Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

How to define product of sets in optmodel

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

How to define product of sets in optmodel

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!

 


Accepted Solutions
Solution
‎12-05-2016 12:23 PM
SAS Employee
Posts: 448

Re: How to define product of sets in optmodel

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


All Replies
Solution
‎12-05-2016 12:23 PM
SAS Employee
Posts: 448

Re: How to define product of sets in optmodel

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.

Occasional Contributor
Posts: 9

Re: How to define product of sets in optmodel

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?

SAS Employee
Posts: 448

Re: How to define product of sets in optmodel

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."

Occasional Contributor
Posts: 9

Re: How to define product of sets in optmodel

Perfect! Thank you so much!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 215 views
  • 0 likes
  • 2 in conversation