PDA

Click to See Complete Forum and Search --> : can someone?


wmosley2
Aug 29th, 2004, 11:07 PM
Cans omeone help me with this one?




Maximize

P = 40x1 + 60x2 + 50x3

Subject to the constraints

2x1 + 2x2 + x3 < 8
X1 – 4x2 + 3x3 < 12

X1 > 0 X2 > 0 X3 > 0

alkatran
Sep 1st, 2004, 12:38 AM
P = 40x1 + 60x2 + 50x3 = 40x + 120x + 150x = 310x
max = infinity

Unless you mean 40x^1 + 60x^2 + 50x^3 in whichcase:
dx/dy(x^n )= nx^n
dx/dy(50x^3 + 60x^2 + 40x) = 150x^2 + 120x + 40

maximums and minimums are at:
150x^2 + 120x + 40 = 0
15x^2 + 12x + 4 = 0
x = (-12 +- sqr(12^2 - 4*15*4))/2*15 = -12/30 +- sqr(144-240)/30
= -2/5 +- i*sqr(96)/30 = -2/5 +- i*4*sqr(6)/30 = -2/5 +- 2i*sqr(6)/15
= -2/5 + .326i or -2/5 - .326i

The answer is imaginary.

sql_lall
Sep 1st, 2004, 04:21 AM
i think they mean there are three variables:

x1, x2 and x3

In that case, there is a simple algorithm that solves all these things for you, I think it's even call SIMPLEX, just search for it, and you'll probably be able to find a program that solves them for you.

alkatran
Sep 1st, 2004, 11:37 AM
Well then why in the world didn't he just use x, y and z??? :confused:

MarcoA
Sep 3rd, 2004, 09:00 AM
Hello:
This simple visual basic probabilistic program can solve your problem:


RANDOMIZE
pmax=-1e30
FOR i=1 TO 10000
' random digits in the range 0-8
x1=INT(8*RND)
x2=INT(8*RND)
x3=INT(8*RND)
' test the inequalities
IF 2*x1+2*x2+x3<8 AND x1-4*x2+3*x3<12 THEN
' calculate p
p=40*x1+60*x2+50*x3
' is better?
IF p>pmax THEN
pmax=p
PRINT x1, x2, x3, pmax
END IF
END IF
NEXT i


The solution is x1=0, x2=1, x3=5 and the maximum is 310
If you wish real numbers rather than integer numbers, remove the "INT" in the code.
Regards

alkatran
Sep 3rd, 2004, 12:15 PM
Originally posted by MarcoA
Hello:
This simple visual basic probabilistic program can solve your problem:


RANDOMIZE
pmax=-1e30
FOR i=1 TO 10000
' random digits in the range 0-8
x1=INT(8*RND)
x2=INT(8*RND)
x3=INT(8*RND)
' test the inequalities
IF 2*x1+2*x2+x3<8 AND x1-4*x2+3*x3<12 THEN
' calculate p
p=40*x1+60*x2+50*x3
' is better?
IF p>pmax THEN
pmax=p
PRINT x1, x2, x3, pmax
END IF
END IF
NEXT i


The solution is x1=0, x2=1, x3=5 and the maximum is 310
If you wish real numbers rather than integer numbers, remove the "INT" in the code.
Regards

int(8*rnd) returns a random number between 0 and 7, not 0 and 8.
also, it would make more sense to just loop x1, x2 and x3 through all the values of 8. It totals up to 512 iterations MAX.