Optimization Routine for two equations, three unknowns

Hi,
I am trying to set up a basic optimization routine in matlab.
Equation 1: 3.6*x*y = 750
Equation 2: 19.8*x*y*z = 800000
x = 6:1:12
y = 20:1:40
z = 150:1:250
Is there a tool/method to solve/optimize this ?
Thank You.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Apr. 2018
>> [X,Y,Z] = ndgrid(6:12,20:40,100:150);
>> mask = (3.6.*X.*Y == 750) & (1.98.*X.*Y.*Z == 800);
>> nnz(mask)
ans =
0
There are no solutions under those constraints.

6 Kommentare

Those equations require that z = 32/165 independently of x and y. Notice that 32/165 is not even close to the z range you indicated -- it is roughly 0.1939 .
DIP
DIP am 29 Apr. 2018
Sorry about that, I missed out on a unit conversion. It should be 800000
Under that circumstance then z must be 6400/33 which is about 193.9393, which at least is in the range you give, but is not one of the choices 150:1:250 . z must be that value exactly for the equations to hold.
DIP
DIP am 29 Apr. 2018
So I basically need to treat this as a 2 equation and 2 unknown and optimize for X and Y keeping Z 193.93. How is it done ?
No, just examine it algebraically.
>> syms x y z
>> Y = solve(3.6*x*y == 750,y)
Y =
625/(3*x)
>> Z = solve(subs(19.8*x*y*z == 800000,y,Y),z)
Z =
6400/33;
>> lbx = solve(Y==20, x)
lbx =
125/12
>> ubx = solve(Y==40, x)
ubx =
125/24
so x must be in the range 125/24 to 125/12 for y to be in the ranges you specified. That is 5.20833 to 10.4166 .
Your x limit starts at 6 and ends at 12. 6 is inside the y range and 12 is outside the y range. So for everything to work out, x must be 6 to 125/12.
>> double(subs(Y,x,6))
ans =
34.7222222222222
>> double(subs(Y,x,125/12))
ans =
20
which fits the given limits.
So given continuous values instead of the discrete values you had asked for, x is any value in the range 6 to 125/12, and y = 625/3 * x, and z is 6400/33
DIP
DIP am 29 Apr. 2018
Thanks Walter. I appreciate the help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

DIP
am 29 Apr. 2018

Kommentiert:

DIP
am 29 Apr. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by