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

Pass verbose flag to solver #79

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions motile/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,20 @@ def add_constraints(self, constraints: Constraint) -> None:
for constraint in constraints.instantiate(self):
self.constraints.add(constraint)

def solve(self, timeout: float = 0.0, num_threads: int = 1) -> ilpy.Solution:
def solve(
self, timeout: float = 0.0, num_threads: int = 1, verbose: bool = False
) -> ilpy.Solution:
"""Solve the global optimization problem.

Args:
timeout:
The timeout for the ILP solver, in seconds. Default (0.0) is no
timeout. If the solver times out, the best solution encountered
so far is returned (if any has been found at all).

num_threads:
The number of threads the ILP solver uses.
verbose:
If true, print more information from ILP solver. Defaults to False.

Returns:
:class:`ilpy.Solution`, a vector of variable values. Use
Expand All @@ -142,7 +145,7 @@ def solve(self, timeout: float = 0.0, num_threads: int = 1) -> ilpy.Solution:
if timeout > 0:
self.ilp_solver.set_timeout(timeout)

self.ilp_solver.set_verbose(False)
self.ilp_solver.set_verbose(verbose)

self.solution = self.ilp_solver.solve()
if message := self.solution.get_status():
Expand Down