FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > > Class Template Reference

A parser for XCSP files involving constraints of type "global:vehicle_routing". More...

Inheritance diagram for frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >:

Public Member Functions

 XCSPparserVRP (Document doc)
 Constructor from a JDOM Document in XCSP format.
 XCSPparserVRP (Document doc, Element params)
 Constructor.
XCSPparserVRP< U > getSubProblem (String agent)
void setUtilClass (Class< U > utilClass)
void rescale (U multiply, U add)
Public Member Functions inherited from frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >
 XCSPparser ()
 Empty constructor.
 XCSPparser (Element root)
 Constructor from a JDOM root Element in XCSP format.
 XCSPparser (Document doc)
 Constructor from a JDOM Document in XCSP format.
 XCSPparser (Document doc, Boolean countNCCCs)
 Constructor from a JDOM Document in XCSP format.
 XCSPparser (Document doc, Boolean countNCCCs, HashSet< String > spacesToIgnore)
 Constructor from a JDOM Document in XCSP format.
 XCSPparser (Document doc, boolean countNCCCs, boolean extendedRandNeighborhoods)
 Constructor from a JDOM Document in XCSP format.
 XCSPparser (Document doc, boolean countNCCCs, boolean extendedRandNeighborhoods, boolean publicAgents)
 Constructor from a JDOM Document in XCSP format.
 XCSPparser (Document doc, Element params)
 Constructor.
void setDomClass (Class< V > domClass)
 Sets the class to be used for variable values.
Class< V > getDomClass ()
void addSpaceToIgnore (String spaceToIgnore)
 Adds a space to be ignored.
String getAgent ()
getZeroUtility ()
getPlusInfUtility ()
getMinInfUtility ()
List< ? extends UtilitySolutionSpace< V, U > > getProbabilitySpaces ()
 Extracts probability spaces from the constraints in the problem.
List< ? extends UtilitySolutionSpace< V, U > > getProbabilitySpaces (String var)
 Extracts probability spaces involving the input variable from the constraints in the problem.
List< ? extends UtilitySolutionSpace< V, U > > getSolutionSpaces ()
 Returns the solution spaces in the problem.
List< ? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (String var)
 Extracts solution spaces involving the input variable from the constraints in the problem.
List< ? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (final boolean withAnonymVars)
 Extracts solution spaces from the constraints in the problem.
List< ? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (DCOPProblemInterface< V, U > problem, final boolean withAnonymVars)
 Extracts solution spaces from the constraints in the problem.
List< ? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (String var, final boolean withAnonymVars)
 Extracts solution spaces involving the input variable from the constraints in the problem.
List<? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (String var, Set< String > forbiddenVars)
 Returns the solution spaces involving the input variable and none of the forbidden variables.
List<? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (String var, boolean withAnonymVars, Set< String > forbiddenVars)
 Extracts solution spaces involving the input variable from the constraints in the problem.
List<? extends UtilitySolutionSpace< V, U > > getSolutionSpaces (Set< String > vars, boolean withAnonymVars, Set< String > forbiddenVars)
 Extracts solution spaces involving the input variables from the constraints in the problem.
boolean isCountingNCCCs ()
void incrNCCCs (long incr)
 Increments the number of constraint checks.
void setNCCCs (long ncccs)
 Sets the NCCC count.
long getNCCCs ()
boolean removeSpace (String name)
 Removes the space with the given name.
boolean addSolutionSpace (UtilitySolutionSpace< V, U > space)
 Adds a solution space to the problem.
Set< String > getAgents ()
String getOwner (String var)
 Returns the name of the agent owning the input variable.
boolean setOwner (String var, String owner)
 Sets the owner agent for the input variable.
Map< String, String > getOwners ()
int getNbrVars ()
 Extracts the number of variables in the problem.
int getNbrVars (String owner)
 Computes the number of variables owned by the input agent.
int getNbrIntVars ()
Set< String > getAllVars ()
Set< String > getVariables ()
Set< String > getVariables (String owner)
 Returns the set of variables owned by a given agent.
