-
Notifications
You must be signed in to change notification settings - Fork 7
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
Improve API ergonomics #82
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some more To-dos for this:
|
Introduces: - `SatInstance::var_manager_ref()` - `SatInstance::var_manager_mut()` - `SatInstance::n_vars()` - `OptInstance::constraints_ref()` - `OptInstance::constraints_mut()` - `OptInstance::objective_ref()` - `OptInstance::objective_mut()` - `MultiOptInstance::constraints_ref()` - `MultiOptInstance::constraints_mut()` - `MultiOptInstance::objective_ref()` - `MultiOptInstance::objective_mut()` Deprecates: - `SatInstance::var_manager()` - `OptInstance::get_constraints()` - `OptInstance::get_objective()` - `MultiOptInstance::get_constraints()` - `MultiOptInstance::get_objective()`
Make `to_opb` and similar opb writing functions take by reference instead of by value. Some still need to take mutable references, provide workarounds in documentation if additional guarantees are known.
Make `to_dimacs` and similar dimacs writing functions take by reference instead of by value. For the high-level instance types mutable references are still needed; provide `Cnf::to_dimacs` and workarounds in documentation if additional guarantees are known.
Since external libraries cannot easily take ownership anyway, for most solvers this is more reasonable. Add a default implementation for `add_clause` that can be overwritten for solvers that can truly take ownership.
f5921f4
to
f812aec
Compare
- rename file writing methods `write_` rather than `to_` - make all file writing methods take references and return errors if not in right format - rename all heavy converters `into_` - rename all inplace converters `convert_to_`
in tests and two methods of `Objective` type
0634ad4
to
af9d3fc
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #81
add_clause_ref
andadd_cnf_ref
toSolve
traitwrite_
and make them take by reference. If they require the instance to be in a certain format, they will return an error if this is not the case._ref
and_mut
accessor methods to instance types and deprecate older accessors.write_dimacs
toCnf
n_vars
toSatInstance
add_nary
toSatInstance
andCnf
into_
and all inplace converters toconvert_to_