picsou.pricing
Class PricingSimulator

java.lang.Object
  extended by picsou.pricing.PricingSimulator
All Implemented Interfaces:
Simulator
Direct Known Subclasses:
EuropeanBarrier, EuropeanSimple, PricingSimulatorTree

public abstract class PricingSimulator
extends java.lang.Object
implements Simulator


Field Summary
protected  double a1
           
protected  double a2
           
protected  Algorithm alg
           
protected  Asset asset
           
protected  double deltaT
           
protected  Random generator
           
protected  int itsPerPacket
           
protected  Log log
           
protected  int offloadedIts
           
protected  double riskFreeRateDiscount
           
protected  State state
           
protected  int timeIntervals
           
 
Constructor Summary
PricingSimulator()
           
 
Method Summary
 org.objectweb.proactive.core.util.wrapper.BooleanWrapper autorun(Simulator parent)
          Ask the simulator to run, pulling tasks from sim and merging them back in as they complete.
 Algorithm getAlg()
           
 Asset getAsset()
           
abstract  OptionSet getDefaultOptionSet()
           
 OptionSet getOptionSet()
          Returns the OptionSet entry state: any exit state: unchanged
 Price getPrice()
           
 State getState()
          Returns the current state entry state: any exit state: unchanged
protected  org.apache.xml.serialize.OutputFormat getXMLFormatter()
           
abstract  void init(Algorithm alg, Asset asset)
          Sets up the Simulator with an algorithm and an asset.
 void init(OptionSet optionSet)
          Sets up the Simulator with an algorithm and an asset.
 void init(java.lang.String fileOrURL)
           
 void merge(Simulator sim)
          Adds the results of another simulator to this Simulator.
 org.objectweb.proactive.core.util.wrapper.IntWrapper offload(Simulator sim)
          Offer a number of the queued iterations to another simulator.
 void printAlgXML()
           
 void printAssetXML()
           
 void printOptionSet(java.io.OutputStream out)
           
 void reset()
          Resets Simulator to initial (cleared) state.
 void restart()
          Clears the current results to restart the Simulator with the original Algorithm and Asset (cleared of Performance and Price results).
 void seed(Simulator sim)
          Seeds the current Simulator from the state of another Simulator.
 void simulate()
          Do a simulation on the asset with the given parameters and using all remaining iterations entry state: READY or RUNNING exit state: DONE
 org.objectweb.proactive.core.util.wrapper.IntWrapper simulate(java.lang.Double simCount)
           
 org.objectweb.proactive.core.util.wrapper.IntWrapper simulate(java.lang.Integer simCount)
          Attempt to simulate up to "iterations", return actual number completed.
 org.objectweb.proactive.core.util.wrapper.IntWrapper simulate(org.objectweb.proactive.core.util.wrapper.IntWrapper simCount)
           
protected abstract  void unguardedMerge(Simulator sim)
           
protected  void unguardedRestart()
           
protected abstract  java.lang.Integer unguardedSimulate(java.lang.Integer simCount)
           
protected  void updateState()
           
