C# 클래스 Cream.Solver

An abstract class for constraint solvers. A solver is constructed with a {@linkplain Network constraint network} which is used by the solver to find solutions. Please note that any network can not be simultaneously shared by two different solvers. Solvers can be used in three typical ways. As a subroutine: {@link #FindFirst()}, {@link #FindBest()}, etc.
Solution solution = solver.FindFirst();
As a handler caller: {@link #FindAll(ISolutionHandler handler)}, etc.
solver.FindAll(new ISolutionHandler() { public synchronized void Solved(Solver solver, Solution solution) { ..... } });
As a coroutine: {@link #Start()}, {@link #WaitNext()}, {@link #Resume()}, {@link #Stop()}, etc.
for (solver.Start(); solver.WaitNext(); solver.Resume()) { Solution solution = solver.getSolution(); ..... } solver.Stop();
상속: IThreadRunnable
파일 보기 프로젝트 열기: kikoanis/CSharpCream 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
bestSolution Solution
bestValue int
count long
debug bool
name String
network Cream.Network
option int
solution Solution
startTime long
totalTimeout long

공개 메소드들

메소드 설명
ClearBest ( ) : void

Clears the best solution this solver has been found.

FindAll ( ISolutionHandler handler ) : void

Invokes the handler for each solution. This method is equivalent to {@link #FindAll(ISolutionHandler, long) FindFirst(handler, 0)}.

FindAll ( ISolutionHandler handler, long timeout ) : void

Invokes the handler for each solution with the timeout. This method is implemented as follows:

 ClearBest(); Start(handler, timeout); Join(); 

FindBest ( ) : Solution

Finds the best solution. This method is equivalent to {@link #FindBest(long) FindBest(0)}.

FindBest ( long timeout ) : Solution

Finds the best solution with the timeout. This method is implemented as follows:

 ClearBest(); for (Start(timeout); WaitNext(); Resume()) { ; } Stop(); return getBestSolution(); 

FindFirst ( ) : Solution

Finds the first solution. This method is equivalent to {@link #FindFirst(long) FindFirst(0)}.

FindFirst ( long timeout ) : Solution

Finds the first solution with the timeout. This method is implemented as follows:

 ClearBest(); Start(timeout); WaitNext(); Stop(); return getBestSolution(); 

GetCount ( ) : long
GetElapsedTime ( ) : long
GetMonitor ( ) : Monitor

Gets the monitor.

GetOption ( ) : int

Returns the option value.

Join ( ) : void

Waits until the solver ends the execution.

ResetIDCounter ( ) : void

Resets the ID counter to be 0.

Resume ( ) : void

Resumes the execution of the solver.

Run ( ) : void

The body of the solver. This method is called from {@link Solver#Start} methods.

SetMonitor ( Monitor mon ) : void

Sets the mon.

Start ( ) : void

Starts the solver in a new thread, and immediately returns to the caller. The {@link #WaitNext()} and {@link #WaitNext(long timeout)} methods can be used to wait the next solution. When a solution is found, the solver suspends the execution until the {@link #Resume()} method is called. You can Stop the solver anytime by calling the {@link #Stop()} method.

Start ( ISolutionHandler handler ) : void

Starts the solver in a new thread, and immediately returns to the caller. The handler is called for each solution and at the end of the solver execution. You can Stop the solver anytime by calling the {@link #Stop()} method.

Start ( ISolutionHandler handler, long timeout ) : void

Starts the solver in a new thread with the timeout, and immediately returns to the caller. When the timeout milliseconds have been elapsed since the Start of the solver, it stops the execution. The handler is called for each solution and at the end of the solver execution. You can Stop the solver anytime by calling the {@link #Stop()} method.

Start ( long timeout ) : void

Starts the solver in a new thread with the timeout, and immediately returns to the caller. When the timeout milliseconds have been elapsed since the Start of the solver, it stops the execution. The {@link #WaitNext()} and {@link #WaitNext(long timeout)} methods can be used to wait the next solution, or to detect the timeout. When a solution is found, the solver suspends the execution until the {@link #Resume()} method is called. You can Stop the solver anytime by calling the {@link #Stop()} method.

Stop ( ) : void

Stops the execution of the solver.

ToString ( ) : String

Returns the name of this solver.

WaitNext ( ) : bool

Waits for the next solution, or the end of the solver execution. It returns true if the next solution is available, false if the solver ends the execution.

WaitNext ( long timeout ) : bool

Waits for the next solution, or the end of the solver execution with the timeout. It returns true if the next solution is available within the timeout milliseconds, false if the solver ends the execution or the timeout milliseconds have been elapsed since the Start of this method.

보호된 메소드들

메소드 설명
Fail ( ) : void
IsBetter ( int value1, int value2 ) : bool
IsOption ( int opt ) : bool
Solver ( Cream.Network network ) : System

Constructs a solver for the given network (for invocation by subclass constructors). This constructor is equivalent to Solver(network, Default, null).

Solver ( Cream.Network network, String name ) : System

Constructs a solver for the given network and name (for invocation by subclass constructors). This constructor is equivalent to Solver(network, Default, name).

Solver ( Cream.Network network, int option ) : System

Constructs a solver for the given network and option (for invocation by subclass constructors). This constructor is equivalent to Solver(network, option, null).

Solver ( Cream.Network network, int option, String name ) : System

Constructs a solver for the given network, option, and name (for invocation by subclass constructors). When option is Default, None is used if the network has no objective variable, or else Minimize is used. Solvers and subclasses have their ID number starting from 0.

Success ( ) : void
UpdateBest ( ) : bool

메소드 상세

ClearBest() 공개 메소드

Clears the best solution this solver has been found.
public ClearBest ( ) : void
리턴 void

Fail() 보호된 메소드

protected Fail ( ) : void
리턴 void

FindAll() 공개 메소드

Invokes the handler for each solution. This method is equivalent to {@link #FindAll(ISolutionHandler, long) FindFirst(handler, 0)}.
public FindAll ( ISolutionHandler handler ) : void
handler ISolutionHandler solution handler ///
리턴 void

FindAll() 공개 메소드

Invokes the handler for each solution with the timeout. This method is implemented as follows:
 ClearBest(); Start(handler, timeout); Join(); 
public FindAll ( ISolutionHandler handler, long timeout ) : void
handler ISolutionHandler solution handler ///
timeout long timeout in milliseconds (non-positive value means no timeout) ///
리턴 void

FindBest() 공개 메소드

Finds the best solution. This method is equivalent to {@link #FindBest(long) FindBest(0)}.
public FindBest ( ) : Solution
리턴 Solution

FindBest() 공개 메소드

Finds the best solution with the timeout. This method is implemented as follows:
 ClearBest(); for (Start(timeout); WaitNext(); Resume()) { ; } Stop(); return getBestSolution(); 
public FindBest ( long timeout ) : Solution
timeout long timeout in milliseconds (non-positive value means no timeout) ///
리턴 Solution

FindFirst() 공개 메소드

Finds the first solution. This method is equivalent to {@link #FindFirst(long) FindFirst(0)}.
public FindFirst ( ) : Solution
리턴 Solution

FindFirst() 공개 메소드

Finds the first solution with the timeout. This method is implemented as follows:
 ClearBest(); Start(timeout); WaitNext(); Stop(); return getBestSolution(); 
public FindFirst ( long timeout ) : Solution
timeout long timeout in milliseconds (non-positive value means no timeout) ///
리턴 Solution

GetCount() 공개 메소드

public GetCount ( ) : long
리턴 long

GetElapsedTime() 공개 메소드

public GetElapsedTime ( ) : long
리턴 long

GetMonitor() 공개 메소드

Gets the monitor.
public GetMonitor ( ) : Monitor
리턴 Monitor

GetOption() 공개 메소드

Returns the option value.
public GetOption ( ) : int
리턴 int

IsBetter() 보호된 메소드

protected IsBetter ( int value1, int value2 ) : bool
value1 int
value2 int
리턴 bool

IsOption() 보호된 메소드

protected IsOption ( int opt ) : bool
opt int
리턴 bool

Join() 공개 메소드

Waits until the solver ends the execution.
public Join ( ) : void
리턴 void

ResetIDCounter() 공개 정적인 메소드

Resets the ID counter to be 0.
public static ResetIDCounter ( ) : void
리턴 void

Resume() 공개 메소드

Resumes the execution of the solver.
public Resume ( ) : void
리턴 void

Run() 공개 추상적인 메소드

The body of the solver. This method is called from {@link Solver#Start} methods.
public abstract Run ( ) : void
리턴 void

SetMonitor() 공개 메소드

Sets the mon.
public SetMonitor ( Monitor mon ) : void
mon Monitor monitor ///
리턴 void

Solver() 보호된 메소드

Constructs a solver for the given network (for invocation by subclass constructors). This constructor is equivalent to Solver(network, Default, null).
protected Solver ( Cream.Network network ) : System
network Cream.Network the constraint network ///
리턴 System

Solver() 보호된 메소드

Constructs a solver for the given network and name (for invocation by subclass constructors). This constructor is equivalent to Solver(network, Default, name).
protected Solver ( Cream.Network network, String name ) : System
network Cream.Network the constraint network ///
name String the name of the solver ///
리턴 System

Solver() 보호된 메소드

Constructs a solver for the given network and option (for invocation by subclass constructors). This constructor is equivalent to Solver(network, option, null).
protected Solver ( Cream.Network network, int option ) : System
network Cream.Network the constraint network ///
option int the option for search strategy ///
리턴 System

Solver() 보호된 메소드

Constructs a solver for the given network, option, and name (for invocation by subclass constructors). When option is Default, None is used if the network has no objective variable, or else Minimize is used. Solvers and subclasses have their ID number starting from 0.
protected Solver ( Cream.Network network, int option, String name ) : System
network Cream.Network the constraint network ///
option int the option for search strategy, or Default for default search strategy ///
name String the name of the solver, or null for a default name ///
리턴 System

Start() 공개 메소드

Starts the solver in a new thread, and immediately returns to the caller. The {@link #WaitNext()} and {@link #WaitNext(long timeout)} methods can be used to wait the next solution. When a solution is found, the solver suspends the execution until the {@link #Resume()} method is called. You can Stop the solver anytime by calling the {@link #Stop()} method.
public Start ( ) : void
리턴 void

Start() 공개 메소드

Starts the solver in a new thread, and immediately returns to the caller. The handler is called for each solution and at the end of the solver execution. You can Stop the solver anytime by calling the {@link #Stop()} method.
public Start ( ISolutionHandler handler ) : void
handler ISolutionHandler solution handler ///
리턴 void

Start() 공개 메소드

Starts the solver in a new thread with the timeout, and immediately returns to the caller. When the timeout milliseconds have been elapsed since the Start of the solver, it stops the execution. The handler is called for each solution and at the end of the solver execution. You can Stop the solver anytime by calling the {@link #Stop()} method.
public Start ( ISolutionHandler handler, long timeout ) : void
handler ISolutionHandler solution handler ///
timeout long timeout in milliseconds (non-positive value means no timeout) ///
리턴 void

Start() 공개 메소드

Starts the solver in a new thread with the timeout, and immediately returns to the caller. When the timeout milliseconds have been elapsed since the Start of the solver, it stops the execution. The {@link #WaitNext()} and {@link #WaitNext(long timeout)} methods can be used to wait the next solution, or to detect the timeout. When a solution is found, the solver suspends the execution until the {@link #Resume()} method is called. You can Stop the solver anytime by calling the {@link #Stop()} method.
public Start ( long timeout ) : void
timeout long timeout in milliseconds (non-positive value means no timeout) ///
리턴 void

Stop() 공개 메소드

Stops the execution of the solver.
public Stop ( ) : void
리턴 void

Success() 보호된 메소드

protected Success ( ) : void
리턴 void

ToString() 공개 메소드

Returns the name of this solver.
public ToString ( ) : String
리턴 String

UpdateBest() 보호된 메소드

protected UpdateBest ( ) : bool
리턴 bool

WaitNext() 공개 메소드

Waits for the next solution, or the end of the solver execution. It returns true if the next solution is available, false if the solver ends the execution.
public WaitNext ( ) : bool
리턴 bool

WaitNext() 공개 메소드

Waits for the next solution, or the end of the solver execution with the timeout. It returns true if the next solution is available within the timeout milliseconds, false if the solver ends the execution or the timeout milliseconds have been elapsed since the Start of this method.
public WaitNext ( long timeout ) : bool
timeout long timeout in milliseconds (non-positive value means no timeout) ///
리턴 bool

프로퍼티 상세

bestSolution 보호되어 있는 프로퍼티

protected Solution,Cream bestSolution
리턴 Solution

bestValue 보호되어 있는 프로퍼티

protected int bestValue
리턴 int

count 보호되어 있는 프로퍼티

protected long count
리턴 long

debug 보호되어 있는 프로퍼티

protected bool debug
리턴 bool

name 보호되어 있는 프로퍼티

protected String name
리턴 String

network 보호되어 있는 프로퍼티

protected Network,Cream network
리턴 Cream.Network

option 보호되어 있는 프로퍼티

protected int option
리턴 int

solution 보호되어 있는 프로퍼티

protected Solution,Cream solution
리턴 Solution

startTime 보호되어 있는 프로퍼티

protected long startTime
리턴 long

totalTimeout 보호되어 있는 프로퍼티

protected long totalTimeout
리턴 long