简体   繁体   中英

python solve the simultaneous equations with solutions > 0

I have simultaneous equations(with many equations), which are no solution, and I need to find a best solutions. Each element of solution must>0 (no 0 or negative).

np.linalg.lstsq could get the best solution, but may also appear negative elements.

scipy.optimize.nnls could get best solution without negative elements, but may also appear 0.

How can I restrict to get the best solution with each element>0 or is there any other function can use to solve the problem?

For each parameter p , define p_ = p - eps for very small eps .

Solve for {p_} , then assign p = p_ + eps and you get all parameters above zero.

In practice, just add epsilon to the solution.

If that doesn't suffice, please explain why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM