Making matrix solver/ solver for X

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Apr 14 20:49:33 EDT 2018


steffie.booij at gmail.com wrote:
> Q = np.array(['Q1', 'Q2', 'Q3', 'Q4'])
> 
> P = (X*Q)-X

I'm assuming that 'Q1', etc. are placeholders for numbers here?
Otherwise, you're doing arithmetic with strings, which doesn't
make sense.

> So solve condition:
> P[0]+P[1] ,P[0]+P[2] ,P[0]+P[3] ,P[1]+P[2] ,P[1]+P[3] ,P[2]+P[3] >= np.sum(X)

This looks like a linear programming problem:

https://en.wikipedia.org/wiki/Linear_programming

except that there's no objective function (something to be
maximised or minimised) so there won't be a unique solution.

If you can frame it as a linear programming problem,
you could use this:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linprog.html

If there are no other constraints that the solution needs to
satisfy, then you could just make up an objective function,
e.g. tell it to minimise sum(X).

Also, if you can tell us more about the original problem you're
trying to solve, we may be able to help more.

-- 
Greg


More information about the Python-list mailing list