FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > > Class Template Reference

A solution iterator for JaCoPutilSpace that runs a JaCoP search in an extra thread. More...

Inheritance diagram for frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >:

Public Member Functions

 JaCoPutilSpaceIter2 (JaCoPutilSpace< V > space, String[] variables, AddableInteger[][] domains)
 Constructor.
String toString ()
getCurrentUtility ()
nextUtility ()
void setCurrentUtility (V valuation)
AddableInteger[] getCurrentSolution ()
AddableInteger[][] getDomains ()
String[] getVariablesOrder ()
AddableInteger[] nextSolution ()
void update ()
getCurrentUtility (V bound, boolean minimize)
nextUtility (V bound, boolean minimize)
Public Member Functions inherited from frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.SparseIterator< V, U >
nextUtility (U bound, boolean minimize)
 Returns the next solution strictly better than the input bound.
getCurrentUtility (U bound, boolean minimize)
Public Member Functions inherited from frodo2.solutionSpaces.BasicUtilitySolutionSpace< V extends Addable< V >, U extends Serializable >.SparseIterator< V, U >
void setCurrentUtility (U util)
 Sets the utility of the current solution.

Protected Member Functions

void finalize () throws Throwable

Protected Attributes

JaCoPutilSpace< V > space
 The JaCoPutilSpace we are iterating over.
valuation
 Current valuation.
AddableInteger[] assignments
 Current variable assignments.
String[] variables
 The order of iteration over the variables.
int nbrVars
 The number of variables.
AddableInteger[][] domains
 The variables' domains.

Private Member Functions

void getNextFromSearch (final boolean first)
 The transaction between the current thread and the search thread.
void terminateSearch ()
 As long as the search has not ended its thread is kept alive.
void initSearch (final V strictBound)
 This method starts the search thread.

Private Attributes

strictBound
 Any solution returned by this iterator has to be strictly better than this bound.
final boolean maximize
 Whether to maximize utility or minimize cost.
StoreCloneable store
 The JaCoP Store.
JaCoPiterSearch< V > search
 The JaCoPSearch object that wraps the JaCoP search.
Thread searchThread
 The thread that carries out the JaCoP search.
boolean searchTerminated = false
 Whether the search has already finished going through all solutions.
boolean searchInitiated
 If true, the JaCoP search has already been initiated.
final Lock lock = new ReentrantLock()
 The lock used to ensure that only a single thread is running at a time.
final Condition nextAsked = lock.newCondition()
 The condition used to signal the search to continue until a next solution is found.
final Condition nextDelivered = lock.newCondition()
 The condition used to signal this thread that a new solution has been found and has been delivered.
final V infeasibleValuation
 The infeasible valuation.

Detailed Description

A solution iterator for JaCoPutilSpace that runs a JaCoP search in an extra thread.

This iterator uses less space as all the solutions are not temporarily stored but are computed one by one by pausing the JaCoP search. Additionally, the variables whose projection has been requested are projected in an optimization search that is performed on top of the first search in the same way as a master/slave search combination.

Author
Arnaud Jutzeler, Thomas Leaute
Parameters
<V>the type used for valuations

Constructor & Destructor Documentation

◆ JaCoPutilSpaceIter2()

frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.JaCoPutilSpaceIter2 ( JaCoPutilSpace< V > space,
String[] variables,
AddableInteger domains[][] )

Constructor.

Parameters
spacethe space over which to iterate
variablesthe variable order for the iteration
domainsthe domains of the variables

References domains, space, and variables.

Member Function Documentation

◆ finalize()

void frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.finalize ( ) throws Throwable
protected
See also
java.lang.Object#finalize()

References finalize(), and terminateSearch().

Referenced by finalize().

Here is the call graph for this function:

◆ getCurrentSolution()

◆ getCurrentUtility() [1/2]

◆ getCurrentUtility() [2/2]

V frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.getCurrentUtility ( V bound,
boolean minimize )
See also
SparseIterator.getCurrentUtility(java.lang.Object, boolean)
Todo
Auto-generated method stub

◆ getDomains()

◆ getNextFromSearch()

void frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.getNextFromSearch ( final boolean first)
private

The transaction between the current thread and the search thread.

The control is given to the search thread that will search for the next solution. When the next solution is found, the search records it in its fields and gives back the control to the current thread. Finally, we get the next solution and its valuation using the corresponding getter of the search.

