1
$\begingroup$

I'm currently trying to replicate a vehicle routing problem paper, and I'm facing trouble writing the said constraints in the paper in Pyomo. I've been able to generate the data as required by the model, but unfortunately due to my limited experience with Pyomo, I'm unable to write some constraints.

I have declared my variables and index sets in Pyomo like this: 

J = list(S_i_dict.keys()) # Set of locations 
I = list(S_i_dict.keys())  # Set of Facilties 
K = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

#Step 2: Define variables
model_1.x_ij = Var(I,J, within = Binary) # if a demand point i is assigned to a vaccination centre j at a time period t 
model_1.y_i = Var(I, within = Binary) 
model_1.z_ijk = Var(I, J, K within = Binary)
model_1.u_ik = Var(I, K, domain = NonNegativeIntegers)
model_1.w_i = Var(I, domain = NonNegativeIntegers)

$z_{iik} = 0 \ \ \forall i,k$

I'm unable to write the above constraint as I've fixed model_1.z_ijk = Var(I, J, K within = Binary).

$$U_{ik} - U_{jk} + pZ_{ijk} \leq p - W_{j} \forall \ \ i,j,k $$

Similar to the above problem, I've fixed model_1.u_ik = Var(I, K, domain = NonNegativeIntegers).

Additionally, I'm finding trouble to write the following constraint -

$$W_i = \sum_{0 \leq j \leq n=1} b_j X_{ij} \forall \ \ i \leq n$$

Hoping I receive some help on writing these constraints, I've already the Pyomo cookbook, but I continue to struggle. Thanks in advance!

$\endgroup$
1
  • $\begingroup$ There are multiple examples in the Pyomo cookbook or the pyomo gallery which demonstrate how to add constraints. Also, note that this isn't a complete example. What are $b_j$, $p$ and $n$? $\endgroup$
    – joni
    Jul 21 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy