-
Notifications
You must be signed in to change notification settings - Fork 25
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
Glasgow Constraint Solver #202
Conversation
Turns out that the transformations were called with different arguments then what they should be. I updated the docs to make it clearer what they should be. All the expression tests now pass, so it seems this would be ready to merge... I do have one request @mmcilree , can we call it 'gcs' instead of 'glassgowconstraintsolver'? |
Hi Matthew @mmcilree , We've refactored our solver interface and solver making guidelines a bit, based also on this effort, and to make it easier to debug. The two changes are that there should be a Would you be up for making those changes and testing what the current state is? Would be happy to see it progres... (and we have a summerschool 2nd week of july, could be nice for participants to also have gcs available) |
# Conflicts: # .gitignore # tests/test_constraints.py
I can't seem to install gcspy, did anyone else recently try? |
Hi @Wout4 the gcspy package is very out of date with respect to the Glasgow constraint solver - lots of the solver API has changed since I wrote the python bindings. It's on my todo list to update it and make sure it all works correctly, I'll try to get to it possibly next week. |
# Conflicts: # .github/workflows/python-test.yml # tests/test_constraints.py
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.
code review, only minor comments
then indeed you need the bool() part for Boolean variables
…On 11/07/2024 16:18, Matthew J McIlree wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In cpmpy/solvers/gcs.py
<#202 (comment)>:
> + self.cpm_status.exitstatus = ExitStatus.FEASIBLE
+ else:
+ self.cpm_status.exitstatus = ExitStatus.UNSATISFIABLE
+
+ # True/False depending on self.cpm_status
+ has_sol = self._solve_return(self.cpm_status)
+
+ # translate solution values (of user specified variables only)
+ self.objective_value_ = None
+ if has_sol:
+ # fill in variable values
+ for cpm_var in self.user_vars:
+ sol_var = self.solver_var(cpm_var)
+ if isinstance(cpm_var, _BoolVarImpl):
+ # Convert back to bool
+ cpm_var._value = bool(self.gcs.get_solution_value(sol_var))
I'm not sure about this one. What do you mean by well-type? GCS always
returns integers for solution values, so I thought I'd need to convert
0-1 back to False/True for boolvars.
—
Reply to this email directly, view it on GitHub
<#202 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABKCNGAFZBSV263CWBRBSDZL2H35AVCNFSM6AAAAABKLFFWK6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNZSGA2DCNJTGE>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#202 (comment)", "url":
"#202 (comment)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub",
"url": "https://github.com" } } ]
|
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'm having some trouble adding an objective to a model:
e.g.
a = boolvar()
m = Model(a == 1)
m.minimize(a).
m.solve('gcs')
This crashes..
Other than that test are successful.
tests/test_constraints.py
Outdated
@@ -11,6 +11,7 @@ | |||
# make sure that `SolverLookup.get(solver)` works | |||
# also add exclusions to the 3 EXCLUDE_* below as needed | |||
SOLVERNAMES = [name for name, solver in SolverLookup.base_solvers() if solver.supported()] | |||
SOLVERNAMES = ['ortools'] |
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.
we should remove this before merging
"alldifferent", | ||
"element", | ||
'table', | ||
'negative_table', |
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.
so I guess we could add short_table here ?
elif cpm_expr.name == 'negative_table': | ||
self.gcs.post_negative_table(self.solver_vars(cpm_expr.args[0]), cpm_expr.args[1]) | ||
elif isinstance(cpm_expr, GlobalConstraint): | ||
# GCS also has SmartTable, Regular Language Membership, Knapsack constraints |
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.
cpmpy's ShortTable is SmartTable
I couldn't find smart table in the gcs python interface, could be nice to add still. Other than that seems ready to merge! |
Some test fail due to pycroptosat not being installed, will merge this anyway as that does not seem to happen on master |
Matthew's GCS solver interface
Unfinished: multiple constraint tests failing