-
Notifications
You must be signed in to change notification settings - Fork 11
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
Phase saving, restarts, and heuristic performance logs #202
base: master
Are you sure you want to change the base?
Conversation
- Assignment provides getLastValue (i.e. phase). - VSIDSWithPhaseSaving is VSIDS but uses saved phase from Assignment. - BranchingHeuristicFactory knows new VSIDSWithPhaseSaving heuristics. - HeapOfActiveAtoms polished, growForMaxAtomId added. - TrailAssignment saves the phase (last truth value) of variables.
- CommandLineParser and SystemConfig have option to enable restarts. - DefaultSolver runs restarts if enabled. - Add MixedRestartStrategy combining Luby and dynamic (EMA) restarts. - Enhanced performance logs for conflicts and restarts
- ChainedBranchingHeuristics gives access to first-run heuristics. - HeapOfActiveAtoms reports activity increment for normalization. - VSIDSWithPhaseSaving logs * the overall, normalized decrease in activity of the seelected atoms, * the number of most-active choices thrown away because they were not active choice points at the time. - PerformanceLog prints heuristics information if DefaultSolver is runnning with VSIDSWithPhaseSaving
with phase saving. - CommandLineParser and SystemConfig accept initial phase settings. - AtomChoiceRelation stores relation between ordinary atoms and the choice points that influence them. - NaiveGrounder and ProgramAnalyzingGrounder provide AtomChoiceRelation. - NoGoodGenerator fills AtomChoiceRelation. - BranchingHeuristicFactory sets AtomChoiceRelation for VSIDSWithPhaseSaving. - PhaseInitializerFactory provides different initial phase settings. - VSIDSWithPhaseSaving uses AtomChoiceRelation for activity increments. - SolverFactory sets chosen phase initializer. - TrailAssignment considers initial phase value, if phase was not set. - Tests set a phase initializer if needed.
Codecov Report
@@ Coverage Diff @@
## master #202 +/- ##
==========================================
Coverage 69.51% 69.51%
- Complexity 2092 2159 +67
==========================================
Files 182 188 +6
Lines 8006 8261 +255
Branches 1416 1443 +27
==========================================
+ Hits 5565 5743 +178
- Misses 2086 2152 +66
- Partials 355 366 +11
Continue to review full report at Codecov.
|
- In HeapOfActiveAtoms several members/methods package-private now to allow overriding. - Add HeapOfRelatedChoiceAtoms using AtomChoiceRelation to only record and initialize choice points. - Moved ChoiceManager update in DefaultSolver to correctly know which atoms are choice points. - Improved logging in VSIDSWithPhaseSaving and PerformanceLog.
- Move getAtomChoiceRelation() from NaiveGrounder to Grounder, implement method also in DummyGrounder and ChoiceGrounder. - HeapOfActiveAtoms keeps track of literals occurring in the heap. - More logging stats from VSIDSWithPhaseSaving. - ChoiceInfluenceManager: simplified callbackOnChange
# Conflicts: # src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java # src/main/java/at/ac/tuwien/kr/alpha/config/SystemConfig.java # src/main/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounder.java # src/test/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounderTest.java # src/test/java/at/ac/tuwien/kr/alpha/solver/LearnedNoGoodDeletionTest.java
…e_master Merge master into phase_saving_and_restarts
# Conflicts: # src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java
…e_master Merge master into phase_saving_and_restarts
Now #239 pops up also here. We should really fix this issue ... |
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.
Thank you for this contribution!
I have commented upon some issues that should, in my opinion, be addressed before merging.
So far I have only read the code, a second review concerned with performance will follow.
Please also address the Codecov report.
src/main/java/at/ac/tuwien/kr/alpha/grounder/ChoiceRecorder.java
Outdated
Show resolved
Hide resolved
* | ||
* Copyright (c) 2019, the Alpha Team. | ||
*/ | ||
public class HeapOfRelatedChoiceAtoms extends HeapOfActiveAtoms { |
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 this an improved version of, and thus a replacement for HeapOfActiveChoicePoints
? If yes, this fact should be documented and HeapOfActiveChoicePoints
should be deprecated or removed.
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.
The main reason for this class to exists is the initialization of variables. In HeapOfActiveAtoms
a new nogood leads to activities of literals occuring in the nogood to be updated, while here, not the literals themselves are updated, but the related choice atoms of those literals occurring in the nogood. This seems to be much more in line with the idea of having good values for choice atoms (and not the "useless" ordinary atoms).
Note that HeapOfActiveChoicePoints
works in a different direction, namely by referring to related atoms when activities are incremented. For that class, atoms are related whenever they appear in the same nogood. The VSIDSWithPhaseSaving
heuristic, however, uses the knowledge of atom relationships that it obtains from the grounder via the AtomChoiceRelation
. (I currently do however not remember whether the obtained information in both cases is the same or different. The information flow in VSIDSWithPhaseSaving
and HeapOfRelatedChoiceAtoms
seems to be more direct.)
I think, it is worthwhile to consider merging both approaches. If I recall correctly, I did not do it, because there were some differences and I did not want to change all the other heuristics we have so far without any discussion.
src/main/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGenerator.java
Outdated
Show resolved
Hide resolved
src/main/java/at/ac/tuwien/kr/alpha/grounder/ProgramAnalyzingGrounder.java
Outdated
Show resolved
Hide resolved
src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeapOfActiveAtoms.java
Outdated
Show resolved
Hide resolved
for (Integer relatedChoiceAtom : atomChoiceRelation.getRelatedChoiceAtoms(atomOf(literal))) { | ||
if (!incrementedActivityScores[relatedChoiceAtom]) { // update initial value as long as not incremented yet by VSIDS | ||
double score = moms.getScore(relatedChoiceAtom); | ||
if (score > 0.0) { |
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.
Please re-use the existing code in at.ac.tuwien.kr.alpha.solver.heuristics.HeapOfActiveAtoms#initActivityMOMs
instead of just copying it.
@@ -0,0 +1,226 @@ | |||
/** | |||
* Copyright (c) 2018-2019 Siemens AG |
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.
In my opinion, this implementation is independent from VSIDS
enough for the copyright attribution to Siemens not to be necessary.
src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/VSIDSWithPhaseSaving.java
Outdated
Show resolved
Hide resolved
src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/VSIDSWithPhaseSaving.java
Outdated
Show resolved
Hide resolved
- Extend Util.join with toString method parameter.
- Change initial phase values from strings to enum. - Add PhaseInitializer for RULESTRUEATOMSFALSE.
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.
Some more change requests.
One of them (the NullPointerException
) is critical!
.desc("enable the usage of (dynamic and static) restarts (default: " | ||
+ SystemConfig.DEFAULT_ENABLE_RESTARTS + ")") | ||
.build(); | ||
private static final Option OPT_INITIAL_PHASE = Option.builder("ph").longOpt("initialPhase").hasArg(true).argName("initializer") |
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.
Since this option is only meaningful if the VSIDS_PHASE_SAVING
heuristic is used, a warning should be issued if it is used in conjunction with any other heuristic.
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.
This is a good point and touches on a larger issue: what we would need is to check whether the whole set of given options actually makes sense. For the time being, I'll change the description so that it becomes clear that this only works for the VSIDS_WITH_PHASE_SAVING
heuristic.
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.
Added to issue #302 as a condition to check eventually.
src/main/java/at/ac/tuwien/kr/alpha/grounder/structure/AtomChoiceRelation.java
Outdated
Show resolved
Hide resolved
…default_initial_phase Use enum instead of string for default initial phase
There is a bug: #255 |
# Conflicts: # src/main/java/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriter.java # src/main/java/at/ac/tuwien/kr/alpha/Main.java # src/main/java/at/ac/tuwien/kr/alpha/api/mapper/AnswerSetToWorkbookMapper.java # src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java # src/main/java/at/ac/tuwien/kr/alpha/config/InputConfig.java # src/main/java/at/ac/tuwien/kr/alpha/config/SystemConfig.java # src/main/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounder.java # src/main/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGenerator.java # src/main/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrders.java # src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/CardinalityNormalization.java # src/test/java/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriterTest.java # src/test/java/at/ac/tuwien/kr/alpha/api/AlphaTest.java # src/test/java/at/ac/tuwien/kr/alpha/grounder/DummyGrounder.java # src/test/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounderTest.java # src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrderTest.java # src/test/java/at/ac/tuwien/kr/alpha/solver/LearnedNoGoodDeletionTest.java
…to phase_saving_and_restarts
- Introduced AbstractVSIDS, bundling code common to all VSIDS implementations. - VSIDS refactored and extends AbstractVSIDS now. - VSIDSWithPhaseSaving refactored and extends AbstractVSIDS now.
# Conflicts: # alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/config/SystemConfig.java # alpha-cli-app/src/main/java/at/ac/tuwien/kr/alpha/app/config/CommandLineParser.java # alpha-cli-app/src/test/java/at/ac/tuwien/kr/alpha/app/config/CommandLineParserTest.java # alpha-cli-app/src/test/java/at/ac/tuwien/kr/alpha/app/mappers/AnswerSetToWorkbookMapperTest.java # alpha-commons/src/main/java/at/ac/tuwien/kr/alpha/commons/literals/ComparisonLiteralImpl.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/common/NoGood.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/grounder/ChoiceRecorder.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/grounder/Grounder.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/grounder/NaiveGrounder.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/grounder/NoGoodGenerator.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/programs/structure/AtomChoiceRelation.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/DefaultSolver.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/MixedRestartStrategy.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/NaiveNoGoodStore.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/NoGoodCounter.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/PerformanceLog.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/SolverFactory.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/TrailAssignment.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/AbstractVSIDS.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/BranchingHeuristicFactory.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/ChainedBranchingHeuristics.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/HeapOfActiveAtoms.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/HeapOfRelatedChoiceAtoms.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/PhaseInitializerFactory.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/VSIDS.java # alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/heuristics/VSIDSWithPhaseSaving.java # alpha-core/src/test/java/at/ac/tuwien/kr/alpha/core/grounder/ChoiceGrounder.java # alpha-core/src/test/java/at/ac/tuwien/kr/alpha/core/grounder/DummyGrounder.java
- Extract InitialAtomPhase from PhaseInitializerFactory. - Fix missing/wrong imports.
This is a preview PR adding two standard SAT/ASP techniques.
Restarts in conjunction with the restricted guessing on applicable rules (in order to compute computation sequences as in other lazy-grounding ASP systems), however, have a negative impact on search performance. Unless further advances for lazy-grounding search to remedy that performance impact are available, this PR shall not be merged.