Original Message:
Sent: Wed November 03, 2021 01:42 PM
From: Nourredine Hail
Subject: Define decision variable on a set of integer numbers
Hi Hugues,
I got your answer to my first question, but I realized that this question did not describe the real issue I have.
Below is a part of the problem I am trying to formulate.
Given n integer decision variables that I want to define on a set of integers, e.g. {1, 3, 5, 17, 21, 13, 7, 11}. Here n = 8.
How can I define formulate this knowing that all decision variables must take different value?
I hope it is clearer now.
Thanks, and I am sorry for the confusion.
|  | Nourredine Hail, PhD in Applied Mathematics Senior Operations Research & Data Scientist Data Analytics Governance team Canadian Tire Corporation 2111 Steeles Avenue East, Brampton, ON, L6T4L5 Phone: 905.792.5983 nourredine.hail@cantire.com |
"Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young." Henry Ford
Original Message:
Sent: 11/3/2021 1:11:00 PM
From: Hugues Juille
Subject: RE: Define decision variable on a set of integer numbers
Hi Nourredine,
I'm a bit confused...
In the example of my previous e-mail, the decision variable element_val can only take values in {1, 3, 5, 17, 21, 13, 7, 11} because of the "element" constraint. This is the formulation in the OPL language (if CP is used as a solver).
Then, constraints in your model would be formulated using this element_val decision variable.
I thought this was the purpose of your question.
I'm certainly misunderstanding what you are asking for.
Can you please give more details about your context? Are you using a MIP or a CP model ? Which modelling language are you using (OPL, docplex, Cplex API... ?)
Thanks,
------------------------------
Hugues Juille
------------------------------
Original Message:
Sent: Wed November 03, 2021 10:40 AM
From: Nourredine Hail
Subject: Define decision variable on a set of integer numbers
Thanks, Hugues.
Let us assume, the decision variable element_val is defined on the range elements_idx (element_val [elements_idx]) taking different values in {1, 3, 5, 17, 21, 13, 7, 11}.
How would you formulate this?
Thanks
|  | Nourredine Hail, PhD in Applied Mathematics Senior Operations Research & Data Scientist Data Analytics Governance team Canadian Tire Corporation 2111 Steeles Avenue East, Brampton, ON, L6T4L5 Phone: 905.792.5983 nourredine.hail@cantire.com |
"Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young." Henry Ford
Original Message:
Sent: 11/3/2021 9:54:00 AM
From: Hugues Juille
Subject: RE: Define decision variable on a set of integer numbers
Hi,
The first idea that comes to my mind is that you need some form of indirection.
In the case of a combinatorial problem using CP, this can be implemented using the "element" function.
Here is a simple OPL example to illustrate the use of this function:
using CP;int NB_ELEMENTS = 7;range elements_idx = 0..NB_ELEMENTS;int elements_list[elements_idx] = [1, 3, 5, 17, 21, 13, 7, 11];dvar int idx in elements_idx;dvar int element_val;maximize element_val;subject to { element_val == element(elements_list, idx);}
which would result in the following solution:
// solution with objective 21element_val = 21;idx = 4;
In the case of a MIP model, a similar approach could be used by creating as many boolean decision variables as there are elements to choose from, and to enforce that the sum over all these binary variables is equal to 1.
The actual value for the desired decision variable is then a dot product between the vector of boolean decision variables and the list of values.
Regards,
------------------------------
Hugues Juille