-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New solvers based on dynamic programming and the didppy library #321
Conversation
g-poveda
commented
Oct 10, 2024
- create a generic solver class with Did library aligned with our existing one
- create base model for jsp, fjsp, facility, coloring, mis, rcpsp, tsp, vrp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that some changes should be put in another PR (it seems they do not have a relation with dynamic programming).
It would be nice to test the callback use at least in one of the did solvers to check this is working as intended (logging, stopping, crashing if callback raise an error).
@@ -0,0 +1,3 @@ | |||
# Copyright (c) 2024 AIRBUS and its affiliates. | |||
# This source code is licensed under the MIT license found in the | |||
# LICENSE file in the root directory of this source tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -79,6 +83,7 @@ def adding_constraint_from_results_store( | |||
# constraints.append(solver.cp_model.Add(solver.variables["ends"][k] <= end+20)) | |||
# constraints.append(solver.cp_model.Add(solver.variables["ends"][k] >= end-20)) | |||
solver.cp_model.Minimize(solver.variables["makespan"]) | |||
solver.set_warm_start(sol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -114,4 +119,5 @@ def adding_constraint_from_results_store( | |||
# m = solver.cp_model.NewIntVar(lb=0, ub=makespan, name="") | |||
# solver.cp_model.AddMaxEquality(m, [solver.variables["ends"][k] for k in keys_part]) | |||
# solver.cp_model.Minimize(m) #+sum([solver.variables["ends"][k] for k in keys_part])) | |||
solver.set_warm_start(sol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -148,7 +148,7 @@ def evaluate(self, variable: FacilitySolution) -> dict[str, float]: # type: ign | |||
d = self.evaluate_cost(variable) | |||
capacity_constraint_violation = 0 | |||
for f in d["details"]: | |||
capacity_constraint_violation = max( | |||
capacity_constraint_violation += max( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -56,7 +56,7 @@ class LocalSearchMetaheuristic(Enum): | |||
class BasicRoutingMonitor: | |||
def __init__(self, do_solver: "VrpORToolsSolver"): | |||
self.model = do_solver.routing | |||
self.problem = do_solver.vrp_model | |||
self.problem = do_solver.problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -169,7 +169,7 @@ def retrieve(self, solution: pywrapcp.Assignment) -> VrpSolution: | |||
vehicle_tours_all[-1] += [self.manager.IndexToNode(index)] | |||
logger.debug(f"Route distance : {route_distance}") | |||
logger.debug(f"Vehicle tours : {vehicle_tours}") | |||
logger.debug(f"Objective : {objective}") | |||
logger.info(f"Objective : {objective}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
step_verbosity_level=logging.INFO, end_verbosity_level=logging.INFO | ||
) | ||
], | ||
time_limit=5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -39,7 +42,7 @@ def run_cpsat_coloring(): | |||
p = ParametersCP.default_cpsat() | |||
logging.info("Starting solve") | |||
result_store = solver.solve( | |||
callbacks=[NbIterationTracker(step_verbosity_level=logging.INFO)], | |||
callbacks=[ObjectiveLogger(step_verbosity_level=logging.INFO)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
@@ -13,7 +13,7 @@ | |||
|
|||
|
|||
def run_cpsat_knapsack(): | |||
file = [f for f in get_data_available() if "ks_1000_0" in f][0] | |||
file = [f for f in get_data_available() if "ks_10000_0" in f][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
examples/vrp/vrp_solver_example.py
Outdated
@@ -26,7 +30,11 @@ def run_ortools_vrp_solver(): | |||
first_solution_strategy=FirstSolutionStrategy.SAVINGS, | |||
local_search_metaheuristic=LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH, | |||
) | |||
res = solver.solve(time_limit_seconds=20) | |||
res = solver.solve( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in the PR ?
aea5bc7
to
a53f28c
Compare
-adding didppy models available for many DO problems -implemented examples, tests for each implemented problem
a53f28c
to
e4e676f
Compare