Set< String > getMyVars ()
Set< String > getExtVars ()
Set< String > getAnonymVars ()
boolean addVariable (String name, String owner, String domain)
 Adds a new variable.
boolean addVariable (String name, String owner, V[] domain)
 Adds a new variable.
HashSet< String > getNeighborVars (String var)
 Extracts the collection of neighbors of a given variable.
HashSet< String > getNeighborVars (String var, final boolean withAnonymVars)
 Extracts the collection of neighbors of a given variable.
int getNbrNeighbors (String var)
 Extracts the number of neighbors of an input variable.
int getNbrNeighbors (String var, final boolean withAnonymVars)
 Extracts the number of neighbors of an input variable.
Map< String, HashSet< String > > getNeighborhoods (String agent)
 Parses the problem description to construct, for each variable owned by the input agent, its list of neighbors.
Map< String, HashSet< String > > getNeighborhoods ()
 Returns the neighborhood of each internal variable.
Map< String, HashSet< String > > getAnonymNeighborhoods (String agent)
 Parses the problem description to construct, for each variable owned by the input agent, its list of neighbors with no specified owner.
Map< String, HashSet< String > > getAnonymNeighborhoods ()
Map< String, HashSet< String > > getNeighborhoods (String agent, final boolean withAnonymVars, final boolean onlyAnonymVars)
 Parses the problem description to construct, for each variable owned by the input agent, its list of neighbors.
Map< String, Integer > getNeighborhoodSizes (String agent)
 Computes the number of neighboring variables of all variables owned by a given agent.
Map< String, Integer > getNeighborhoodSizes ()
 Returns the number of neighboring variables of all internal variables.
Map< String, Collection< String > > getAgentNeighborhoods (String agent)
 Gets the agent neighborhoods.
Map< String, Collection< String > > getAgentNeighborhoods ()
Map< String, Collection< String > > getBackyardNeighborhood (String var)
 This method only makes sense in subclasses of XCSPparser that handle backyard variables.
int getDomainSize (String var)
 Extracts the size of the domain of the input variable.
V[] getDomain (String var)
 Extracts the domain of a given variable.
void setDomain (String var, V[] dom)
 Sets the domain of a variable in the problem.
void setProbSpace (String var, Map< V, Double > prob)
 Adds to the problem a probability space for the input random variable.
String toString ()
String toDOT ()
boolean isRandom (String var)
 Returns whether the input variable is defined as a random variable.
Document groundVars (String[] vars, V[] values)
 Transforms the problem into one where some variables' values have been fixed.
UtilitySolutionSpace< V, U > getUtility (Map< String, V > assignments)
 Computes the total utility of the input assignment to variables, ignoring variables with no specified owner.
UtilitySolutionSpace< V, U > getUtility (Map< String, V > assignments, final boolean withAnonymVars)
 Computes the total utility of the input assignment to variables.
UtilitySolutionSpace< V, U > getExpectedUtility (Map< String, V > assignments)
 Computes the expectation over the random variables of the utility for the input assignments.
UtilitySolutionSpace< V, U > getParamUtility (Map< String[], BasicUtilitySolutionSpace< V, ArrayList< V > > > assignments)
 Computes the total utility of the input assignment to variables, conditioned on the values of parameters.
boolean maximize ()
void setMaximize (boolean maximize)
 Sets whether utility should be maximized, or cost minimized.
Document switchMaxMin (int shiftInt)
 Change the problem from a maximisation problem to a minimisation problem.
void reset (ProblemInterface< V, U > newProblem)
 Resets this problem to be the same as the input one.
int getNumberOfCoordinationConstraints ()
 Returns the number of spaces that are shared between different agents.
boolean multipleTypes ()
UtilitySolutionSpace< V, U > addUnarySpace (String name, String var, V[] dom, U[] utils)
 Add a unary solution space to the problem.
DCOPProblemInterface< V, U > parse ()
Public Member Functions inherited from frodo2.algorithms.ParserInterface< V, U >
ProblemInterface< V, U > parse ()

