############################################################################## print("Solving model....") msol = mdl.solve() print("Solution: ") msol.print_solution() ############################################################################## # Display result ############################################################################## if msol and visu.is_visu_enabled(): visu.timeline("Solution SchedTime", origin=10, horizon=120) visu.panel("Schedule") for t in ALL_TASKS: visu.interval(msol.get_var_solution(tasks[t.id]), t.id, t.name) for t in ALL_TASKS: if t.release_date is not None: visu.panel('Earliness') itvsol = msol.get_var_solution(tasks[t.id]) cost = fearliness[t].get_value(itvsol.get_start()) visu.function(segments=[(itvsol, cost, t.name)], color=t.id, style='interval') visu.function(segments=fearliness[t], color=t.id) if t.due_date is not None: visu.panel('Tardiness') itvsol = msol.get_var_solution(tasks[t.id]) cost = ftardiness[t].get_value(itvsol.get_end()) visu.function(segments=[(itvsol, cost, t.name)], color=t.id, style='interval') visu.function(segments=ftardiness[t], color=t.id) visu.show()
############################################################################## # Solve model print("Solving model....") msol = mdl.solve(FailLimit=100000) print("Solution: ") msol.print_solution() ############################################################################## # Display result ############################################################################## if msol and visu.is_visu_enabled(): load = [CpoStepFunction() for j in range(nbResources)] for i in range(nbTasks): itv = msol.get_var_solution(tasks[i]) for j in range(nbResources): if 0 < demands[i][j]: load[j].add_value(itv.get_start(), itv.get_end(), demands[i][j]) visu.timeline("Solution for RCPSP " + filename) visu.panel("Tasks") for i in range(nbTasks): visu.interval(msol.get_var_solution(tasks[i]), i, tasks[i].get_name()) for j in range(nbResources): visu.panel("R " + str(j + 1)) visu.function(segments=[(INTERVAL_MIN, INTERVAL_MAX, capacities[j])], style='area', color='lightgrey') visu.function(segments=load[j], style='area', color=j) visu.show()
# Solve model print("Solving model....") msol = mdl.solve(FailLimit=100000) print("Solution: ") msol.print_solution() ############################################################################## # Display result ############################################################################## if msol and visu.is_visu_enabled(): load = [CpoStepFunction() for j in range(nbResources)] for i in range(nbTasks): itv = msol.get_var_solution(tasks[i]) for j in range(nbResources): if 0 < demands[i][j]: load[j].add_value(itv.get_start(), itv.get_end(), demands[i][j]) visu.timeline("Solution for RCPSP " + filename) visu.panel("Tasks") for i in range(nbTasks): visu.interval(msol.get_var_solution(tasks[i]), i, tasks[i].get_name()) for j in range(nbResources): visu.panel("R " + str(j + 1)) visu.function(segments=[(INTERVAL_MIN, INTERVAL_MAX, capacities[j])], style='area', color='lightgrey') visu.function(segments=load[j], style='area', color=j) visu.show()
############################################################################## # Display result ############################################################################## def compact(name): # Example: H3-garden -> G3 # ^ ^ loc, task = name[1:].split('-', 1) return task[0].upper() + loc if msol and visu.is_visu_enabled(): workersF = CpoStepFunction() cashF = CpoStepFunction() for p in range(5): cashF.add_value(60 * p, INT_MAX, 30000) for task in all_tasks: itv = msol.get_var_solution(task) workersF.add_value(itv.get_start(), itv.get_end(), 1) cashF.add_value(itv.start, INT_MAX, -200 * desc[task].duration) visu.timeline('Solution SchedCumul') visu.panel(name="Schedule") for task in all_tasks: visu.interval(msol.get_var_solution(task), house[task], compact(task.get_name())) visu.panel(name="Workers") visu.function(segments=workersF, style='area') visu.panel(name="Cash") visu.function(segments=cashF, style='area', color='gold') visu.show()
print("Solution: ") msol.print_solution() ############################################################################## # Display result ############################################################################## def compact(name): # Example: H3-garden -> G3 # ^ ^ loc, task = name[1:].split('-', 1) return task[0].upper() + loc if msol and visu.is_visu_enabled(): workers_function = CpoStepFunction() for v in all_tasks: itv = msol.get_var_solution(v) workers_function.add_value(itv.get_start(), itv.get_end(), 1) visu.timeline('Solution SchedState') visu.panel(name="Schedule") for v in all_tasks: visu.interval(msol.get_var_solution(v), house[v], compact(v.get_name())) visu.panel(name="Houses state") for f in all_state_functions: visu.sequence(name=f.get_name(), segments=msol.get_var_solution(f)) visu.panel(name="Nb of workers") visu.function(segments=workers_function, style='line') visu.show()
############################################################################## # Display result ############################################################################## def compact(name): # Example: H3-garden -> G3 # ^ ^ loc, task = name[1:].split('-', 1) return task[0].upper() + loc if msol and visu.is_visu_enabled(): workers_function = CpoStepFunction() for v in all_tasks: itv = msol.get_var_solution(v) workers_function.add_value(itv.get_start(), itv.get_end(), 1) visu.timeline('Solution SchedState') visu.panel(name="Schedule") for v in all_tasks: visu.interval(msol.get_var_solution(v), house[v], compact(v.get_name())) visu.panel(name="Houses state") for f in all_state_functions: visu.sequence(name=f.get_name(), segments=msol.get_var_solution(f)) visu.panel(name="Nb of workers") visu.function(segments=workers_function, style='line') visu.show()
print("Solution: ") msol.print_solution() ############################################################################## # Display result ############################################################################## if msol and visu.is_visu_enabled(): visu.timeline("Solution SchedTime", origin=10, horizon=120) visu.panel("Schedule") for t in ALL_TASKS: visu.interval(msol.get_var_solution(tasks[t.id]), t.id, t.name) for t in ALL_TASKS: if t.release_date is not None: visu.panel('Earliness') itvsol = msol.get_var_solution(tasks[t.id]) cost = fearliness[t].get_value(itvsol.get_start()) visu.function(segments=[(itvsol, cost, t.name)], color=t.id, style='interval') visu.function(segments=fearliness[t], color=t.id) if t.due_date is not None: visu.panel('Tardiness') itvsol = msol.get_var_solution(tasks[t.id]) cost = ftardiness[t].get_value(itvsol.get_end()) visu.function(segments=[(itvsol, cost, t.name)], color=t.id, style='interval') visu.function(segments=ftardiness[t], color=t.id) visu.show()