diff --git a/instances/samples/s1.json b/instances/samples/s1.json index 018fb13..6a520e0 100644 --- a/instances/samples/s1.json +++ b/instances/samples/s1.json @@ -76,7 +76,7 @@ "L1": { "latitude": 0.0, "longitude": 0.0, - "capacity": 500, + "capacity": 5000, "opening cost": 2000, "fixed operating cost": 70.0, "variable operating cost": 70.0, @@ -95,7 +95,7 @@ "latitude": 0.5, "longitude": 0.5, "opening cost": 1000, - "capacity": 750, + "capacity": 7500, "opening cost": 1000, "fixed operating cost": 50.0, "variable operating cost": 50.0 diff --git a/src/model.jl b/src/model.jl index 56534d6..7225e1a 100644 --- a/src/model.jl +++ b/src/model.jl @@ -21,6 +21,7 @@ mutable struct ProcessNode <: Node incoming_arcs::Array outgoing_arcs::Array fixed_cost::Float64 + capacity::Float64 end mutable struct ShippingNode <: Node @@ -131,8 +132,8 @@ function create_process_node_constraints!(mip, nodes, vars) for a in n.outgoing_arcs @constraint(mip, vars.flow[a] == a.values["weight"] * input_sum) end - # If plant is closed, input must be zero - @constraint(mip, input_sum <= 1e6 * vars.open_plant[n]) + # If plant is closed, input must be zero. If plant is opened, input must be below capacity. + @constraint(mip, input_sum <= n.capacity * vars.open_plant[n]) end end @@ -166,7 +167,18 @@ function create_nodes_and_arcs(instance) for plant in product["input plants"] for (location_name, location) in plant["locations"] cost = location["opening cost"] + location["fixed operating cost"] - n = ProcessNode(product_name, plant["name"], location_name, [], [], cost) + if "capacity" in keys(location) + capacity = location["capacity"] + else + capacity = 1e10 + end + n = ProcessNode(product_name, + plant["name"], + location_name, + [], # incoming_arcs + [], # outgoing_arcs + cost, + capacity) process_nodes[n.product_name, n.plant_name, n.location_name] = n end end diff --git a/src/schemas/input.json b/src/schemas/input.json index 2d0ebc4..6c6a390 100644 --- a/src/schemas/input.json +++ b/src/schemas/input.json @@ -31,6 +31,7 @@ "variable operating cost": { "type": "number" }, "fixed operating cost": { "type": "number" }, "opening cost": { "type": "number" }, + "capacity": { "type": "number" }, "disposal": { "type": "object", "additionalProperties": {