Protected Member Functions

 XCSPparserVRP (Element instance)
 Constructor from a JDOM root Element in XCSP format.
 XCSPparserVRP (Element instance, boolean countNCCCs, boolean extendedRandNeighborhoods, HashSet< String > spacesToIgnoreNcccs, boolean mpc)
 Constructor from a JDOM root Element in XCSP format.
XCSPparserVRP< U > newInstance (Element instance)
void foundUndefinedRelations (HashSet< String > relationNames)
void parseConstraint (ArrayList< UtilitySolutionSpace< AddableInteger, U > > spaces, Element constraint, HashMap< String, AddableInteger[]> variablesHashMap, HashMap< String, Relation< AddableInteger, U > > relationInfos, Set< String > vars, final boolean getProbs, final boolean withAnonymVars, U infeasibleUtil, Set< String > forbiddenVars, DCOPProblemInterface< AddableInteger, U > problem)
Protected Member Functions inherited from frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >
 XCSPparser (Element root, boolean countNCCCs, boolean extendedRandNeighborhoods)
 Constructor from a JDOM root Element in XCSP format.
 XCSPparser (Element root, boolean countNCCCs, boolean extendedRandNeighborhoods, boolean publicAgents)
 Constructor from a JDOM root Element in XCSP format.
 XCSPparser (Element root, boolean countNCCCs)
 Constructor from a JDOM root Element in XCSP format.
 XCSPparser (Element root, boolean countNCCCs, boolean extendedRandNeighborhoods, HashSet< String > spacesToIgnoreNcccs, boolean mpc)
 Constructor from a JDOM root Element in XCSP format.
getInfeasibleUtil ()
List< ? extends UtilitySolutionSpace< V, U > > getSpaces (Set< String > vars, final boolean withAnonymVars, final boolean getProbs, Set< String > forbiddenVars, DCOPProblemInterface< V, U > problem)
 Extracts hypercubes from the constraints in the problem.
void parseConstraint (ArrayList< UtilitySolutionSpace< V, U > > spaces, Element constraint, HashMap< String, V[]> variablesHashMap, HashMap< String, Relation< V, U > > relationInfos, Set< String > vars, final boolean getProbs, final boolean withAnonymVars, U infeasibleUtil, Set< String > forbiddenVars, DCOPProblemInterface< V, U > problem)
 Parses a constraint.
V[] getDomain (Element domainElmt, final boolean debugLoad)
 Parses and instantiates a domain from a domain Element.
boolean ignore (String spaceClass)

Additional Inherited Members

Static Public Member Functions inherited from frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >
static Document parse (File file) throws JDOMException, IOException
 Creates a JDOM Document out of the input XML file in XCSP format.
static Document parse (File file, boolean checkXCSP) throws JDOMException, IOException
 Creates a JDOM Document out of the input XML file (not necessarily in XCSP format).
static Document parse (String path) throws Exception
 Creates a JDOM Document out of the input XML file path in XCSP format.
static Document parse (String path, boolean checkXCSP) throws Exception
 Creates a JDOM Document out of the input XML file path (not necessarily in XCSP format).
static Document parse (InputStream stream) throws JDOMException, IOException
 Creates a JDOM Document out of the input XML stream in XCSP format.
static Document parse (InputStream stream, boolean checkXCSP) throws JDOMException, IOException
 Creates a JDOM Document out of the input XML stream (not necessarily in XCSP format).
static String toString (Document doc)
 Returns a human-friendly String representation of the input JDOM Document.
static String toString (Element root)
 Returns a human-friendly String representation of the input JDOM Element.
static void main (String[] args) throws Exception
 Parses the input problem.
static String toDOT (Document doc)
 Returns the constraint graph in DOT format.
static String toDOT (Element root)
 Returns the constraint graph in DOT format.
static< V extends Addable< V > Element getRelation (UtilitySolutionSpace< V, ? extends Addable<?> > hypercube, String id, String nature)
 Generates the XCSP "relation" or "probability" fragment corresponding to the input hypercube.
