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.B T2 1* * V32 V3A.B T3 1* * ………………………..* * VN2 VNA.B TN 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 * * *
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@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (2)
-
Hanno Klemm -
salahudeen razac