问题
I am using scipy.optimize.nnls
to compute non-negative least square fit with a coefficients sum to 1. I always get the same solution when I run the computation. This is the code I am using :
#! /usr/bin/env python3
import numpy as np
import scipy.optimize as soptimize
if __name__ == '__main__':
C = np.array([[112.771820, 174.429720, 312.175750, 97.348620],
[112.857010, 174.208300, 312.185270, 93.467580],
[114.897210, 175.661850, 314.275100, 99.015480]
]);
d = np.array([[112.7718, 174.4297, 312.1758, 97.3486],
[112.7718, 174.4297, 312.1758, 97.3486]]);
for line in d:
ret , _= soptimize.nnls(C.T, line)
print(ret)
And everytime I get :
[9.99992794e-01 7.27824399e-06 0.00000000e+00]
[9.99992794e-01 7.27824399e-06 0.00000000e+00]
I need to compute multiple solutions with a tolerance range, and select the solution that fits best my needs. Do anyone know how to get different solutions for the same input matrix ?
来源:https://stackoverflow.com/questions/50587012/multiple-solution-with-scipy-optimize-nnls