FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.solutionSpaces.hypercube.tests.HypercubeTest Class Reference

A class used to test the Hypercube class. More...

Inheritance diagram for frodo2.solutionSpaces.hypercube.tests.HypercubeTest:

Classes

enum  Infinity
 Variables are used to determine whether infinite values are allowed. More...

Public Member Functions

 HypercubeTest (String name)
 Contructor that returns a TestCase consisting of a single test method.
void setUp ()
void testSaveAsXMLRandom ()
 Tests the saving to XML functionality.
void testEqualClonesRandom ()
 Tests that a hypercube is equal to a clone of itself.
void testEquivalentRandom ()
 Tests that a hypercube is equivalent to itself with reordered variables.
void testJoinRandom ()
 This method creates random number of hypercubes and then first join the hypercubes with one call of the join method.
void testApplyJoinRandom ()
 This method creates two random hypercubes change the variables order of the second hypercube so that the variables order of the two hypercubes is not necessarily consistent, then joins these two hypercubes by using join and applyJoin methods, and compares the two outputs.
void testProjectionRandom ()
 This method creates two random hypercubes and an array of random variables obtained from the variables of each hypercube.
void testApplyProjectRandom ()
 This method creates a random hypercube and a random array of variables, then checks that the result of the projection of these variables out of the hypercube by using project and applyProject is the same.
void testProjOutputRandom ()
 This method tests that the projection method (taking a list of variables) computes the correct optimal assignments.
void testProjOutputRandom2 ()
 This method tests that the projection method (taking a number of variables) computes the correct optimal assignments.
void testSliceRandom ()
 This method creates two random hypercubes, performs a slice on them, and them joins the two sliced hypercubes.
void testApplySliceRandom ()
 Creates one random hypercube and tests if slice and applySlice return the same output.
void testSplittingRandom ()
 this method creates a random hypercube.
void testChangeVariablesOrderRandom ()
 Tests changing the order of variables.
void testApplyChangeVariablesOrderRandom ()
 creates a random hypercube and tests whether changeVariablesOrder and applyChangeVariablesOrder return the same output
void testGetUtility ()
 This method creates a random hypercube, then gets all its utilities values and store them in a new arrray, and finally checks this array is identical to the utilities array of the original hypercube.
void testProjection ()
 Tests the projection methods on a simple example.
void testSerializationRandom () throws IOException, ClassNotFoundException
 Tests the serialization of a random hypercube.
void testSerializationNullHypercube ()
 Method to test the serialization of the NULL hypercube.
void testUnion ()
 Tests the union() method.
void testProjectAllRandom ()
 Tests the projection method when all variables are projected out.
void testBlindProjectRandom ()
 Tests blindProject().
void testSmartJoinRandom ()
 Tests the additive join method that automatically computes the variable ordering.
void testSmartMultiplyRandom ()
 Tests the multiplicative join method that automatically computes the variable ordering.
void testSmartJoinRandom (boolean addition)
 Tests the join method that automatically computes the variable ordering.
void testExpectation ()
 Tests the expectation operation.
void testCompose ()
 Tests the composition method.
void testSample ()
 Test for the sample(int) method.
void testConsensusWeighted ()
 Tests the consensus() operation with weighted samples.
void testConsensusWeightedExpect ()
 Tests the consensusExpect() operation with weighted samples.
void testIterator ()
 Test for the iterator() method that takes in a list of variables not necessarily containing all the space's variables.

Static Public Member Functions

static Test suite ()
 Builds up a test suite.
static Hypercube< AddableInteger, AddableIntegerrandom_hypercube ()
static Hypercube< AddableInteger, AddableIntegerrandom_hypercube (double prob)
static< U extends Addable< U > Hypercube< AddableInteger, U > random_hypercube (double prob, Class< U > utilClass)
static Hypercube< AddableInteger, AddableIntegerrandom_hypercube (int number_variables, int domain_size, int redundancy, int shift)
static Hypercube< AddableInteger, AddableIntegerrandom_hypercube (int number_variables, int domain_size, int redundancy, int shift, AddableInteger infeasibleUtil)
static< U extends Addable< U > Hypercube< AddableInteger, U > random_hypercube (int number_variables, int domain_size, int redundancy, int shift, U infeasibleUtil, Class< U > utilClass)

