Java Reference

Java Reference

SearchMonitor.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 4.0.1
4  *
5  * Do not make changes to this file unless you know what you are doing--modify
6  * the SWIG interface file instead.
7  * ----------------------------------------------------------------------------- */
8 
9 package com.google.ortools.constraintsolver;
10 
14 public class SearchMonitor extends BaseObject {
15  private transient long swigCPtr;
16 
17  protected SearchMonitor(long cPtr, boolean cMemoryOwn) {
18  super(mainJNI.SearchMonitor_SWIGUpcast(cPtr), cMemoryOwn);
19  swigCPtr = cPtr;
20  }
21 
22  protected static long getCPtr(SearchMonitor obj) {
23  return (obj == null) ? 0 : obj.swigCPtr;
24  }
25 
26  @SuppressWarnings("deprecation")
27  protected void finalize() {
28  delete();
29  }
30 
31  public synchronized void delete() {
32  if (swigCPtr != 0) {
33  if (swigCMemOwn) {
34  swigCMemOwn = false;
35  mainJNI.delete_SearchMonitor(swigCPtr);
36  }
37  swigCPtr = 0;
38  }
39  super.delete();
40  }
41 
42  protected void swigDirectorDisconnect() {
43  swigCMemOwn = false;
44  delete();
45  }
46 
47  public void swigReleaseOwnership() {
48  swigCMemOwn = false;
49  mainJNI.SearchMonitor_change_ownership(this, swigCPtr, false);
50  }
51 
52  public void swigTakeOwnership() {
53  swigCMemOwn = true;
54  mainJNI.SearchMonitor_change_ownership(this, swigCPtr, true);
55  }
56 
58 
59  public SearchMonitor(Solver s) {
60  this(mainJNI.new_SearchMonitor(Solver.getCPtr(s), s), true);
61  mainJNI.SearchMonitor_director_connect(this, swigCPtr, true, true);
62  }
63 
67  public void enterSearch() {
68  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_enterSearch(swigCPtr, this); else mainJNI.SearchMonitor_enterSearchSwigExplicitSearchMonitor(swigCPtr, this);
69  }
70 
74  public void restartSearch() {
75  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_restartSearch(swigCPtr, this); else mainJNI.SearchMonitor_restartSearchSwigExplicitSearchMonitor(swigCPtr, this);
76  }
77 
81  public void exitSearch() {
82  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_exitSearch(swigCPtr, this); else mainJNI.SearchMonitor_exitSearchSwigExplicitSearchMonitor(swigCPtr, this);
83  }
84 
89  try {
90  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_beginNextDecision(swigCPtr, this, DecisionBuilder.getCPtr(b), b); else mainJNI.SearchMonitor_beginNextDecisionSwigExplicitSearchMonitor(swigCPtr, this, DecisionBuilder.getCPtr(b), b);
91  } finally {
93  }
94  }
95 
100  try {
101  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_endNextDecision(swigCPtr, this, DecisionBuilder.getCPtr(b), b, Decision.getCPtr(d), d); else mainJNI.SearchMonitor_endNextDecisionSwigExplicitSearchMonitor(swigCPtr, this, DecisionBuilder.getCPtr(b), b, Decision.getCPtr(d), d);
102  } finally {
104  }
105  }
106 
110  public void applyDecision(Decision d) {
111  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_applyDecision(swigCPtr, this, Decision.getCPtr(d), d); else mainJNI.SearchMonitor_applyDecisionSwigExplicitSearchMonitor(swigCPtr, this, Decision.getCPtr(d), d);
112  }
113 
117  public void refuteDecision(Decision d) {
118  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_refuteDecision(swigCPtr, this, Decision.getCPtr(d), d); else mainJNI.SearchMonitor_refuteDecisionSwigExplicitSearchMonitor(swigCPtr, this, Decision.getCPtr(d), d);
119  }
120 
124  public void afterDecision(Decision d, boolean apply) {
125  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_afterDecision(swigCPtr, this, Decision.getCPtr(d), d, apply); else mainJNI.SearchMonitor_afterDecisionSwigExplicitSearchMonitor(swigCPtr, this, Decision.getCPtr(d), d, apply);
126  }
127 
131  public void beginFail() {
132  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_beginFail(swigCPtr, this); else mainJNI.SearchMonitor_beginFailSwigExplicitSearchMonitor(swigCPtr, this);
133  }
134 
138  public void endFail() {
139  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_endFail(swigCPtr, this); else mainJNI.SearchMonitor_endFailSwigExplicitSearchMonitor(swigCPtr, this);
140  }
141 
145  public void beginInitialPropagation() {
146  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_beginInitialPropagation(swigCPtr, this); else mainJNI.SearchMonitor_beginInitialPropagationSwigExplicitSearchMonitor(swigCPtr, this);
147  }
148 
152  public void endInitialPropagation() {
153  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_endInitialPropagation(swigCPtr, this); else mainJNI.SearchMonitor_endInitialPropagationSwigExplicitSearchMonitor(swigCPtr, this);
154  }
155 
159  public boolean acceptSolution() {
160  return (getClass() == SearchMonitor.class) ? mainJNI.SearchMonitor_acceptSolution(swigCPtr, this) : mainJNI.SearchMonitor_acceptSolutionSwigExplicitSearchMonitor(swigCPtr, this);
161  }
162 
166  public boolean atSolution() {
167  return (getClass() == SearchMonitor.class) ? mainJNI.SearchMonitor_atSolution(swigCPtr, this) : mainJNI.SearchMonitor_atSolutionSwigExplicitSearchMonitor(swigCPtr, this);
168  }
169 
173  public void noMoreSolutions() {
174  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_noMoreSolutions(swigCPtr, this); else mainJNI.SearchMonitor_noMoreSolutionsSwigExplicitSearchMonitor(swigCPtr, this);
175  }
176 
180  public boolean localOptimum() {
181  return (getClass() == SearchMonitor.class) ? mainJNI.SearchMonitor_localOptimum(swigCPtr, this) : mainJNI.SearchMonitor_localOptimumSwigExplicitSearchMonitor(swigCPtr, this);
182  }
183 
184  public boolean acceptDelta(Assignment delta, Assignment deltadelta) {
185  return (getClass() == SearchMonitor.class) ? mainJNI.SearchMonitor_acceptDelta(swigCPtr, this, Assignment.getCPtr(delta), delta, Assignment.getCPtr(deltadelta), deltadelta) : mainJNI.SearchMonitor_acceptDeltaSwigExplicitSearchMonitor(swigCPtr, this, Assignment.getCPtr(delta), delta, Assignment.getCPtr(deltadelta), deltadelta);
186  }
187 
191  public void acceptNeighbor() {
192  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_acceptNeighbor(swigCPtr, this); else mainJNI.SearchMonitor_acceptNeighborSwigExplicitSearchMonitor(swigCPtr, this);
193  }
194 
198  public void AcceptUncheckedNeighbor() {
199  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_AcceptUncheckedNeighbor(swigCPtr, this); else mainJNI.SearchMonitor_AcceptUncheckedNeighborSwigExplicitSearchMonitor(swigCPtr, this);
200  }
201 
206  return (getClass() == SearchMonitor.class) ? mainJNI.SearchMonitor_IsUncheckedSolutionLimitReached(swigCPtr, this) : mainJNI.SearchMonitor_IsUncheckedSolutionLimitReachedSwigExplicitSearchMonitor(swigCPtr, this);
207  }
208 
209  public Solver solver() {
210  long cPtr = mainJNI.SearchMonitor_solver(swigCPtr, this);
211  return (cPtr == 0) ? null : new Solver(cPtr, false);
212  }
213 
217  public void periodicCheck() {
218  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_periodicCheck(swigCPtr, this); else mainJNI.SearchMonitor_periodicCheckSwigExplicitSearchMonitor(swigCPtr, this);
219  }
220 
224  public int progressPercent() {
225  return (getClass() == SearchMonitor.class) ? mainJNI.SearchMonitor_progressPercent(swigCPtr, this) : mainJNI.SearchMonitor_progressPercentSwigExplicitSearchMonitor(swigCPtr, this);
226  }
227 
231  public void accept(ModelVisitor visitor) {
232  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_accept(swigCPtr, this, ModelVisitor.getCPtr(visitor), visitor); else mainJNI.SearchMonitor_acceptSwigExplicitSearchMonitor(swigCPtr, this, ModelVisitor.getCPtr(visitor), visitor);
233  }
234 
238  public void install() {
239  if (getClass() == SearchMonitor.class) mainJNI.SearchMonitor_install(swigCPtr, this); else mainJNI.SearchMonitor_installSwigExplicitSearchMonitor(swigCPtr, this);
240  }
241 
242  public final static int kNoProgress = mainJNI.SearchMonitor_kNoProgress_get();
243 }
int progressPercent()
Returns a percentage representing the propress of the search before reaching limits.
Solver Class A solver represents the main computation engine.
Definition: Solver.java:60
A BaseObject is the root of all reversibly allocated objects.
Definition: BaseObject.java:14
A Decision represents a choice point in the search tree.
Definition: Decision.java:14
void AcceptUncheckedNeighbor()
After accepting an unchecked neighbor during local search.
void noMoreSolutions()
When the search tree is finished.
void accept(ModelVisitor visitor)
Accepts the given model visitor.
void install()
Registers itself on the solver such that it gets notified of the search and propagation events.
void beginFail()
Just when the failure occurs.
void afterDecision(Decision d, boolean apply)
Just after refuting or applying the decision, apply is true after Apply.
void endInitialPropagation()
After the initial propagation.
A search monitor is a simple set of callbacks to monitor all search events.
void beginNextDecision(DecisionBuilder b)
Before calling DecisionBuilder::Next.
void endNextDecision(DecisionBuilder b, Decision d)
After calling DecisionBuilder::Next, along with the returned decision.
A DecisionBuilder is responsible for creating the search tree.
void endFail()
After completing the backtrack.
void periodicCheck()
Periodic call to check limits in long running methods.
boolean localOptimum()
When a local optimum is reached.
boolean acceptDelta(Assignment delta, Assignment deltadelta)
void beginInitialPropagation()
Before the initial propagation.
void acceptNeighbor()
After accepting a neighbor during local search.
An Assignment is a variable -> domains mapping, used to report solutions to the user.
Definition: Assignment.java:14
boolean atSolution()
This method is called when a valid solution is found.
boolean IsUncheckedSolutionLimitReached()
Returns true if the limit of solutions has been reached including unchecked solutions.
void applyDecision(Decision d)
Before applying the decision.
SearchMonitor(long cPtr, boolean cMemoryOwn)
void refuteDecision(Decision d)
Before refuting the decision.
boolean acceptSolution()
This method is called when a solution is found.