Simplex MethoDe

24 views
Skip to first unread message

yefim rozenkrants

unread,
Oct 11, 2014, 6:05:02 AM10/11/14
to nume...@googlegroups.com
Dear Sebastien.

Sorry for bothering you, but I couldn't find in documentation how correctly set the data for LP problem.
According to example in the documentation I assumed that for problem like following

 minimize c1*x1 + c2*x2 +c3*x3
 subject to
 b1r <= a11*x1 +a12*x2 + a13*x3 <= b1l
 a21*x1 +a22*x2 + a23*x3 <= b2l
 r1<=x1 , x2<=r2

the data should look like this:

c=[c1, c2, c3]
A=[[-1, 0, 0], [0, -1, 0], [0, 0, -1],
[a11, a12, a13], [-a11, -a12, -a13],
[-a21, -a22, -a23],
[1, 0, 0], [0, -1, 0]]
b=[0, 0, 0, b1r, -b1l, b2l, r1, -r2]

Please correct me if I'm wrong.
I'll appreciate your help
Yefim 

Sébastien Loisel

unread,
Oct 11, 2014, 6:41:39 AM10/11/14
to nume...@googlegroups.com
Hi,

Your matrices look weird. This looks better to me:

c=[c1, c2, c3]
A=[[a11, a12, a13], 
   [-a11, -a12, -a13],
   [a21, a22, a23],
   [-1, 0, 0], 
   [0, 1, 0]]
b=[b1l, -b1r, b2l, -r1, r2]


--
You received this message because you are subscribed to the Google Groups "numericjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numericjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sébastien Loisel
Assistant Professor
Department of Mathematics, Heriot-Watt University
Riccarton, EH14 4AS, United Kingdom
web: http://www.ma.hw.ac.uk/~loisel/
email: S.Loisel at hw.ac.uk
phone: +44 131 451 3234
fax: +44 131 451 3249

yefim rozenkrants

unread,
Oct 11, 2014, 5:24:22 PM10/11/14
to nume...@googlegroups.com
-------------------------------------

Sebasien, thanks for your respond. But I still have problems.

It looks like that I’m missing something, because I got weird results. I've create data according your suggestion and got the solution where some variables have negative values.

Could you please point me in the right direction.

                Here the example:

Minimize:
 0.0269*c1 + 0.00001*c2 + 0.00001*c3 + 0.00001*c4 + 0.00001*c5 + 0.00001*c6 + 0.264*c7 + 0.0774*c8 + 0.0267*c9 + 0.053*c10 + 0.0006*c11

    subject to

 6.54*x1 + 0.01*x2 + 0.01*x3 + 1.76*x4 + 3.16*x5 + 1.82*x6 + 3.62*x7 + 2.39*x8 + 0.98*x9 + 0.56*x10 + 7.17*x11 <= 1600
 -0.1523*x1 - 0.0012*x2 - 0*x3 - 0.2563*x4 - 0.1802*x5 - 0.035*x6 - 0.078*x7 - 0.167*x8 - 0.1112*x9 - 0.041*x10 - 0.0085*x11 >= 40
 0.1523*x1 + 0.0012*x2 + 0*x3 + 0.2563*x4 + 0.1802*x5 + 0.035*x6 + 0.078*x7 + 0.167*x8 + 0.1112*x9 + 0.041*x10 + 0.0085*x11 <= 140
 -0.6521*x1 - 0.0002*x2 - 0*x3 - 0.0819*x4 - 0.2241*x5 - 0.049*x6 - 0.018*x7 - 0.14*x8 - 0.043*x9 - 0.02*x10 - 0.8111*x11 >= 35.56
 0.6521*x1 + 0.0002*x2 + 0*x3 + 0.0819*x4 + 0.2241*x5 + 0.049*x6 + 0.01*x7 + 0.14*x8 + 0.043*x9 + 0.02*x10 + 0.8111*x11 <= 65.78
 -0.1371*x1 + 0*x2 - 0.003*x3 - 0*x4 - 0.1057*x5 - 0.3075*x6 - 0.85*x7 - 0.116*x8 - 0.0338*x9 - 0.053*x10 - 0.0006*x11 >= 180
 0.1371*x1 + 0*x2 + 0.003*x3 + 0*x4 + 0.1057*x5 + 0.3075*x6 + 0.85*x7 + 0.116*x8 + 0.0338*x9 + 0.053*x10 + 0.0006*x11 <= 260
 0.06126*x1 + 0.00002*x2 + 0.00002*x3 + 0.03244*x4 + 0.04915*x5 + 0.00763*x6 + 0.004*x7 + 0.0879*x8 + 0.01718*x9 + 0.01242*x10 + 0.50489*x11 <= 12.44

The data and solution
=============================================================================================
c: [ 0.0269, 0.00001, 0.00001, 0.00001, 0.00001, 0.00001, 0.264, 0.0774, 0.0267, 0.053, 0.0006 ]

A: [
[ 6.54, 0.01, 0.01, 1.76, 3.16, 1.82, 3.62, 2.39, 0.98, 0.56, 7.17 ],
[ -0.1523, -0.0012, 0, -0.2563, -0.1802, -0.035, -0.078, -0.167, -0.1112, -0.041, -0.0085 ],
[ 0.1523, 0.0012, 0, 0.2563, 0.1802, 0.035, 0.078, 0.167, 0.1112, 0.041, 0.0085 ],
[ -0.6521, -0.0002, 0, -0.0819, -0.2241, -0.049, -0.018, -0.14, -0.043, -0.02, -0.8111 ],
[ 0.6521, 0.0002, 0, 0.0819, 0.2241, 0.049, 0.01, 0.14, 0.043, 0.02, 0.8111 ],
[ -0.1371, 0, -0.003, 0, -0.1057, -0.3075, -0.85, -0.116, -0.0338, -0.053, -0.0006 ],
[ 0.1371, 0, 0.003, 0, 0.1057, 0.3075, 0.85, 0.116, 0.0338, 0.053, 0.0006 ],
[ 0.06126, 0.00002, 0.00002, 0.03244, 0.04915, 0.00763, 0.004, 0.0879, 0.01718, 0.01242, 0.50489 ]
]

b: [ 1600, -40, 148, -35.56, 65.78, -180, 260, 12.44]
----------------------------------------------
 
SOLUTION x (iterations = 21 ):

x0: 4468.396450071527
x1: 6001.613696047467
x2: 3074.6191257127675
x3: 8927.839670335821
x4: 83444.57804672404
x5: 16198.26554441951
x6: -3777.4999999975894
x7: -58046.32498587716
x8: -60105.89789008526
x9: -42614.80254297848
x10: -14144.971656543916

Yefim


Sébastien Loisel

unread,
Oct 12, 2014, 6:54:36 AM10/12/14
to nume...@googlegroups.com
Hi,

Your inequalities have to be of the form Ax<b. That's the same mistake you made the first time around.

On Sat, Oct 11, 2014 at 11:24 PM, yefim rozenkrants <yefim.ro...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "numericjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numericjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages