def _add_maximum_makespan_constraints(self): """Defines maximum makespan""" for route in range(1, self._n_columns): self.makespan_constr[route] = pulp.LpConstraintVar( "makespan_%s" % route, pulp.LpConstraintLE, 0, )
def _add_set_covering_constraints(self): """ All vertices must be visited exactly once, or periodically if frequencies are given. If dropping nodes is allowed, the drop variable is activated (as well as a penalty is the cost function). """ for node in self.G.nodes(): if (node not in ["Source", "Sink"] and "depot_from" not in self.G.nodes[node] and "depot_to" not in self.G.nodes[node]): # Set RHS right_hand_term = (self.G.nodes[node]["frequency"] if self.periodic else 1) # Save set covering constraints self.set_covering_constrs[node] = pulp.LpConstraintVar( "visit_node_%s" % node, pulp.LpConstraintGE, right_hand_term)
def __init__(self, *args): super(_MasterSolvePulp, self).__init__(*args) # create problem self.prob = pulp.LpProblem("MasterProblem", pulp.LpMinimize) # objective self.objective = pulp.LpConstraintVar("objective") # variables self.y = {} # route selection variable self.drop = {} # dropping variable self.dummy = {} # dummy variable self.dummy_bound = {} # dummy variable for vehicle bound cost self.makespan = {} # maximum global span # constrs self.set_covering_constrs = {} self.vehicle_bound_constrs = {} self.drop_penalty_constrs = {} self.makespan_constr = {} # Restricted master heuristic self.diving_heuristic = _DivingHeuristic() # Parameter when minimizing global span self._n_columns = 1000 self._formulate()
def _add_bound_vehicles(self): """Adds empty constraints and sets the right hand side""" for k in range(len(self.num_vehicles)): self.vehicle_bound_constrs[k] = pulp.LpConstraintVar( "upper_bound_vehicles_%s" % k, pulp.LpConstraintLE, self.num_vehicles[k])