Public Attributes

boolean maximize
 This variable is used to choose between maximising and minimising during the tests.

Static Public Attributes

static Infinity inf = Infinity.NONE
 This variable is used to make sure that one does not mix plus infinity and min infinity in the testing.

Package Functions

private< T extends Comparable< T > > T[] intersection (T[] array1, T[] array2)
 Computes the intersection of two lists.

Private Member Functions

void verifyProjection (Hypercube< AddableInteger, AddableInteger > hypercube, UtilitySolutionSpace.ProjOutput< AddableInteger, AddableInteger > projOutput, String[] vars)
 Verifies the output of the projection method.
String[] sub_variables (String[] variables)
 Computes a random sublist of the input list of variables.
String[] union (String[] array1, String[] array2, String[] total_variables)
 Computes the union of two lists, respecting the input total order on the elements.
void testConsensusWeighted (final boolean expect)
 Tests the consensus() operation with weighted samples.

Detailed Description

A class used to test the Hypercube class.

Author
Ouaret Nacereddine, Thomas Leaute, Radoslaw Szymanek
Todo
change every test in the following manner. If it fails, log the arguments and information what has failed so the test can be repeated.

Constructor & Destructor Documentation

◆ HypercubeTest()

frodo2.solutionSpaces.hypercube.tests.HypercubeTest.HypercubeTest ( String name)

Contructor that returns a TestCase consisting of a single test method.

Parameters
namethe name of the method to be used

Referenced by suite().

Member Function Documentation

◆ intersection()

private< T extends Comparable< T > > T[] frodo2.solutionSpaces.hypercube.tests.HypercubeTest.intersection ( T[] array1,
T[] array2 )
package

Computes the intersection of two lists.

Parameters
<T>the type of the elements in the lists
array1the first list
array2the second list
Returns
the intersection of the two lists

References intersection().

Referenced by intersection(), and testSliceRandom().

Here is the call graph for this function:

◆ random_hypercube() [1/6]

◆ random_hypercube() [2/6]

Hypercube< AddableInteger, AddableInteger > frodo2.solutionSpaces.hypercube.tests.HypercubeTest.random_hypercube ( double prob)
static
Parameters
probfor any given utility, the probability that it be infinite
Returns
random hypercube
Todo
This implementation is too restrictive (imposes an order on variables, values...).

References random_hypercube().

Here is the call graph for this function:

◆ random_hypercube() [3/6]

static< U extends Addable< U > Hypercube< AddableInteger, U > frodo2.solutionSpaces.hypercube.tests.HypercubeTest.random_hypercube ( double prob,
Class< U > utilClass )
static
Parameters
<U>the class used for utility values
probfor any given utility, the probability that it be infinite
utilClassthe class used for utility values
Returns
random hypercube
Todo
This implementation is too restrictive (imposes an order on variables, values...).

References inf, frodo2.solutionSpaces.hypercube.tests.HypercubeTest.Infinity.NONE, and frodo2.solutionSpaces.hypercube.tests.HypercubeTest.Infinity.PLUS_INFINITY.

◆ random_hypercube() [4/6]

Hypercube< AddableInteger, AddableInteger > frodo2.solutionSpaces.hypercube.tests.HypercubeTest.random_hypercube ( int number_variables,
int domain_size,
int redundancy,
int shift )
static
Parameters
number_variablesnumber of variables of the generated Hypercube will contain
domain_sizenumber of values that the domains of the variables of the Hypercube
redundancyredundancy in the array of utilities (between 0 - 100)
shiftthe number starting with which the variables should be named (Xshift, X(shift+1)...)
Returns
a random hypercube, with some random utilities set to -1

References random_hypercube().

Here is the call graph for this function:

◆ random_hypercube() [5/6]