protected abstract  void updateValues(java.lang.Double sumX, java.lang.Double sumXX, java.lang.Integer simCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alg

protected Algorithm alg

asset

protected Asset asset

state

protected State state

generator

protected Random generator

log

protected transient Log log

timeIntervals

protected int timeIntervals

itsPerPacket

protected int itsPerPacket

offloadedIts

protected int offloadedIts

deltaT

protected double deltaT

riskFreeRateDiscount

protected double riskFreeRateDiscount

a1

protected double a1

a2

protected double a2
Constructor Detail

PricingSimulator

public PricingSimulator()
Method Detail

init

public void init(java.lang.String fileOrURL)

init

public void init(OptionSet optionSet)
Description copied from interface: Simulator
Sets up the Simulator with an algorithm and an asset. entry state: ANY exit state: READY

Specified by:
init in interface Simulator

init

public abstract void init(Algorithm alg,
                          Asset asset)
Description copied from interface: Simulator
Sets up the Simulator with an algorithm and an asset. entry state: ANY exit state: READY

Specified by:
init in interface Simulator

simulate

public void simulate()
              throws InvalidStateException
Description copied from interface: Simulator
Do a simulation on the asset with the given parameters and using all remaining iterations entry state: READY or RUNNING exit state: DONE

Specified by:
simulate in interface Simulator
Throws:
InvalidStateException

simulate

public org.objectweb.proactive.core.util.wrapper.IntWrapper simulate(java.lang.Double simCount)
                                                              throws InvalidStateException
Throws:
InvalidStateException

simulate

public org.objectweb.proactive.core.util.wrapper.IntWrapper simulate(org.objectweb.proactive.core.util.wrapper.IntWrapper simCount)
                                                              throws InvalidStateException
Throws:
InvalidStateException

simulate

public org.objectweb.proactive.core.util.wrapper.IntWrapper simulate(java.lang.Integer simCount)
                                                              throws InvalidStateException
Description copied from interface: Simulator
Attempt to simulate up to "iterations", return actual number completed. Simulator will not simulate more than the total iterations set by the Algorithm, so the smaller of queuedIterations and requestedIterations will be passed to unguarded simulate. entry state: READY or RUNNING exit state: RUNNING or DONE

Specified by:
simulate in interface Simulator
Returns:
Integer
Throws:
InvalidStateException

autorun

public org.objectweb.proactive.core.util.wrapper.BooleanWrapper autorun(Simulator parent)
                                                                 throws InvalidStateException
Description copied from interface: Simulator
Ask the simulator to run, pulling tasks from sim and merging them back in as they complete. Returns "true" when done. Should never return "false". This is a PA artifact, since the returned object allows PA to hold a future to synchronise on. entry state: not INIT exit state: not INIT

Specified by:
autorun in interface Simulator
Throws:
InvalidStateException

offload

public org.objectweb.proactive.core.util.wrapper.IntWrapper offload(Simulator sim)
Description copied from interface: Simulator
Offer a number of the queued iterations to another simulator. Do not assume they will be completed (perhaps partial, perhaps none), so do not decrease any queued iteration count. Implementation may choose to count how many have been offloaded. entry state: READY or RUNNING exit state: unchanged

Specified by:
offload in interface Simulator

merge

public void merge(Simulator sim)
           throws InvalidStateException
Description copied from interface: Simulator
Adds the results of another simulator to this Simulator. Pre-conditions on "sim": RUNNING or DONE, Asset must be identical, except for "simulation" count. Pre-conditions on "this": READY or RUNNING, this.completedSimulations + sim.completedSimulations <= this.simulations entry state: READY or RUNNING exit state: RUNNING or DONE

Specified by:
merge in interface Simulator
Throws:
InvalidStateException

seed

public void seed(Simulator sim)
          throws InvalidStateException
Description copied from interface: Simulator
Seeds the current Simulator from the state of another Simulator. Currently this is synonymous with "this = sim.copyOf()" in that it creates a copy of the sim Simulator. entry state: ANY exit state: same as sim.state

Specified by:
seed in interface Simulator
Throws:
InvalidStateException

reset

public void reset()
Description copied from interface: Simulator
Resets Simulator to initial (cleared) state. entry state: ANY exit state: INIT

Specified by:
reset in interface Simulator

restart

public void restart()
             throws InvalidStateException
Description copied from interface: Simulator
Clears the current results to restart the Simulator with the original Algorithm and Asset (cleared of Performance and Price results). After restart(), simulate() or simulate(int) can be called. entry state: not INIT exit state: READY

Specified by:
restart in interface Simulator
Throws:
InvalidStateException

unguardedSimulate

protected abstract java.lang.Integer unguardedSimulate(java.lang.Integer simCount)
                                                throws InvalidStateException
Throws:
InvalidStateException

unguardedMerge

protected abstract void unguardedMerge(Simulator sim)
                                throws InvalidStateException
Throws:
InvalidStateException

unguardedRestart

protected void unguardedRestart()

updateValues

protected abstract void updateValues(java.lang.Double sumX,
                                     java.lang.Double sumXX,
                                     java.lang.Integer simCount)
                              throws InvalidStateException
Throws:
InvalidStateException

getXMLFormatter

protected org.apache.xml.serialize.OutputFormat getXMLFormatter()

printOptionSet

public void printOptionSet(java.io.OutputStream out)

printAlgXML

public void printAlgXML()

printAssetXML

public void printAssetXML()

updateState

protected void updateState()

getState

public State getState()
Description copied from interface: Simulator
Returns the current state entry state: any exit state: unchanged

Specified by:
getState in interface Simulator
Returns:
Price

getPrice

public Price getPrice()
               throws InvalidStateException
Throws:
InvalidStateException

getAlg

public Algorithm getAlg()

getAsset

public Asset getAsset()

getDefaultOptionSet

public abstract OptionSet getDefaultOptionSet()

getOptionSet

public OptionSet getOptionSet()
Description copied from interface: Simulator
Returns the OptionSet entry state: any exit state: unchanged

Specified by:
getOptionSet in interface Simulator
Returns:
OptionSet