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

Providing Model.renewSolver() #490

Closed
2 tasks
cprudhom opened this issue Jan 10, 2017 · 14 comments
Closed
2 tasks

Providing Model.renewSolver() #490

cprudhom opened this issue Jan 10, 2017 · 14 comments
Milestone

Comments

@cprudhom
Copy link
Member

I'm considering to create in Model a method named renewSolver() that erases the current solver and replaces it by a new one.
Such a method should be helpful when Solver.reset() is not enough, for instance when dealing with search monitors, counters or explanation (that is a Learner but also an Explainer).
By creating a new solver, the model remains the same, but the way it can be solved may be adapted.

The following part should be reconsidered to avoid unexpected behavior:

  • Model.setObjective(boolean, IntVar) should not create the objective manager, but only records the parameters. Then, at initialization, the solver should create the objective manager.
  • same goes with Model.clearObjective()

There are also some restrictions to consider:

  • a solver can only be renew at root node, before running any search. This will be ensured by calling solver.reset() on the old solver before creating the new one.

Alternatively, we can consider a deepReset() in Solver, that acts as a solver renewal, but that may be confusing with current reset().
In both cases, the actions about objective should be done.

@cprudhom
Copy link
Member Author

cprudhom commented Jan 11, 2017

After discussion with @jgFages :

  • let's list references to Solver in the library and sum up what should be reset
  • update Solver.reset() instead of renewSolver() or deepReset()
  • patch objective behavior.

@cprudhom
Copy link
Member Author

Here is what calling reset() will do:

  • backtrack to rootWorldIndex
  • set searchWorldIndex to 0
  • set action to Solver.Action.initialize
  • reset bounds of objectivemanager (calling IObjectiveManager.resetBestBounds()
  • reset mMeasures
  • synchronize dpath to erase out-dated decisions, presumably all of them
  • flush engine
  • clear criteria, that forget any declared limit
  • clear searchMonitors, that forget any declared one
  • replace M by MoveBinaryDFS
  • replace P by PropagateBasic
  • replace L by LearnNothing
  • set explainer to NoExplanationEngine.SINGLETON

@cprudhom
Copy link
Member Author

I also let Model.setObjective(boolean, IntVar) and Model.clearObjective() as is, since the objective manager is now reset.

@mwahbi
Copy link
Contributor

mwahbi commented Jan 12, 2017

Hi Charles ,
What about Nogoods?

@cprudhom
Copy link
Member Author

Though question.
This has to do with the model and the solver.
My first though is to keep them, but should maybe consider differently nogoods from failure (that we should keep) and ones from solutions (that should be removed).
I would prefer to externally deal with the nogoodstore.
What is your opinion about that?
Maybe we should open a new issue

@cprudhom
Copy link
Member Author

See #491 to discuss about nogoods

@jgFages
Copy link
Contributor

jgFages commented Jan 12, 2017

Is the search strategy set back to null?

cprudhom added a commit that referenced this issue Jan 12, 2017
@mwahbi
Copy link
Contributor

mwahbi commented Jan 12, 2017

By the way, this changes on reset will require a lot of changes for me developing dischoco based on choco4. I don't know what is the case for other choco users. In order to make it easier for us maybe it would be better to make Solver extendable and its attributes protected!!

@cprudhom
Copy link
Member Author

@jgFages the move is set to a new instance of MoveBinaryDFS which automatically erase the search strategy. So the answer is yes.

@jgFages
Copy link
Contributor

jgFages commented Jan 12, 2017

thanks! Well, you have to redefined the search strategy, I believe you can redefine that you want to record nogoods...

cprudhom added a commit that referenced this issue Jan 13, 2017
@cprudhom
Copy link
Member Author

I finally made the choice of two methods instead of one:

  • reset() that preserves how the search space is explored as defined by the user (ie, search strategy, move, learn and propagate are untouched) but backtracks to root node, reset measures, erases feasibility status, resets bounds of objective manager and forgets limits.
  • and hardReset() that calls reset() and then erases move, search strategy, learn, propagate and search monitors.

The former restores the solver as before running the last resolution call, the latter restores the solver as after its creation.
reset() has an impact on internal variables that cannot be modified thanks to setters, but that's not the case for hardReset(), so mid-level reset can be defined by the user.

@cprudhom cprudhom modified the milestone: 4.0.2 Jan 20, 2017
@marquessbr
Copy link

marquessbr commented Feb 1, 2017

Hi
I want to make a crossword game, so, I got the crossword example and when I try to compile I got a error in the call "solver.post(IntConstraintFactory.alldifferent(E, "BC"));" line, so, How is the equivalent command in the 4.0.2 version?

thanks!

here is my gradle (android studio) output:
Information:Gradle: Executing tasks: [:app:assembleDebug]
Information:Module "app" was fully rebuilt due to project configuration/dependencies changes
Information:01/02/17 22:02 - Compilation completed with 12 errors and 0 warnings in 20s 885ms
Error:Gradle: Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.
/home/armando/IdeaProjects/PalavrasCruzadas/app/src/main/java/com/debug/palavrascruzadas/CrossWord.java
Error:(151, 8) Gradle: error: cannot find symbol method post(Constraint)
Error:(155, 10) Gradle: error: cannot find symbol method post(Constraint)
Error:(170, 17) Gradle: error: boolean cannot be dereferenced
Error:(172, 9) Gradle: error: cannot find symbol method post(Constraint)
Error:(173, 9) Gradle: error: cannot find symbol method post(Constraint)
Error:(177, 9) Gradle: error: cannot find symbol method post(Constraint)
Error:(179, 9) Gradle: error: cannot find symbol method post(Constraint)
Error:(180, 9) Gradle: error: cannot find symbol method post(Constraint)
Error:(188, 22) Gradle: error: incompatible types: String cannot be converted to Model
Error:(193, 31) Gradle: error: cannot find symbol method inputOrder_InDomainMin(IntVar[])
Error:(220, 18) Gradle: error: cannot find symbol method nextSolution()

@cprudhom
Copy link
Member Author

cprudhom commented Feb 2, 2017

Hi marquessbr,

Please use the google groups and not an unrelated closed issue to post that kind of questions.

Best,
CP

@marquessbr
Copy link

Hi, thanks, @cprudhom!
Ok

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

No branches or pull requests

4 participants