Hypercube< AddableInteger, AddableInteger > frodo2.solutionSpaces.hypercube.tests.HypercubeTest.random_hypercube ( int number_variables,
int domain_size,
int redundancy,
int shift,
AddableInteger infeasibleUtil )
static
Parameters
number_variablesnumber of variables of the generated Hypercube will contain
domain_sizenumber of values that the domains of the variables of the Hypercube
redundancyredundancy in the array of utilities (between 0 - 100)
shiftthe number starting with which the variables should be named (Xshift, X(shift+1)...)
infeasibleUtilthe infeasible utility
Returns
a random hypercube, with some random utilities set to -1

References random_hypercube().

Here is the call graph for this function:

◆ random_hypercube() [6/6]

static< U extends Addable< U > Hypercube< AddableInteger, U > frodo2.solutionSpaces.hypercube.tests.HypercubeTest.random_hypercube ( int number_variables,
int domain_size,
int redundancy,
int shift,
U infeasibleUtil,
Class< U > utilClass )
static
Parameters
<U>the type of utility values
number_variablesnumber of variables of the generated Hypercube will contain
domain_sizenumber of values that the domains of the variables of the Hypercube
redundancyredundancy in the array of utilities (between 0 - 100)
shiftthe number starting with which the variables should be named (Xshift, X(shift+1)...)
infeasibleUtilthe infeasible utility
utilClassthe type of utility values
Returns
a random hypercube, with some random utilities set to -1

variables names and their domains ///

array of utilities ///

References random_hypercube().

Here is the call graph for this function:

◆ setUp()

◆ sub_variables()

String[] frodo2.solutionSpaces.hypercube.tests.HypercubeTest.sub_variables ( String[] variables)
private

Computes a random sublist of the input list of variables.

Parameters
variableslist of variables
Returns
a random sublist of variables

References sub_variables().

Referenced by sub_variables(), testApplyProjectRandom(), testProjectionRandom(), and testSplittingRandom().

Here is the call graph for this function:

◆ suite()

Test frodo2.solutionSpaces.hypercube.tests.HypercubeTest.suite ( )
static

Builds up a test suite.

Author
Thomas Leaute
Returns
a TestSuite in which randomized test methods are run multiple times, and others only once

References HypercubeTest().

Referenced by frodo2.solutionSpaces.hypercube.tests.AllTestsHypercube.suite().

Here is the call graph for this function:

◆ testApplyChangeVariablesOrderRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testApplyChangeVariablesOrderRandom ( )

◆ testApplyJoinRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testApplyJoinRandom ( )

