6
$\begingroup$

Notation

  • $\text{src}_{h,s},\text{dst}_{h,s},\text{ch}_{h,s}$ are constants.

  • $a_{h,s},x_{i,j,s}$ are binary variables.

  • $\text{wt}_{h,s}$ are continuous variables.

Problem

\begin{align}\min.&\qquad\sum_{h \in H}\sum_{s\in S}(\text{src}_{h,s}+\text{ch}_{h,s}+\text{dst}_{h,s}+\text{wt}_{h,s})\times a_{h,s}\\\text{s.t.}&\qquad{\forall i,j\in H,\,\forall s\in S}:\text{wt}_{j,s}\geq((\text{src}_{i,s}+\text{ch}_{i,s}+\text{wt}_{i,s})-\text{src}_{j,s})\times x_{i,j,s}\end{align}

Now $x_{i,j,s} = 1$ only when vehicle $i$ charges before vehicle $j$. (Finding minimum time for vehicle to reach to its destination) for reference.

Vehicle $i$ charges before $j$ only when $\text{src}_{i,s} < \text{src}_{j,s}$ so how could I force $x_{i,j,s} = 1$ when this condition meets?

$\endgroup$
3
  • 3
    $\begingroup$ If $src$ are constants, then you know in advance whether $i$ charges before $j$, and you can just force $x_{ijs} = 1$ in this case (via a constraint or via treating it like a constant) — or am I missing something? $\endgroup$ Commented Aug 3, 2019 at 21:42
  • $\begingroup$ yes, you are right. $\endgroup$
    – ooo
    Commented Aug 4, 2019 at 8:50
  • 1
    $\begingroup$ In that case I will write it as an answer in case it is useful to future readers. $\endgroup$ Commented Aug 5, 2019 at 0:41

2 Answers 2

5
$\begingroup$

Since the $\text{src}$ are constants, you know in advance whether $i$ charges before $j$, and you can just force $x_{ijs}=1$ in this case (via a constraint or by treating it like a constant).

$\endgroup$
9
$\begingroup$

Add two indicator constraints:

  • when $x_{i,j,s} = 1$, the condition must be true ($i$ charges before $j$)
  • when $x_{i,j,s} = 0$, the condition must be false ($i$ charges after $j$)

Most commercial solvers have simple APIs that allow you to add indicator constraints directly, without reformulation. For example, here's the documentation for Gurobi's addGenConstrIndicator function.

$\endgroup$
1
  • 4
    $\begingroup$ Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: or.stackexchange.com/questions/231/… $\endgroup$
    – dxb
    Commented Aug 3, 2019 at 21:44

Your Answer

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

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