1
$\begingroup$

I try to model a decision process in which I first need to decide about a binary variable $x$. In case $x=1$, I also need to decide upon variable $y$ and the value of $y$ is not defined otherwise. Especially, I do not know how to correctly introduce constraints. Assume that I want to model a constraint that states that $y$ needs to be greater than 5. Of course I could then just state: \begin{equation}\label{eq:cap} y > 5 \end{equation} But this would suggest that $y$ has a defined value, which does not need to be the case (if $x = 0$).

Is there a standard way how to introduce such a variable and associated constraints (e.g. in an IP or MDP)?

$\endgroup$
4
  • 3
    $\begingroup$ The answer will depend on whether $y$ appears in the objective function and how it appears in the constraints. Basically, there are two possibilities for when $x=0$: either you do not care what value $y$ takes, or you need it to take a specific value (most likely 0, possibly 1 if it multiplies other variables) that would be the algebraic equivalent of omitting it from the constraints. So we need more detail about how $y$ is used in the model. $\endgroup$
    – prubin
    Jan 19, 2022 at 17:35
  • $\begingroup$ You could add $y\ge 5 x$. This way, if $x=1$, you have $y\ge 5$, but if $x=0$, $y$ can take any non negative value. I agree with @prubin, more detail is needed to provide a complete answer though. $\endgroup$
    – Kuifje
    Jan 20, 2022 at 9:38
  • $\begingroup$ Thank you for your answers @prubin. I cannot just set the value of y to 0, because it corresponds to a geographical position and appears in the objective function. Any value of y would lead to costs > 0. A solution would be (similar to the suggestion of @Kuifje) to multiply the term in the objective function by x, so that the value of y only matters if x=1. But I was wondering if there is another standard way of introducing such a relationship mathematically. $\endgroup$
    – PeterD
    Jan 20, 2022 at 17:43
  • 1
    $\begingroup$ The usual approaches to that would basically amount to doing what you suggest (multiplying the cost term by $x$) and then linearizing it. $\endgroup$
    – prubin
    Jan 20, 2022 at 18:58

1 Answer 1

2
$\begingroup$

Optional decision variables are part of the building block of scheduling within CPLEX CPOptimizer.

For instance

using CP;

dvar interval s size 1;
dvar interval e size 1;
dvar interval itvs optional size 7;

maximize presenceOf(itvs);
subject to
{
  startOf(s)==1;
  startOf(e)==8;
  startBeforeStart(itvs,s);
  startBeforeEnd(e,itvs);  
}

int isPresent=presenceOf(itvs);
execute
{
  writeln("isPresent=",isPresent);
}

gives

isPresent=1

but if I turn

dvar interval itvs optional size 7;

into

dvar interval itvs optional size 5;

then we get

isPresent=0

The constraints on itvs (start and end) are valid as long as the optional interval is present.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.