[Numpy-discussion] solving linear equations
Hanno Klemm
klemm at phys.ethz.ch
Fri Mar 9 04:35:18 EST 2012
Hi,
have a look at scipy optimize. For a solution with only positive values you could consider using scipy.optimize.nnls, if you want more general (linear) constraints, have a look at the linear programming functions.
Another possibility would be looking at openOpt, which has probably more general solvers.
On Mar 9, 2012, at 7:33, salahudeen razac wrote:
>
> I wrote a script to solve the equation ‘P =Kd .V2 + Kl.VA.BT + C’ . To solve the equation I have used the matrix method.
>
>
> Ie, K*X = P where
>
> [P] = [ P1
>
> P2 a column matrix with the total powers P1, P2,P3…….PN at (V1,T1),(V2,T2)……(VN.TN) respectively,\
>
> P3
>
> ..
>
> PN ]
>
>
>
> [K] = [ V12 V1A.BT1 1
>
> V22 V2A.BT2 1
>
> V32 V3A.BT3 1
>
> ………………………..
>
> VN2 VNA.BTN 1 ]
>
>
>
> [X]= [ Kd A column matrix with the unknowns
>
> Kl
>
> C ]
>
>
> Now in order to solve multiply both sides with KT, ie KT.K.X = KTP or A.X = B where A= KT.K and B= KTP
>
>
>
> Now we will get the matrix X by using linalg.solve(A,B) function which will eventually solve for a set of linear equations of the form Ax=B
>
>
>
> I was able to get the solution. But it is not acceptable since some of the values are negative. SO I want to know is there any way to give some constraints like the solution should contain only positive values and give any range for the solution?
>
>
>
> I also tried with linalg.lstsq and I am getting the same results
>
> -----
> Salahudeen razak | +917760902602
>
> o__
> _> /__
> (_) \(_)... Burn fat not fuel
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120309/c77c341d/attachment.html>
More information about the NumPy-Discussion
mailing list