java.lang.Object
org.palladiosimulator.protocom.resourcestrategies.activeresource.AbstractDemandStrategy
All Implemented Interfaces:
IDemandStrategy
Direct Known Subclasses:
CalculatePrimesDemand, CountNumbersDemand, FFTDemand, FibonacciDemand, MandelbrotDemand, ReadLargeChunksDemand, SortArrayDemand, VoidDemand, WaitDemand

public abstract class AbstractDemandStrategy extends Object implements IDemandStrategy
Abstract superclass of all active demand strategies. c.f.: Steffen Becker, Tobias Dencker, and Jens Happe. Model-Driven Generation of Performance Prototypes. In Performance Evaluation: Metrics, Models and Benchmarks (SIPEW 2008), volume 5119 of Lecture Notes in Computer Science, pages 79-98. Springer-Verlag Berlin Heidelberg, 2008.
  • Field Details

    • WORKUNITS

      public static final javax.measure.unit.Unit<AbstractDemandStrategy.Work> WORKUNITS
    • CALIBRATION_PATH_CONFIG_KEY

      public static final String CALIBRATION_PATH_CONFIG_KEY
      See Also:
    • defaultIterationCount

      protected long defaultIterationCount
      Iteration count for calibration
    • degreeOfAccuracy

      protected DegreeOfAccuracyEnum degreeOfAccuracy
  • Constructor Details

    • AbstractDemandStrategy

      public AbstractDemandStrategy(int low, int medium, int high, int iterationCount, int warmups)
      Constructor. Configures a demand strategy with low, medium and high modifier, as well as number of standard and warm-up cycles
      Parameters:
      low - accuracy modifier for low precision calibration
      medium - accuracy modifier for medium precision calibration
      high - accuracy modifier for high precision calibration
      iterationCount -
      warmups -
  • Method Details

    • initializeStrategy

      public void initializeStrategy(DegreeOfAccuracyEnum degree, double initProcessingRate)
      Description copied from interface: IDemandStrategy
      Initialize the strategy and perform necessary calibrations
      Specified by:
      initializeStrategy in interface IDemandStrategy
      Parameters:
      degree - The degree of accuracy used for calibration: HIGH, MEDIUM, LOW WARNING: The use of HIGH can result in a significant increase in the execution time
      initProcessingRate - [units/seconds] The rate to initialize with (demand/processingRate = time)
      See Also:
    • initializeStrategy

      public void initializeStrategy(DegreeOfAccuracyEnum degreeOfAccuracy, double processingRate, String calibrationPath)
      Description copied from interface: IDemandStrategy
      Initialize the strategy and perform necessary calibrations
      Specified by:
      initializeStrategy in interface IDemandStrategy
      Parameters:
      degreeOfAccuracy - The degree of accuracy used for calibration: HIGH, MEDIUM, LOW WARNING: The use of HIGH can result in a significant increase in the execution time
      processingRate - [units/seconds] The rate to initialize with (demand/processingRate = time)
      calibrationPath - Path where the calibration is stored
      See Also:
    • setProperties

      public void setProperties(Properties properties)
      Description copied from interface: IDemandStrategy
      Do not use default properties, but set properties externally.
      Specified by:
      setProperties in interface IDemandStrategy
      See Also:
    • consume

      public void consume(double demand)
      Description copied from interface: IDemandStrategy
      Consume a resource according to its demand & processing rate(specified in initaliseStrategy) WARNING: initializeStrategy() has to be run first
      Specified by:
      consume in interface IDemandStrategy
      Parameters:
      demand - [units] The demand to consume
      See Also:
    • getStrategysResource

      public abstract ResourceTypeEnum getStrategysResource()
      Template method to return the real hardware resource type simulated by this strategy
      Specified by:
      getStrategysResource in interface IDemandStrategy
      Returns:
      The resource type we can simulate
      See Also:
    • getName

      public abstract String getName()
      Template method to return the name of this strategy
      Specified by:
      getName in interface IDemandStrategy
      Returns:
      a string containing the name of the strategy
      See Also:
    • getCalibrationFileName

      protected String getCalibrationFileName()
      Returns the name of the file used to store the calibration table Filename depends on paramters of this class
      Returns:
      The calibration table file name
    • getCalibrationPath

      protected File getCalibrationPath()
      Query the calibration path from the properties of this object
      Returns:
      The file system path used to load and store the calibration data, or the current working directory if it is not set
    • run

      protected abstract void run(long load)
      Template method. This starts running the strategy with the parameter load
      Parameters:
      load - Complexity parameter. Algorithm should take longer if parameter is larger, i.e., ideally run(a) < run(b) <==> a < b
    • ensureCalibrationExists

      public void ensureCalibrationExists()
      Specified by:
      ensureCalibrationExists in interface IDemandStrategy
    • calibrate

      public CalibrationTable calibrate()
      Create a new calibration table for this host by measuring the execution times of our algorithm and creating an according calibration table
      Specified by:
      calibrate in interface IDemandStrategy
      Returns:
      a calibration table containing the results of the calibration
    • setCalibrationListener

      public void setCalibrationListener(ICalibrationListener listener)
      Description copied from interface: IDemandStrategy
      Sets the calibration listener that receives progress updates during the calibration.
      Specified by:
      setCalibrationListener in interface IDemandStrategy
      Parameters:
      listener - the calibration listener to receive the updates
    • setCalibrationTable

      public void setCalibrationTable(CalibrationTable table)
      Description copied from interface: IDemandStrategy
      Sets the calibration table.
      Specified by:
      setCalibrationTable in interface IDemandStrategy
      Parameters:
      table - the calibration table
    • hasCalibrationTable

      public boolean hasCalibrationTable()
      Description copied from interface: IDemandStrategy
      Checks whether the strategy has a calibration table.
      Specified by:
      hasCalibrationTable in interface IDemandStrategy
      Returns:
      true if the strategy has a calibration table, otherwise false
    • setDebug

      public void setDebug(boolean enable)
      Description copied from interface: IDemandStrategy
      Enables or disables debug mode. When debug mode is enabled, the calibration returns dummy results instead of actually calibrating the strategy.
      Specified by:
      setDebug in interface IDemandStrategy
      Parameters:
      enable - true if debug mode should be enabled, otherwise false
    • debugEnabled

      public boolean debugEnabled()
      Description copied from interface: IDemandStrategy
      Checks whether debug mode is enabled.
      Specified by:
      debugEnabled in interface IDemandStrategy
      Returns:
      true if debug mode is enabled, otherwise false
    • watchConsume

      @Deprecated public void watchConsume(double demand)
      Deprecated.
      Consumes demands (only used for testing purpose!)
      Parameters:
      demand -
    • formatDuration

      public static String formatDuration(org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> t)