-
Notifications
You must be signed in to change notification settings - Fork 140
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
Dev restart #950
Dev restart #950
Conversation
…d in Solver In consequence, it is easy to set/clear the restart policy.
|
solver/src/main/java/org/chocosolver/solver/search/loop/move/IMoveFactory.java
Show resolved
Hide resolved
solver/src/main/java/org/chocosolver/solver/search/loop/move/IMoveFactory.java
Outdated
Show resolved
Hide resolved
|
||
public void setNext(AbstractRestart restart) { | ||
throw new UnsupportedOperationException("Cannot set next on this instance"); | ||
} |
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.
Why not putting the nextrestart variable in the abstract class?
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.
You're right.
Well, that was because NO_RESTART
singleton must not declare next
, but I can manage that differently.
solver/src/main/java/org/chocosolver/solver/search/restart/Restarter.java
Outdated
Show resolved
Hide resolved
* @author Charles Prud'homme | ||
* @since 03/09/2015 | ||
*/ | ||
public final class Restarter extends AbstractRestart { |
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.
Is there a benefit from declaring this class final?
* Indicates if this strategy is learn-based may, for instance, require to be coupled with a restart strategy. | ||
* @return <i>true</i> if this strategy is dynamic. | ||
*/ | ||
public abstract boolean isDynamic(); |
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 find the concept of dynamic search quite vague and possibly confusing.
If it is really about restarts i would suggest a more explicit name, like isImprovedByRestarts.
However, i am not 100% convinced by the idea of this feature, because it often depends on the problem.
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.
Indeed, the choice of the term and the concept it encapsulates are debatable.
However, it happens quite often (and this is notably the case of the default strategy 🤦) that the strategy/restarts couple is unsuitable.
However, this can be the subject of another RP with a more in-depth discussion.
@@ -104,6 +104,11 @@ public boolean init() { | |||
return mainStrategy.init(); | |||
} | |||
|
|||
@Override | |||
public boolean isDynamic() { | |||
return true; |
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.
For instance here it is not so clear to me that we should recommend restarts
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 agree, I asked myself the same question and made the choice that seemed most logical.
Hi, I find the refactoring of the restart a very good idea, because it is indeed sometimes hard to follow. What would the code look like to restart both on solutions and every 100 fails for instance? I am just not so sure about the isDynamical function. |
solver.setLubyRestart(100, new FailCounter(target, 0), 5000);
solver.setRestartOnSolutions(); I agree that the 2nd point must be discussed (somewhere else) |
Thanks for your answers!
Before we had However, the new implementation looks like a real setter (the new Restarter will replace the previous one). |
True, that was my first intention but I didn't go through with it |
Proposal : Prop 0 (current): model.getSolver().setLubyRestart(2, new FailCounter(model, 2), 25000);
model.getSolver().setRestartOnSolutions(); Prop 1: model.getSolver().makeRestarter().luby(2).onFailure().upTo(25000).restartOnSolution(); Prop 2: model.getSolver().setLubyRestart(2, new FailCounter(model, 2), 25000, true); where I can keep Prop 0, but I think there is a side effect which allows to combine n restarts policy inadvertently (actually, I can add checks). |
This branch is dedicated to a small revamp of the way restarts are managed.
The main idea is to avoid using a
Move
implementation to deal with restarts but to integrate this directly in theSolver
object. Doing so, it becomes easier (well, doable) to remove or replace a restart policy.In addition, strategies and variable selectors are instrumented to indicate if they are dynamic, that is learn-based objects that are to be combined with restarts to be more efficient. A warning is printed to the console (if warnings are enabled) to indicate poor combinations (such as dyn. strat. without restarts).