print(support.list_to_string(id0)+"----- new value of objective function for instance "+str(instance.id[-1])+" fixed 0 : "+str(round(pyo.value(instance.objective),2)))
pprint(support.list_to_string(id0)+"----- new value of objective function for instance "+str(instance2.id[-1])+" fixed 1 : "+str(round(pyo.value(instance2.objective),2)))
instance.lower_bound=cbc.lower_bound(instance)
instance.lower_bound=cbc.lower_bound(instance)
instance2.lower_bound=cbc.lower_bound(instance2)
instance2.lower_bound=cbc.lower_bound(instance2)
log.write_timed("branching found over index "+str(index)+" with value "+str(instance.x[index].value),instance.id)
log.write("value of objective function for new instance "+str(instance.id[-1])+" which fixed variable at 0 is "+str(round(pyo.value(instance.objective),2)),id0)
log.write("value of objective function for new instance "+str(instance2.id[-1])+" which fixed variable at 1 is "+str(round(pyo.value(instance2.objective),2)),id0)
#ATTENTION : for feasible_integer_found to be true we only need to verify is_integer and connected components heuristic (not all other constraint generation heuristics)
#ATTENTION : for feasible_integer_found to be true we only need to verify is_integer and connected components heuristic (not all other constraint generation heuristics)
#therefore, when adding new heursitics in the future, this breaking condition will have to be placed else where to happen also right after said heuristic
#therefore, when adding new heursitics in the future, this breaking condition will have to be placed else where to happen also right after said heuristic
log.write("objective function after loop "+str(loop_count)+" : "+str(round(obj_val,4))+" ( "+str(support.integer_percent(instance))+"% integer )",instance.id)
ifdebug:
#we verify that we are not stuck in an unmoving loop
pprint(support.list_to_string(instance.id)+"----- value of objective function during column generation "+str(loop_count)+" is "+str(round(pyo.value(instance.objective),10))+" and is "+str(support.integer_percent(instance))+"% integer")
ifabs(obj_val-obj_val_old)<0.00000001:
log.write("no evolution in column_generation, moving on to branching",instance.id)
break
obj_val_old=obj_val
loop_count+=1
loop_count+=1
returnfeasible_integer_found
defremove_inactive_constraints(instance):
defremove_inactive_constraints(instance):
#must disable constraints that are inactive being careful of the fact that they may become active again later on...
#must disable constraints that are inactive being careful of the fact that they may become active again later on...
log.title("starting CVRP solving for "+str(instance.n.value)+" nodes, "+str(instance.number_of_vehicles.value)+" vehicles with capacity of "+str(instance.capacity.value))
print("++++++++++ starting CVRP solving for "+str(instance.n.value)+" nodes, "+str(instance.number_of_vehicles.value)+" vehicles with capacity of "+str(instance.capacity.value))
log.write("initial upper bound of cvrp problem is "+str(instance_manager.upper_bound))
#solving the initial instance in order to initialize instance.x values
#solving the initial instance in order to initialize instance.x values
results=opt.solve(instance)
results=opt.solve(instance)
#printing initial value of objective function
#printing initial value of objective function
ifdebug:
log.write_spaced("0: initial value of objective function "+str(round(pyo.value(instance.objective),2))+" and is "+str(support.integer_percent(instance))+"% integer")
print("0----- initial value of objective function "+str(round(pyo.value(instance.objective),2))+" and is "+str(support.integer_percent(instance))+"% integer")
print("lower bound found :"+str(pyo.value(instance_manager.partial_solution_recorded[0].objective)))
log.write("best lower bound found :"+str(pyo.value(instance_manager.partial_solution_recorded[0].objective))+" and is "+str(support.integer_percent(instance_manager.partial_solution_recorded[0]))+"% integer")