Skip to content
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

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

g-poveda
Copy link
Collaborator

  • 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

Copy link
Contributor

@nhuet nhuet left a 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.
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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(
Copy link
Contributor

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
Copy link
Contributor

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}")
Copy link
Contributor

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,
Copy link
Contributor

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)],
Copy link
Contributor

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]
Copy link
Contributor

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 ?

@@ -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(
Copy link
Contributor

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 ?

-adding didppy models available for many DO problems
-implemented examples, tests for each implemented problem
@g-poveda g-poveda merged commit 24fa8e7 into airbus:master Oct 11, 2024
5 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants