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!
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.
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.
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?
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."
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.