BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aloevera
Calcite | Level 5

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.

aloevera_0-1602824477153.pngaloevera_0-1602824477153.png

 

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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).

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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).

aloevera
Calcite | Level 5

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

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2263 views
  • 0 likes
  • 2 in conversation