0

I am working on a logistics supply-demand problem involving the loading of vessels over a 7-day horizon.

I am trying to define a binary variable that indicates the date a vessel is loaded i.e. 1 = Can load or 0 = can't load. This criteria is determined by the inventory availability: if material is available, the vessel can load.

Current output

Currently the output of the binary variable is always 1, which is incorrect because once the vessel is loaded then the shipment is complete. As a result the shipment variable (which signifies what date the vessel demand is satisfied) is at 1.0 for each day in the planned horizon

Desired Output

I need the binary variable to signify when a vessel can load (1/0). The vessel can only load after it has arrived, and if sufficient material is available in the inventory.

Binary Constraint Formulation

Code and definitions below:

Owing to the amount of code in the model (including variable formation) it is very difficult to provide an MRE, so I am hoping that someone can spot the error in the definition of the binary variable/constraint expression.

  • vessel_grade_demand_tonnes[vessel, grade]: Constant. the required amount, in tonnes of each grade required by each vessel.
  • vessel_sales_demand_vars[(vessel, grade, date)]: Variable. The date a vessels demand requirements are fully satisfied i.e. ship is loaded with all grades it requires.
  • vessel_load_start_date[vessel, date]: Binary. The date indicating when a vessel can be loaded. NOTE a vessel can only load if the total amount it requires is available in the port inventory, port_inventory_vars[date, grade].

Code:

# Vessel can only load when sufficient material available.
for date, vessel, grade in vessel_sales_temp:
  model += vessel_load_start_date[vessel, date] * vessel_sales_demand_tonnes[date, vessel, grade] <= port_inventory_vars[date, grade]

  
# All vessel requirements must be satisfied on one day, defined by loading date
for grade in grades:
  for vessel, date in vessel_load_start_date:
    model += vessel_load_start_date[vessel, date] * vessel_grade_demand_tonnes[vessel, grade] == pulp.lpSum(vessel_grade_demand_tonnes[vessel, grade])
    model += vessel_sales_demand_vars[(vessel, grade, date)] <= vessel_load_start_date[vessel, date] * vessel_grade_demand_tonnes[vessel, grade]
    
# Vessel sales requirements vars must equal the total required sales tonnes 
for vessel, grade, date in vessel_sales_demand_vars:
    model += pulp.lpSum(vessel_sales_demand_vars[vessel, grade, date]) == vessel_grade_demand_tonnes[vessel, grade]

All help gratefully received.

cmp
  • 568
  • 3
  • 16
  • If the constraint you've shown in the formualation is the only constraint involving `y_it` then the problem is that you haven't set the constraints to control when `y_it` can be 1 - i.e. it has to be after the vessel has arrived etc. – kabdulla Jun 29 '20 at 06:34
  • Yes - this is the constraint I think is currently causing the issue. I have tried to define it here `# Vessel can only load when sufficient material available. for date, vessel, grade in vessel_sales_temp: model += vessel_load_start_date[vessel, date] * vessel_sales_demand_tonnes[date, vessel, grade] <= port_inventory_vars[date, grade]`. The binary variable, `y_it` is supposed to be `1` when `sum(I_jt) >= sum(x_ijt)`, where `I` is the port inventory, meaning the vessel is able to load because material is available in the inventory to do so. – cmp Jun 29 '20 at 08:48
  • I should note that `load_start_date` is a dict of vessel:date combinations after the vessel has arrived. – cmp Jun 29 '20 at 08:58
  • @kabdulla could you please show how you would define the binary variable? – cmp Jun 30 '20 at 07:02
  • @cmp did you find any solution for this? – Tavish Aggarwal Jul 25 '22 at 13:11

0 Answers0