Hi there,
I want to solve this equation, by finding the value of each x1, x2, x3, lb1, lb2, lb3, lb4 (lb stands for lambda), as written down in the following system.
I have tried to write down some syntax as follow:
proc optmodel;
var x{1..3} >= 0;
var lb{1..4} >= 0;
con r1: 2*x[1]-8+lb[1]-lb[2]=0;
con r2: 3*lb[1]-2-lb[3]=0;
con r3: (2*lb[1])-1-lb[4]=0;
con r4: x[1]+3*x[2]+2*x[3]<=12;
con r5: lb[1]*(x[1]+3*x[2]+2*x[3])=0;
con r6: lb[2]*x[1]=0;
con r7: lb[3]*x[2]=0;
con r8: lb[4]*x[3]=0;
solve;
print x;
print lb;
quit;
Even though the program could run without any error, it resulted unexpected value:
x[1] = -2.2223E-14
x[2] = -7.3896E-15
x[3] = -1.3411E-14
I'm expecting that x[1] = 11/3, x[2] = 25/9, and x[3] = 0.
I'm not really sure what to do with my code, so any suggestion would be helpful.
Regards.
Hi @aloevera and welcome to the SAS Support Communities!
Let me first say that I have neither experience with SAS/OR nor a license for this module, so can't test anything.
But the discrepancy between your expectation and the result from PROC OPTMODEL is most likely due to the missing -12 in constraint r5 (cf. equation no. 12).
Hi @aloevera and welcome to the SAS Support Communities!
Let me first say that I have neither experience with SAS/OR nor a license for this module, so can't test anything.
But the discrepancy between your expectation and the result from PROC OPTMODEL is most likely due to the missing -12 in constraint r5 (cf. equation no. 12).
Hi @FreelanceReinh,
Thank you for visiting this thread.
Now I realized that the equation is incomplete as you said, and I have corrected.
At the moment, I could obtain the values that are pretty near to the expected one.
Thank you for your sharp eye and assistance.
Regards
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: