|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectCSPGen.Problem
Problem class is the generator of flawless Random CSPs. This generator is based on the paper "Random constraint satisfaction: Flaws and structure" by Gent et al.,1998. To call the constructor of this class, you need to know five parameters. The first is a random seed which should be a long value, the main reason to use this parameter is to keep track of generated solvable instances. The second parameter is variable numbers of this problem and the third parameter is the domain size of this problem. the fourth parameter will decide the possibility that there exists one constraint between two variables and the fifth parameter will decide the possibility that one constraint will be "satisfied". After calling the constructor, you will get an instance of CSP. In this instance, there will be five public field which will help people to access this problem.They are: size, the variable number of this problem; domainSize, the domain size of this problem; 2D array constraints, which will tell if there exist a binaryconstraint between two variables;Arraylist allconstraints, which is the list of all constraints in this problem; Array Variable, which is the list of all variables in this problem.
| Field Summary | |
protected java.util.ArrayList |
allConstraints
An array to record all the constraints in this problem. |
protected boolean[][] |
constrained
An array to record if there is one constraint between two variables. |
protected BinaryConstraint[][] |
constraints
Records the same information as the constrained table except in the form of pointers to the actual BinaryConstraint instances. |
int |
domainSize
The domain size of the problem. |
double |
p1
The first parameter, as in the constructor of this class. |
double |
p2
The second parameter, as in the constructor of this class. |
long |
Seed
The seed value used in the random number generator. |
int |
size
The number of variables in the problem. |
protected Variable[] |
variables
An arrary of all the Variables in this problem. |
| Constructor Summary | |
Problem(long randSeed,
int nbrOfVars,
int domSize,
double conrate,
double fufillrate)
Class constructor,the main method to generate a new CSP with five parameters |
|
| Method Summary | |
protected void |
addelEdges(int soFar,
boolean add)
|
java.util.Enumeration |
allConstraints()
Returns an enumeration on all the constraints in the problem. |
protected void |
buildCompleteGraph()
the method to build a graph that there is a constraint between any two variables |
boolean |
CheckConstrain(int variable1,
int variable2,
int value1,
int value2)
The method to judge if two values of two variables are consistent under the binary constraint between these two variables. |
boolean |
connected(int v1,
int v2)
Returns true if there is a a constraint between variable v1 and v2. |
BinaryConstraint |
connected(Variable v1,
Variable v2)
Returns the BinaryConstraint between v1 and v2 if one exists |
protected void |
connection(int v1,
int v2,
boolean conn)
make the connection between two variables v1 and v2 |
Variable |
getVariable(int i)
Returns the Variable with the specified id. |
protected void |
initArrays(boolean edgeDefault)
set all the edges of the graph to be true or false |
static void |
main(java.lang.String[] args)
A testing method that generates 5 pre-set problems and prints a representation of each to the screen. |
void |
print()
Prints out all the constraints in this problem, one per line, to the standard output. |
protected void |
setEdge(int v1,
int v2,
boolean[][] array)
Deprecated. The BinaryConstraint class now handles these these details on the fly. |
java.lang.String |
toString()
Returns a string representation of this problem. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public final int size
public final int domainSize
protected boolean[][] constrained
protected BinaryConstraint[][] constraints
null is used for false
constrainedprotected java.util.ArrayList allConstraints
public final double p1
Problem(long, int, int, double, double)public final double p2
Problem(long, int, int, double, double)public final long Seed
Problem(long, int, int, double, double)protected Variable[] variables
| Constructor Detail |
public Problem(long randSeed,
int nbrOfVars,
int domSize,
double conrate,
double fufillrate)
randSeed - the randomseed of the generated problemnbrOfVars - number of variablesdomSize - domain size of the problemconrate - the parameter p1 of the problem,e.g. the possibility of there exist constraint between two variablesfufillrate - the parameter p2 of the problem, e.g. the possibility of one constraint be fulfilled.| Method Detail |
protected void initArrays(boolean edgeDefault)
edgeDefault - the value which will be set to all edges of the graph.
public boolean connected(int v1,
int v2)
v1 - the id of a variable in the problemv2 - the id of another variable in the problem
true if there exists a constraint
between variable v1 and v2, false otherwise.
public BinaryConstraint connected(Variable v1,
Variable v2)
v1 - a variable in the problemv2 - another variable in the problem
null if none exists.
protected void addelEdges(int soFar,
boolean add)
protected void buildCompleteGraph()
protected void connection(int v1,
int v2,
boolean conn)
throws java.lang.IndexOutOfBoundsException
v1 - v2 - conn - the parameter to tell if there exist a constraint between v1 and v2
java.lang.IndexOutOfBoundsException
protected void setEdge(int v1,
int v2,
boolean[][] array)
v1 - v2 - array - the truth table of constraint between v1 and v2
java.lang.IndexOutOfBoundsException
public boolean CheckConstrain(int variable1,
int variable2,
int value1,
int value2)
variable1 - the first variable to be assigned valuevariable2 - the second variable to be assigned valuevalue1 - the value to be assigned to variable1value2 - the value to be assigned to variable2
true if variable1=value1 and variable2=value2 is
consistent under the binary constraint between them.false otherwisepublic java.util.Enumeration allConstraints()
public java.lang.String toString()
public Variable getVariable(int i)
i - an id of a Variable in this problem
ArrayOutOfBoundsException - if the given id
does not exist in this problem.public void print()
BinaryConstraint.toString()public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||