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

Add a solver characteristic for solvers implementing solve_from() #320

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

nhuet
Copy link
Contributor

@nhuet nhuet commented Apr 2, 2024

The new characteristic, the generic (default) version and its optional specific declination are:

  • generic characteristic: FromInitState
  • specific characteristic: FromAnyState:
    • the solver have a solve_from() method
    • solve() use it by default to solve from initial state (if domain is initializable else raise a ValueError if not implemented)
    • solve() (and _solve) gets also an optional argument from_memory to solve from another state (and call solve_from accordingly)

Consequences:

  • add from_memory arg in Domain.solve_with()
  • Solver inherits from FromInitState (to have solve() and _solve() in its
    api)
  • FromAnyState inherits from FromInitState and overrides solve() and _solve()
  • init_solve() added to FromAnyState to be called in _solve(), to ensure solve_from() will already have the domain (and for instance the underlying c++ solver) initialized when called from _solve.

Minor modifications to avoid circular imports

  • We import Domain for annotations only when type checking
  • We use a dedicated logger in parallel_domains.py to avoid havind to import domains

We adapt all solvers to this new api:

  • for solvers already implementing solve_from():
    • derive from FromAnyState
    • remove _solve implementation (already in FromAnyState)
  • for LazyAstar and LRTAstar:
    • remove attribute self._from_state
    • derive from FromAnyState
    • implement _init_solve() to init self._domain
    • convert _solve into _solve_from
  • for MAHD:
    • derive FromAnyState, but raises an error if chosen solver cannot do it
  • for other solvers: nothing changes.

@nhuet nhuet marked this pull request as draft April 2, 2024 15:07
@nhuet nhuet force-pushed the solve-from branch 2 times, most recently from fb0ed38 to d9ea071 Compare April 11, 2024 13:19
@nhuet nhuet marked this pull request as ready for review April 11, 2024 13:19
- generic characteristic: FromInitState
- specific characteristic: FromAnyState:
   - the solver have a solve_from() method
   - solve() use it by default to solve from initial state (if
    domain is initializable else raise a ValueError if not implemented)
   - solve() (and _solve) gets also an optional argument from_memory to solve from
     another state (and call solve_from accordingly)

Consequences:
- add from_memory arg in Domain.solve_with()
- Solver inherits from FromInitState (to have solve() and _solve() in its
  api)
- FromAnyState inherits from FromInitState and overrides solve() and _solve()
- init_solve() added to FromAnyState to be called in _solve(), to ensure
  solve_from() will already have the domain (and for instance the
  underlying c++ solver) initialized when called from _solve.

Minor modifications to avoid circular imports
- We import Domain for annotations only when type checking
- We use a dedicated logger in parallel_domains.py to avoid havind to
  import domains
- for solvers implementing solve_from():
  - derive from FromAnyState
  - remove _solve implementation (already in FromAnyState)
- for LazyAstar and LRTAstar:
  - remove attribute self._from_state
  - derive from FromAnyState
  - initialize self._domain in _init_solve()
  - convert _solve into _solve_from
- for MAHD:
  - derive FromAnyState, but raises an error if chosen solver cannot do
    it
- for other solvers: nothing changes.
@fteicht fteicht self-assigned this Apr 12, 2024
@fteicht fteicht added the enhancement New feature or request label Apr 12, 2024
Copy link
Collaborator

@fteicht fteicht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nhuet !

@fteicht fteicht merged commit ea0b62b into airbus:master Apr 12, 2024
43 checks passed
@nhuet nhuet deleted the solve-from branch April 15, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants