Class CSTNRandomGenerator

java.lang.Object
it.univr.di.cstnu.util.CSTNRandomGenerator

public class CSTNRandomGenerator extends Object
Allows one to build random CSTN instances specifying:
 - # of wanted DC/NOT DC instances
 And the following parameters that characterize each generated instance:
 - # nodes
 - # propositions
 - # negative qLoops
 - # nodes in each qLoop
 - # observation nodes in each qLoop
 - max weight for each edge
 - probability to have an edge between any pair of nodes
 

The class generates the wanted instances, building each one randomly and then DC checking it for stating its DC property.

Version:
$Rev: 732 $
Author:
posenato
  • Field Details

  • Constructor Details

    • CSTNRandomGenerator

      public CSTNRandomGenerator(int givenDcInstances, int givenNotDCInstances, int nodes, int propositions, int qLoops, int nodesInQloop, int obsInQLoop, double edgeProbability, int givenMaxWeight)
      Parameters:
      givenDcInstances - the wanted DC instances.
      givenNotDCInstances - the wanted not-DC instances.
      nodes - the wanted number of nodes.
      propositions - the wanted number of propositions.
      qLoops - the wanted number of qLoops.
      nodesInQloop - the wanted number of nodes in each qLoop.
      obsInQLoop - the wanted number of observation nodes in each qLoop.
      edgeProbability - the probability of an edge between any pair of nodes.
      givenMaxWeight - the maximum weight for an edge.
      Throws:
      IllegalArgumentException - if one or more parameters has/have invalid value/s.
      IllegalArgumentException - if any.
  • Method Details

    • main

      public static void main(String[] args) throws FileNotFoundException, IOException
      Parameters:
      args - an array of String objects.
      Throws:
      FileNotFoundException - if any.
      IOException - if any.
    • setDifference

      static char[] setDifference(char[] s1, char[] s2)
      Parameters:
      s1 - first set
      s2 - second set
      Returns:
      an array that is the s1 / s2. s1 and s2 are not modified.
    • buildAPairRndCSTNInstances

      public ObjectPair<TNGraph<CSTNEdge>> buildAPairRndCSTNInstances(boolean alsoNotDcInstance)
      Builds a pair of DC and non-DC of CSTN instances using the building parameters. The non-DC instance is built by adding one or more constraints to the previously generated DC instance.
      Parameters:
      alsoNotDcInstance - false if the non-DC instances are required. If false, the returned non-DC instance is an empty TNGraph.
      Returns:
      a pair of DC and non-DC of CSTN instances. If the first member is null, it means that a generic error in the building has occurred. If alsoNotDcInstance is false, the returned not DC instance is null.
    • getDcInstances

      public int getDcInstances()
      Getter for the field dcInstances.
      Returns:
      the dcInstances
    • getEdgeProb

      public double getEdgeProb()
      Getter for the field edgeProb.
      Returns:
      the edgeProb
    • getMaxWeight

      public int getMaxWeight()

      Getter for the field maxWeight.

      Returns:
      the maxWeight
    • getNotDCInstances

      public int getNotDCInstances()
      Getter for the field notDCInstances.
      Returns:
      the notDCInstances
    • getNotDCSubDir

      public File getNotDCSubDir()
      Getter for the field notDCSubDir.
      Returns:
      the notDCSubDir
    • getVersionAndCopyright

      public String getVersionAndCopyright()
      Returns:
      version and copyright string
    • getnNodes

      public int getnNodes()
      Getter for the field nNodes.
      Returns:
      the nNodes
    • getnNodesQLoop

      public int getnNodesQLoop()
      Getter for the field nNodesQLoop.
      Returns:
      the nNodesQLoop
    • getnObsQLoop

      public int getnObsQLoop()
      Getter for the field nObsQLoop.
      Returns:
      the nObsQLoop
    • getnPropositions

      public int getnPropositions()
      Getter for the field nPropositions.
      Returns:
      the nPropositions
    • getnQLoops

      public int getnQLoops()
      Getter for the field nQLoops.
      Returns:
      the nQLoops