Reasoner
Class SimulationEngine

java.lang.Object
  |
  +--Reasoner.SimulationEngine

public class SimulationEngine
extends java.lang.Object

Provides the framework for running the simulation that was set up by all the previous processing stages.

Version:
Created 5 September 2003
Author:
Dan Tappan
See Also:
StaticReasoner, SimulationEngine, DynamicReasoner, MonteCarloRunSet, ObjectTemplateSet

Field Summary
private  java.util.ArrayList m_monte_carlo_run_sets
           
private  ObjectTemplateSet m_object_template_set
           
private  java.lang.String m_simulation_name
           
private  StaticReasoner m_static_reasoner
           
 
Constructor Summary
SimulationEngine(java.lang.String simulation_name, StaticReasoner static_reasoner)
          Creates a new simulator.
 
Method Summary
private  Dimensions computeDimensions(ObjectTemplate object_template, boolean force_determinism)
          Returns the randomly selected dimensions based on the definition of their plausibility intervals and associated attribute interval node in an object template.
private  double computeNondeterministicDimensionValue(PlausibilityInterval plausibility_interval, boolean force_determinism)
          Returns a randomly selected dimension value based on the definition in a plausibility interval and its associated attribute interval node (i.e., center, variance, bandpass).
private  Dimensions computeProportionedDimensions(ObjectTemplate object_template, double height, double width, double depth)
          Returns the dimensions proportioned such that a change in one dimension affects the other two dimensions.
 java.util.ArrayList getMonteCarloRunSets()
          Returns the Monte Carlo run sets generated by this simulation.
 java.lang.String getName()
          Returns the name of this simulation.
 ObjectTemplateSet getObjectTemplateSet()
          Returns the object template set supporting this simulation engine.
 StaticReasoner getStaticReasoner()
          Returns the static reasoner supporting this simulation engine.
private  void simulate(boolean force_determinism, int num_simulations, int max_partition_iterations, int max_partition_backtracks, boolean generate_inferences)
          Runs a Monte Carlo simulation over the object templates to produce sets of interpretations.
 void simulate(int num_simulations, int max_partition_iterations, int max_partition_backtracks, boolean force_determinism, boolean generate_inferences)
          Runs a Monte Carlo simulation over the object templates to produce sets of interpretations.
 void simulate(int num_simulations, int max_partition_iterations, int max_partition_backtracks, boolean force_determinism, boolean generate_inferences, long random_seed)
          Runs a Monte Carlo simulation over the object templates to produce sets of interpretations.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_simulation_name

private java.lang.String m_simulation_name

m_object_template_set

private ObjectTemplateSet m_object_template_set

m_static_reasoner

private StaticReasoner m_static_reasoner

m_monte_carlo_run_sets

private java.util.ArrayList m_monte_carlo_run_sets
Constructor Detail

SimulationEngine

public SimulationEngine(java.lang.String simulation_name,
                        StaticReasoner static_reasoner)
Creates a new simulator.

Parameters:
simulation_name - - the simulation name
static_reasoner - - this static reasoner contributing to this simulation engine
Method Detail

computeDimensions

private Dimensions computeDimensions(ObjectTemplate object_template,
                                     boolean force_determinism)
                              throws java.lang.Exception
Returns the randomly selected dimensions based on the definition of their plausibility intervals and associated attribute interval node in an object template.

Parameters:
object_template - - the defining object template
force_determinism - - whether the random-number component of the calculation is disabled
Returns:
the dimensions
Throws:
java.lang.Exception - - if the dimensions cannot be computed
See Also:
computeProportionedDimensions(Reasoner.ObjectTemplate, double, double, double), computeNondeterministicDimensionValue(KnowledgeBase.PlausibilityInterval, boolean)

computeNondeterministicDimensionValue

private double computeNondeterministicDimensionValue(PlausibilityInterval plausibility_interval,
                                                     boolean force_determinism)
                                              throws java.lang.Exception