Parameters
firstwhether the search thread must be created and started
Bug
handle spurious wake-ups

References assignments, frodo2.solutionSpaces.JaCoP.JaCoPutilSpace< V extends Addable< V > >.defaultValuation, lock, nextAsked, nextDelivered, search, searchInitiated, and terminateSearch().

Referenced by initSearch(), nextSolution(), nextUtility(), and nextUtility().

Here is the call graph for this function:

◆ getVariablesOrder()

◆ initSearch()

void frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.initSearch ( final V strictBound)
private

This method starts the search thread.

Parameters
strictBoundthe initial strict valuation bound, null if we do not want to set one
Bug
Potential name clash with a user-specified variable name
Bug
Potential name clash with a user-specified variable name

References getNextFromSearch(), frodo2.solutionSpaces.JaCoP.JaCoPutilSpace< V extends Addable< V > >.imposeConstraints(), frodo2.solutionSpaces.JaCoP.JaCoPutilSpace< V extends Addable< V > >.initStore(), frodo2.solutionSpaces.JaCoP.JaCoPutilSpace< V extends Addable< V > >.isConsistent, lock, nbrVars, nextAsked, nextDelivered, space, store, strictBound, and terminateSearch().

Referenced by nextSolution(), nextUtility(), and nextUtility().

Here is the call graph for this function:

◆ nextSolution()

◆ nextUtility() [1/2]

◆ nextUtility() [2/2]

◆ setCurrentUtility()

void frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.setCurrentUtility ( V valuation)
See also
SparseIterator.setCurrentUtility(java.lang.Object)
Todo
Auto-generated method stub

References valuation.

◆ terminateSearch()

void frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.terminateSearch ( )
private

As long as the search has not ended its thread is kept alive.

We might want to kill this thread if we do not need any longer the iterator. This method can be used for that purpose.

References searchThread.

Referenced by finalize(), getNextFromSearch(), and initSearch().

◆ toString()

String frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.toString ( )
See also
java.lang.Object#toString()

◆ update()

Member Data Documentation

◆ assignments

AddableInteger [] frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.assignments
protected

Current variable assignments.

Referenced by getNextFromSearch().

◆ domains

The variables' domains.

Referenced by JaCoPutilSpaceIter2().

◆ infeasibleValuation

final V frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.infeasibleValuation
private

The infeasible valuation.

Todo
One condition should actually be enough.

◆ lock

final Lock frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.lock = new ReentrantLock()
private

The lock used to ensure that only a single thread is running at a time.

Referenced by getNextFromSearch(), and initSearch().

◆ maximize

final boolean frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.maximize
private

Whether to maximize utility or minimize cost.

Referenced by nextUtility().

◆ nbrVars

int frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.nbrVars
protected

The number of variables.

Referenced by initSearch().

◆ nextAsked

final Condition frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.nextAsked = lock.newCondition()
private

The condition used to signal the search to continue until a next solution is found.

Referenced by getNextFromSearch(), and initSearch().

◆ nextDelivered

final Condition frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.nextDelivered = lock.newCondition()
private

The condition used to signal this thread that a new solution has been found and has been delivered.

Referenced by getNextFromSearch(), and initSearch().

◆ search

The JaCoPSearch object that wraps the JaCoP search.

Referenced by getNextFromSearch().

◆ searchInitiated

boolean frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.searchInitiated
private

If true, the JaCoP search has already been initiated.

Referenced by getNextFromSearch().

◆ searchTerminated

boolean frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.searchTerminated = false
private

Whether the search has already finished going through all solutions.

◆ searchThread

Thread frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.searchThread
private

The thread that carries out the JaCoP search.

Referenced by terminateSearch().

◆ space

The JaCoPutilSpace we are iterating over.

Referenced by initSearch(), and JaCoPutilSpaceIter2().

◆ store

The JaCoP Store.

Referenced by initSearch().

◆ strictBound

V frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.strictBound
private

Any solution returned by this iterator has to be strictly better than this bound.

Referenced by initSearch(), and nextUtility().

◆ valuation

V frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.valuation
protected

Current valuation.

Referenced by setCurrentUtility().

◆ variables

String [] frodo2.solutionSpaces.JaCoP.JaCoPutilSpaceIter2< V extends Addable< V > >.variables
protected

The order of iteration over the variables.

Referenced by JaCoPutilSpaceIter2().


The documentation for this class was generated from the following file: