Cream version 1.06 Core API Specification

jp.ac.kobe_u.cs.cream
Class LocalSearch

java.lang.Object
  extended by jp.ac.kobe_u.cs.cream.Solver
      extended by jp.ac.kobe_u.cs.cream.LocalSearch
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
IBBSearch, SASearch, TabooSearch

public class LocalSearch
extends Solver

A super class of local search solvers, and also an implementation of a random walk solver. Local search is an iterative procedure. It first finds an initial solution, and iteratively make a small change. Only useful for the optimization problems containing Serialized constraints in the current implementation. The default exchangeRate value for ParallelSolver is 0.05. *

Since:
1.0
See Also:
Code, Serialized

Field Summary
 long initialTimeout
          Timeout in milli seconds to find an initial solution for the local search.
 long iterationTimeout
          Timeout in milli seconds to find the next solution in the iteration.
 DefaultSolver solver
          Sub-solver used to find the initial solution and the next solution.
 
Fields inherited from class jp.ac.kobe_u.cs.cream.Solver
BETTER, DEFAULT, MAXIMIZE, MINIMIZE, NONE
 
Constructor Summary
LocalSearch(Network network)
          Constructs a random-walk solver for the given network.
LocalSearch(Network network, int option)
          Constructs a random-walk solver for the given network and option.
LocalSearch(Network network, int option, String name)
          Constructs a random-walk solver for the given network, option, and name.
LocalSearch(Network network, String name)
          Constructs a random-walk solver for the given network and name.
 
Method Summary
 void endSearch()
          End of the iteration.
 Solution getCandidate()
          Returns the candidate solution for the next iteration.
 double getExchangeRate()
          Returns the solution exchange rate for ParallelSolver.
 int getIterations()
          Returns the iterations count.
 void nextSearch()
          Finds the next solution.
 void run()
          The body of the solver.
 void setCandidate(Solution candidate)
          Sets a candidate solution for the next iteration.
 void setExchangeRate(double exchangeRate)
          Sets the solution exchange rate used for ParallelSolver.
 void startSearch()
          Finds the initial solution.
 void stop()
          Stops the execution of the solver.
 
Methods inherited from class jp.ac.kobe_u.cs.cream.Solver
clearBest, findAll, findAll, findBest, findBest, findFirst, findFirst, getBestSolution, getBestValue, getCount, getElapsedTime, getID, getMonitor, getOption, getSolution, isAborted, join, resetIDCounter, resume, setMonitor, start, start, start, start, toString, waitNext, waitNext
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

initialTimeout

public long initialTimeout
Timeout in milli seconds to find an initial solution for the local search. The initial solution is searched by the Solver.findFirst(long) method. The default value is 0 (no timeout).


iterationTimeout

public long iterationTimeout
Timeout in milli seconds to find the next solution in the iteration. The next solution is searched by the Solver.findBest(long) method. The default value is 5000 (5 seconds).


solver

public DefaultSolver solver
Sub-solver used to find the initial solution and the next solution.

Constructor Detail

LocalSearch

public LocalSearch(Network network)
Constructs a random-walk solver for the given network. This constructor is equivalent to LocalSearch(network, DEFAULT, null).

Parameters:
network - the constraint network

LocalSearch

public LocalSearch(Network network,
                   int option)
Constructs a random-walk solver for the given network and option. This constructor is equivalent to LocalSearch(network, option, null).

Parameters:
network - the constraint network
option - the option for search strategy

LocalSearch

public LocalSearch(Network network,
                   String name)
Constructs a random-walk solver for the given network and name. This constructor is equivalent to LocalSearch(network, DEFAULT, name).

Parameters:
network - the constraint network
name - the name of the solver

LocalSearch

public LocalSearch(Network network,
                   int option,
                   String name)
Constructs a random-walk solver for the given network, option, and name.

Parameters:
network - the constraint network
option - the option for search strategy, or DEFAULT for default search strategy
name - the name of the solver, or null for a default name
Method Detail

getIterations

public int getIterations()
Returns the iterations count.

Returns:
the iterations count

getCandidate

public Solution getCandidate()
Returns the candidate solution for the next iteration.

Returns:
the candidate solution or null

setCandidate

public void setCandidate(Solution candidate)
Sets a candidate solution for the next iteration.

Parameters:
candidate - the candidate

getExchangeRate

public double getExchangeRate()
Returns the solution exchange rate for ParallelSolver.

Returns:
the exchange rate

setExchangeRate

public void setExchangeRate(double exchangeRate)
Sets the solution exchange rate used for ParallelSolver.

Parameters:
exchangeRate - the exchange rate to set

stop

public void stop()
Description copied from class: Solver
Stops the execution of the solver.

Overrides:
stop in class Solver

startSearch

public void startSearch()
Finds the initial solution.


nextSearch

public void nextSearch()
Finds the next solution.


endSearch

public void endSearch()
End of the iteration.


run

public void run()
Description copied from class: Solver
The body of the solver. This method is called from Solver.start() methods.

Specified by:
run in interface Runnable
Specified by:
run in class Solver

Cream version 1.06 Core API Specification

Cream: Constraint Programming Class Library for Java