This method creates two random hypercubes change the variables order of the second hypercube so that the variables order of the two hypercubes is not necessarily consistent, then joins these two hypercubes by using join and applyJoin methods, and compares the two outputs.

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.applyJoin(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.changeVariablesOrder(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.clone(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.join(), and random_hypercube().

Here is the call graph for this function:

◆ testApplyProjectRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testApplyProjectRandom ( )

◆ testApplySliceRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testApplySliceRandom ( )

◆ testBlindProjectRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testBlindProjectRandom ( )

Tests blindProject().

Author
Thomas Leaute

References frodo2.java, maximize, and random_hypercube().

Here is the call graph for this function:

◆ testChangeVariablesOrderRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testChangeVariablesOrderRandom ( )

◆ testCompose()

◆ testConsensusWeighted() [1/2]

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testConsensusWeighted ( )

Tests the consensus() operation with weighted samples.

References testConsensusWeighted().

Referenced by testConsensusWeighted(), and testConsensusWeightedExpect().

Here is the call graph for this function:

◆ testConsensusWeighted() [2/2]

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testConsensusWeighted ( final boolean expect)
private

Tests the consensus() operation with weighted samples.

Parameters
expectwhether to compose the consensus operation with the expectation operation

References frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.ProjOutput< V extends Addable< V >, U extends Addable< U > >.assignments, frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.blindProject(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.changeVariablesOrder(), frodo2.solutionSpaces.AddableReal.compareTo(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.compose(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.consensus(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.consensusAllSols(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.consensusExpect(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.expectation(), frodo2.solutionSpaces.BasicUtilitySolutionSpace< V extends Addable< V >, U extends Serializable >.SparseIterator< V, U >.getCurrentUtility(), frodo2.solutionSpaces.SolutionSpace< V extends Addable< V > >.getDomain(), frodo2.solutionSpaces.SolutionSpace< V extends Addable< V > >.getNumberOfSolutions(), frodo2.solutionSpaces.SolutionSpace< V extends Addable< V > >.getNumberOfVariables(), frodo2.solutionSpaces.BasicUtilitySolutionSpace< V extends Addable< V >, U extends Serializable >.getUtility(), frodo2.solutionSpaces.SolutionSpace< V extends Addable< V > >.getVariables(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.ProjOutput< V extends Addable< V >, U extends Addable< U > >.getVariables(), frodo2.solutionSpaces.SolutionSpace< V extends Addable< V > >.Iterator< V >.hasNext(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.iterator(), maximize, frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.multiply(), frodo2.solutionSpaces.BasicUtilitySolutionSpace< V extends Addable< V >, U extends Serializable >.SparseIterator< V, U >.nextUtility(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.NullHypercube< V extends Addable< V >, U extends Addable< U > >.NULL, random_hypercube(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.resolve(), frodo2.solutionSpaces.BasicUtilitySolutionSpace< V extends Addable< V >, U extends Serializable >.slice(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.slice(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.slice(), and frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.ProjOutput< V extends Addable< V >, U extends Addable< U > >.space.

Here is the call graph for this function:

◆ testConsensusWeightedExpect()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testConsensusWeightedExpect ( )

Tests the consensusExpect() operation with weighted samples.

References testConsensusWeighted().

Here is the call graph for this function:

◆ testEqualClonesRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testEqualClonesRandom ( )

◆ testEquivalentRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testEquivalentRandom ( )

Tests that a hypercube is equivalent to itself with reordered variables.

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.changeVariablesOrder(), and random_hypercube().

Here is the call graph for this function:

◆ testExpectation()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testExpectation ( )

◆ testGetUtility()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testGetUtility ( )

This method creates a random hypercube, then gets all its utilities values and store them in a new arrray, and finally checks this array is identical to the utilities array of the original hypercube.

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.getUtility(), and random_hypercube().

Here is the call graph for this function:

◆ testIterator()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testIterator ( )

Test for the iterator() method that takes in a list of variables not necessarily containing all the space's variables.

Todo
Further tests could be useful.

References frodo2.solutionSpaces.SolutionSpace< V extends Addable< V > >.SparseIterator< V >.getVariablesOrder(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.iterator(), and random_hypercube().

Here is the call graph for this function:

◆ testJoinRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testJoinRandom ( )

This method creates random number of hypercubes and then first join the hypercubes with one call of the join method.

then join the hypercube two by two and compare the two results.

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.join(), frodo2.solutionSpaces.UtilitySolutionSpace< V extends Addable< V >, U extends Addable< U > >.join(), random_hypercube(), and testJoinRandom().

Referenced by testJoinRandom().

Here is the call graph for this function:

◆ testProjectAllRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testProjectAllRandom ( )

Tests the projection method when all variables are projected out.

Author
Thomas Leaute

References frodo2.solutionSpaces.AddableInteger.compareTo(), maximize, and random_hypercube().

Here is the call graph for this function:

◆ testProjection()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testProjection ( )

◆ testProjectionRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testProjectionRandom ( )

◆ testProjOutputRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testProjOutputRandom ( )

This method tests that the projection method (taking a list of variables) computes the correct optimal assignments.

Author
Thomas Leaute

References maximize, random_hypercube(), and verifyProjection().

Here is the call graph for this function:

◆ testProjOutputRandom2()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testProjOutputRandom2 ( )

This method tests that the projection method (taking a number of variables) computes the correct optimal assignments.

Author
Thomas Leaute

References maximize, random_hypercube(), and verifyProjection().

Here is the call graph for this function:

◆ testSample()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSample ( )

◆ testSaveAsXMLRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSaveAsXMLRandom ( )

◆ testSerializationNullHypercube()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSerializationNullHypercube ( )

Method to test the serialization of the NULL hypercube.

Constructor

Parameters
outthe output stream
objthe object to be written
Bug
objIn might not be closed

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.equals(), frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.NullHypercube< V extends Addable< V >, U extends Addable< U > >.NULL, and testSerializationNullHypercube().

Referenced by testSerializationNullHypercube().

Here is the call graph for this function:

◆ testSerializationRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSerializationRandom ( ) throws IOException, ClassNotFoundException

Tests the serialization of a random hypercube.

Author
Thomas Leaute
Exceptions
IOExceptionif unable to create the pipes, or an I/O error occurs when deserializing the hypercube
ClassNotFoundExceptionshould never happen

Constructor

Parameters
outthe output stream
objthe object to be written

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.equals(), random_hypercube(), and testSerializationRandom().

Referenced by testSerializationRandom().

Here is the call graph for this function:

◆ testSliceRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSliceRandom ( )

◆ testSmartJoinRandom() [1/2]

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSmartJoinRandom ( )

Tests the additive join method that automatically computes the variable ordering.

References testSmartJoinRandom().

Referenced by testSmartJoinRandom(), and testSmartMultiplyRandom().

Here is the call graph for this function:

◆ testSmartJoinRandom() [2/2]

◆ testSmartMultiplyRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSmartMultiplyRandom ( )

Tests the multiplicative join method that automatically computes the variable ordering.

References testSmartJoinRandom().

Here is the call graph for this function:

◆ testSplittingRandom()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testSplittingRandom ( )

◆ testUnion()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.testUnion ( )

Tests the union() method.

Author
Thomas Leaute

References frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.union().

Here is the call graph for this function:

◆ union()

String[] frodo2.solutionSpaces.hypercube.tests.HypercubeTest.union ( String[] array1,
String[] array2,
String[] total_variables )
private

Computes the union of two lists, respecting the input total order on the elements.

Parameters
array1the first list
array2the second list
total_variablesthe desired total order on the elements
Returns
union of the two input lists

References union().

Referenced by testProjectionRandom(), and union().

Here is the call graph for this function:

◆ verifyProjection()

void frodo2.solutionSpaces.hypercube.tests.HypercubeTest.verifyProjection ( Hypercube< AddableInteger, AddableInteger > hypercube,
UtilitySolutionSpace.ProjOutput< AddableInteger, AddableInteger > projOutput,
String[] vars )
private

Verifies the output of the projection method.

Parameters
hypercubethe initial hypercube
projOutputthe result of the projection
varsthe variables projected out

References frodo2.solutionSpaces.hypercube.BasicHypercube< V extends Addable< V >, U extends Serializable >.getUtility(), and frodo2.solutionSpaces.hypercube.Hypercube< V extends Addable< V >, U extends Addable< U > >.getUtility().

Referenced by testApplyProjectRandom(), testProjOutputRandom(), and testProjOutputRandom2().

Here is the call graph for this function:

Member Data Documentation

◆ inf

Infinity frodo2.solutionSpaces.hypercube.tests.HypercubeTest.inf = Infinity.NONE
static

This variable is used to make sure that one does not mix plus infinity and min infinity in the testing.

Referenced by random_hypercube(), setUp(), testCompose(), frodo2.solutionSpaces.hypercube.tests.HypercubeIterBestFirstTest.testMaximize(), and frodo2.solutionSpaces.hypercube.tests.HypercubeIterBestFirstTest.testMinimize().

◆ maximize

boolean frodo2.solutionSpaces.hypercube.tests.HypercubeTest.maximize

This variable is used to choose between maximising and minimising during the tests.

Referenced by setUp(), testApplyProjectRandom(), testBlindProjectRandom(), testConsensusWeighted(), testProjectAllRandom(), testProjectionRandom(), testProjOutputRandom(), and testProjOutputRandom2().


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