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 dont know why we use IMPVAR.

I have the following code

PROC OPTMODEL;
/* declare sets and parameters */
set RESOURCES = /labor metal wood/;
set PRODUCTS = /desks chairs bookcases bedframes/;
num selling_price {PRODUCTS} = [94 79 125 109];
num cost {RESOURCES} = [14 20 11];
num availability {RESOURCES} = [225 117 420];
num required {PRODUCTS, RESOURCES} =
[2 1 3
1 1 3
3 1 4
2 1 4];
/* 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 have two question:

1-Please can someone tell me why are we using IMPVAR?

2- Can someone solve the above example using VAR only so that I can know the difference between VAR and IMPVAR.

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

As described here, implicit variables are useful when the same expression is needed in several places and you don't want to increase the number of explicit variables and constraints.

For your code, if you wanted to replace the first implicit variable, for example, it would look like this:

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

 

View solution in original post

1 REPLY 1
RobPratt
SAS Super FREQ

As described here, implicit variables are useful when the same expression is needed in several places and you don't want to increase the number of explicit variables and constraints.

For your code, if you wanted to replace the first implicit variable, for example, it would look like this:

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

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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
  • 1 reply
  • 1366 views
  • 0 likes
  • 2 in conversation