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
num required {PRODUCTS, RESOURCES} = [
0.5 0.4 0.1
0.25 0.5 0.25
];
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;
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
num required {PRODUCTS, RESOURCES} = [
0.5 0.4 0.1
0.25 0.5 0.25
];
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
Yes, dual values and shadow prices are synonymous:
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.