static Element getConstraint (UtilitySolutionSpace<?, ?> hypercube, String id, String ref)
 Creates an XCSP-formated description of this contraint.
Protected Attributes inherited from frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >
Element root
 JDOM Element in XCSP format.
Class< U > utilClass = (Class<U>) AddableInteger.class
 The class to be used for utility values.
valInstance = (V) new AddableInteger ()
 An instance of V.
final boolean extendedRandNeighborhoods
 If true, neighborhood relationships between decision variables are extended through random variables.
final boolean publicAgents
 Whether each agent knows the identities of all agents.
final boolean mpc
 Whether to behave in MPC mode.
final boolean countNCCCs
 Whether to count constraint checks.
HashSet< String > spacesToIgnoreNcccs
 a set of spaces for which ncccs should be ignored

Detailed Description

A parser for XCSP files involving constraints of type "global:vehicle_routing".

Author
Thomas Leaute
Parameters
<U>the type used for utility values (default is AddableReal)

Constructor & Destructor Documentation

◆ XCSPparserVRP() [1/4]

Constructor from a JDOM Document in XCSP format.

Parameters
docthe JDOM Document in XCSP format

Referenced by getSubProblem(), and newInstance().

◆ XCSPparserVRP() [2/4]

frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.XCSPparserVRP ( Document doc,
Element params )

Constructor.

Parameters
docthe JDOM Document in XCSP format
paramsthe parameters of the solver

◆ XCSPparserVRP() [3/4]

frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.XCSPparserVRP ( Element instance)
protected

Constructor from a JDOM root Element in XCSP format.

Parameters
instancethe JDOM root Element in XCSP format

◆ XCSPparserVRP() [4/4]

frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.XCSPparserVRP ( Element instance,
boolean countNCCCs,
boolean extendedRandNeighborhoods,
HashSet< String > spacesToIgnoreNcccs,
boolean mpc )
protected

Constructor from a JDOM root Element in XCSP format.

Parameters
instancethe JDOM root Element in XCSP format
countNCCCsWhether to count constraint checks
extendedRandNeighborhoodswhether we want extended random neighborhoods
spacesToIgnoreNcccslist of spaces for which NCCCs should NOT be counted
mpcWhether to behave in MPC mode

References frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.countNCCCs, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.extendedRandNeighborhoods, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.mpc, and frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.spacesToIgnoreNcccs.

Member Function Documentation

◆ foundUndefinedRelations()

void frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.foundUndefinedRelations ( HashSet< String > relationNames)
protected

◆ getSubProblem()

XCSPparserVRP< U > frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.getSubProblem ( String agent)
See also
XCSPparser.getSubProblem(java.lang.String)

Reimplemented from frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.

References getSubProblem(), and XCSPparserVRP().

Referenced by getSubProblem().

Here is the call graph for this function:

◆ newInstance()

◆ parseConstraint()

void frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.parseConstraint ( ArrayList< UtilitySolutionSpace< AddableInteger, U > > spaces,
Element constraint,
HashMap< String, AddableInteger[]> variablesHashMap,
HashMap< String, Relation< AddableInteger, U > > relationInfos,
Set< String > vars,
final boolean getProbs,
final boolean withAnonymVars,
U infeasibleUtil,
Set< String > forbiddenVars,
DCOPProblemInterface< AddableInteger, U > problem )
protected
See also
XCSPparser#parseConstraint(ArrayList, Element, HashMap, HashMap, Set, boolean, boolean, Addable, Set, DCOPProblemInterface)

References frodo2.solutionSpaces.vehiclerouting.VehicleRoutingSpace< U extends Addable< U > >.getName().

Here is the call graph for this function:

◆ rescale()

void frodo2.benchmarks.vehiclerouting.XCSPparserVRP< U extends Addable< U > >.rescale ( U multiply,
U add )
See also
XCSPparser#rescale(Addable, Addable)

Reimplemented from frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.

◆ setUtilClass()


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