Returns a randomly selected dimension value based on the definition in a plausibility interval and its associated attribute interval node (i.e., center, variance, bandpass). This is normally called for each dimension property (i.e., height, width, and depth).

Parameters:
plausibility_interval - - the plausibility interval defining the value computation
force_determinism - - whether the random-number component of the calculation is disabled
Returns:
the value
Throws:
java.lang.Exception - - if the dimension cannot be computed
See Also:
computeDimensions(Reasoner.ObjectTemplate, boolean), AttributeIntervalNode, PlausibilityInterval.getCenteredRandomValue(double, double, double), PlausibilityInterval.getBoundFixedValue(int)

computeProportionedDimensions

private Dimensions computeProportionedDimensions(ObjectTemplate object_template,
                                                 double height,
                                                 double width,
                                                 double depth)
Returns the dimensions proportioned such that a change in one dimension affects the other two dimensions. The degree of correlation is defined by the last term of the plausibility interval.

Parameters:
object_template - - the defining object template
height - - the unproportioned height
width - - the unproportioned width
depth - - the unproportioned depth
Returns:
the proportioned dimensions
See Also:
computeDimensions(Reasoner.ObjectTemplate, boolean)

getMonteCarloRunSets

public java.util.ArrayList getMonteCarloRunSets()
Returns the Monte Carlo run sets generated by this simulation.

Returns:
the run sets, or null if the simulation has not been run

getName

public java.lang.String getName()
Returns the name of this simulation.

Returns:
the name

getObjectTemplateSet

public ObjectTemplateSet getObjectTemplateSet()
Returns the object template set supporting this simulation engine.

Returns:
the object template set

getStaticReasoner

public StaticReasoner getStaticReasoner()
Returns the static reasoner supporting this simulation engine.

Returns:
the semantic network

simulate

public void simulate(int num_simulations,
                     int max_partition_iterations,
                     int max_partition_backtracks,
                     boolean force_determinism,
                     boolean generate_inferences)
              throws java.lang.Exception
Runs a Monte Carlo simulation over the object templates to produce sets of interpretations. The centralized random-number generator is seeded with the system clock to produce differing results from nondeterministic runs.

Parameters:
num_simulations - - the number of simulations to run
max_partition_iterations - - the maximum number of propagation attempts per partition before backtracking
max_partition_backtracks - - the maximum number of backtracks to earlier partitions
force_determinism - - whether the random-number component of the dimensions calculations is disabled
generate_inferences - - whether inferences should be generated
Throws:
java.lang.Exception - - if the simulation fails

simulate

public void simulate(int num_simulations,
                     int max_partition_iterations,
                     int max_partition_backtracks,
                     boolean force_determinism,
                     boolean generate_inferences,
                     long random_seed)
              throws java.lang.Exception
Runs a Monte Carlo simulation over the object templates to produce sets of interpretations. The centralized random-number generator is seeded with the given value to produce reproducible results from deterministic runs.

Parameters:
num_simulations - - the number of simulations to run
max_partition_iterations - - the maximum number of propagation attempts per partition before backtracking
max_partition_backtracks - - the maximum number of backtracks to earlier partitions
force_determinism - - whether the random-number component of the dimensions calculations is disabled
generate_inferences - - whether inferences should be generated
random_seed - - the random seed
Throws:
java.lang.Exception - - if the simulation fails

simulate

private void simulate(boolean force_determinism,
                      int num_simulations,
                      int max_partition_iterations,
                      int max_partition_backtracks,
                      boolean generate_inferences)
               throws java.lang.Exception
Runs a Monte Carlo simulation over the object templates to produce sets of interpretations.

Parameters:
force_determinism - - whether the random-number component of the dimensions calculations is disabled
num_simulations - - the number of simulations to run
max_partition_iterations - - the maximum number of propagation attempts per partition before backtracking
max_partition_backtracks - - the maximum number of backtracks to earlier partitions
generate_inferences - - whether inferences should be generated
Throws:
java.lang.Exception - - if the simulation fails

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String)