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

Hi,

I am trying to solve the problem as shown.

sss

I used to following code to solve this:

PROC OPTMODEL;
	/* declare sets and parameters */
	set RESOURCES = /W B S/;
	set PRODUCTS = /SWEET PROTEIN/;

	num selling_price {PRODUCTS} = [1.84 3.45];
	num cost {RESOURCES} = [0.2 0.4 0.8];
	num availability {RESOURCES} = [100 250 50];
	num required {PRODUCTS, RESOURCES} = 
				[0.5  0.25 
				0.4  0.5  
				0.1  0.25  
				];

	/* declare variables */
	var NumProd {PRODUCTS} >= 0;

	impvar Revenue = sum {p in PRODUCTS}
		selling_price[p] * NumProd[p];

	impvar AmountUsed {r in RESOURCES} = 
		sum {p in PRODUCTS} NumProd[p] * required[p,r];

	impvar TotalCost = sum {r in RESOURCES}
		cost[r] * AmountUsed[r];

	/* declare constraints */
	con Usage {r in RESOURCES}: 
		AmountUsed[r] <= availability[r];

	/* declare objective */
	max NetProfit = Revenue - TotalCost;

	/*print model formulation*/
	expand;

	/*solve the model*/
	solve;

	/*print parts of the model*/
	print NumProd;
quit;

but I get wrong answer.

I want to answer the following question:

• the profit (formatted as a $XXX.XX),
• the amount of each type of feed produced,
• a resource usage table showing for each resource: the amount used, the amount available,
the percentage used (formatted as a percentage), and the shadow price.

 

Please can someone help

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ
num required {PRODUCTS, RESOURCES} = [
   0.5  0.4 0.1
   0.25 0.5 0.25
];

View solution in original post

5 REPLIES 5
RobPratt
SAS Super FREQ

You can use SAS formats with the PRINT statement:

print NetProfit dollar7.2;
print NumProd;
print AmountUsed availability
   {r in RESOURCES} (AmountUsed[r]/availability[r]) percent.
   Usage.dual;
rohailk
Obsidian | Level 7

Thank you so much for the reply.

I tried using it but I am not getting the answer which I got graphically. I mean Sweet=125 , Protein=150 and optimal value 637.5.Here I am getting Sweet=0 ...please can you fix my code. thanks

RobPratt
SAS Super FREQ
num required {PRODUCTS, RESOURCES} = [
   0.5  0.4 0.1
   0.25 0.5 0.25
];
rohailk
Obsidian | Level 7

Just one question please.In the output  is the Usage.DUAL is the name for Shadow Price ?

Thank you so much for your help.The code is working with correct answers.....thankssss

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1662 views
  • 2 likes
  • 2 in conversation