* @param randomWalkGenerator random number generator to be used in walk generation.
*/
public void chooseStatePairs_internal(double threshold, double scale, int ThreadNumber,
final Class<? extends DetermineDiagonalAndRightHandSideInterface> ddrh, StatesToConsider filter, StateBasedRandom randomWalkGenerator)
{
GDLearnerGraph ndGraph = new GDLearnerGraph(coregraph, filter, false);
switch(coregraph.config.getGdScoreComputationAlgorithm())
{
case SCORE_RANDOMPATHS:
case SCORE_TESTSET:
// build (1) deterministic machines for each state and (2) walks from each state.
ndGraph.computeWalkSequences(randomWalkGenerator, ThreadNumber);
break;
case SCORE_LINEAR:
break;
default:
throw new IllegalArgumentException("computation algorithm "+coregraph.config.getGdScoreComputationAlgorithm()+" is not currently supported");
}
final int [] incompatiblePairs = new int[ndGraph.getStateNumber()*(ndGraph.getStateNumber()+1)/2];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=GDLearnerGraph.PAIR_OK;
final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,ThreadNumber);
LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, ThreadNumber,ddrh);
solver.solve(ThreadNumber);
solver.freeAllButResult();// deallocate memory before creating a large array.
coregraph.pairsAndScores.clear();
// now fill in the scores in the array.
for(int i=0;i<incompatiblePairs.length;++i)
{
int index = incompatiblePairs[i];
if (index >= 0)
{
double value = solver.j_x[incompatiblePairs[i]];
if (value > threshold) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*value), 0));
}
else // PAIR_INCOMPATIBLE
if (threshold < GDLearnerGraph.PAIR_INCOMPATIBLE) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*GDLearnerGraph.PAIR_INCOMPATIBLE), 0));
}
}