6

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?

ooo
  • 1,589
  • 4
  • 12

2 Answers2

9

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.

Simon
  • 1,132
  • 8
  • 16
  • 4
    Here is an earlier OR.SE post on using indicator constraints, with answers focusing on a couple of different packages: https://or.stackexchange.com/questions/231/when-to-use-indicator-constraints-versus-big-m-approaches-in-solving-mixed-int – dxb Aug 03 '19 at 21:44
5

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

LarrySnyder610
  • 13,141
  • 3
  • 41
  • 105