Obsidian | Level 7

## Using PROC OPTMODEL to calculate profit and shadow price

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;```

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.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

## Re: Using PROC OPTMODEL to calculate profit and shadow price

``````num required {PRODUCTS, RESOURCES} = [
0.5  0.4 0.1
0.25 0.5 0.25
];
``````
5 REPLIES 5
SAS Super FREQ

## Re: Using PROC OPTMODEL to calculate profit and shadow price

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;
``````
Obsidian | Level 7

## Re: Using PROC OPTMODEL to calculate profit and shadow price

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

SAS Super FREQ

## Re: Using PROC OPTMODEL to calculate profit and shadow price

``````num required {PRODUCTS, RESOURCES} = [
0.5  0.4 0.1
0.25 0.5 0.25
];
``````
Obsidian | Level 7

## Re: Using PROC OPTMODEL to calculate profit and shadow price

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 Super FREQ

## Re: Using PROC OPTMODEL to calculate profit and shadow price

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