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

Hi,

 

In my optmodel, I have a binary variable which is defined on a set with 3 elements(c,d,v) as: P{c,d,v}

I have another continous variable as x{c,d,v1,v2} which gives me 1 if P{c,d,v1}=1 and P{c,d,v2}=1 and 0 if one of them not , I defined it as

 

con variable_3{<c,d,v1,v2> in set3}:
x[c,d,v1,v2] = P[c,d,v1]*P[c,d,v2]

 

What I did is: I built a big table which has all the combination of v1 and v2 as set3, this makes my problem huge and out of memory. I was wondering about these questions:

 

1. Does it make a difference if I use impvar instead of the constraint for the memory issue

2. I suspect that we can define set3 directly in the opmodel as a product of two other sets without generating a big table as a combination of v1 and v2. Can somebody help me if there is a way to do that.

 

Thank you so much!

 

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

You are asking about a product of binary variables, not a product of sets.  See this doc example that illustrates how to linearize this product.

View solution in original post

4 REPLIES 4
RobPratt
SAS Super FREQ

You are asking about a product of binary variables, not a product of sets.  See this doc example that illustrates how to linearize this product.

Afdoone
Calcite | Level 5

Thank you! It was a very good example. The only question I have is this:

 

In this example variables assign is binary :

var Assign {DEPTS, CITIES} binary;

 and variable product is defined as binary too

var Product {IJKL} binary;
con Product_def {<i,j,k,l> in IJKL}: Assign[i,j] + Assign[k,l] - 1 <= Product[i,j,k,l];
con Product_def2 {<i,j,k,l> in IJKL}: Product[i,j,k,l] <= Assign[i,j];
con Product_def3 {<i,j,k,l> in IJKL}: Product[i,j,k,l] <= Assign[k,l];

I think we dont need to define "product" as binary since based on the constraint I see here it automaticlly gets 1 and zero, is this correct?

RobPratt
SAS Super FREQ

Glad to help.

 

Yes, you can relax the new variable, and this idea is mentioned in the doc example:

"In both formulations, the Product variable can be relaxed to be nonnegative instead of binary. The integrality of Assign, together with the various Product_def* constraints, automatically implies integrality of Product. For real-world problems, you should try both ways to determine which alternative performs better in specific cases."

Afdoone
Calcite | Level 5
Perfect! Thank you so much!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1169 views
  • 0 likes
  • 2 in conversation