Class FlowSpec

java.lang.Object
ca.spatial.patchworks.FlowSpec

public class FlowSpec extends Object
This class contains a specification of how to set flow targets. These objects can be used with the methods in the Control object that create FlowAccounts.

The object created with the constructor will initially not have any periods selected for comparison. Use the object methods to set up the comparison logic.

The following example will set up an even flow objective to compare all periods to the specified period:

 flow = new FlowSpec().even();
 
This will not include period 0 (the period prior to the start of the simulation) since the common idiom is to use even flow for harvest products, which do not occur in period 0. In order to include period 0, use
 flow = new FlowSpec().even(0, periods, periods);
 

In order to set up a non-declining type of comparison, use one of the ndy methods. These require an offset value to specify which periods should be compared to. The following example compares to the previous period for the last 5 period. This would be typical for a non-delining closing inventory constraint:

 flow = new FlowSpec().ndy(periods-4, periods, -1);
 

The methods may be chained together to make more complex relationships. The following example compares the first four period for evenflow, and the rest for a separate evenflow level:

 flow = new FlowSpec().even(1,2,2).even(3,periods,periods);
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a FlowSpec object, initially with all periods not being compared to anything.
  • Method Summary

    Modifier and Type
    Method
    Description
    Set all periods to compare to the final period.
    even​(int anchor)
    Set all periods to compare to the same anchor period.
    even​(int low, int high, int anchor)
    Set selected periods to compare to the same anchor period.
    int[]
    Return a reference to the internal array of flow periods.
    incrementFrom​(int start)
    Set to calculate the increment from period to period, starting with start period.
    ndy​(int offset)
    Set all periods to compare to the period with the same offset.
    ndy​(int low, int high, int offset)
    Set selected periods to compare to the period with the same offset.
    nop()
    Set all periods to not compare
    nop​(int period)
    Set a single period to not compare
    nop​(int low, int high)
    Set selected periods to not be compared.
    pass​(int period)
    Pass a value from the input account unchanged.
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FlowSpec

      public FlowSpec()
      Create a FlowSpec object, initially with all periods not being compared to anything.
  • Method Details

    • getFlowPeriods

      public int[] getFlowPeriods()
      Return a reference to the internal array of flow periods. Changes that are made to this array will change the FlowSpec.
    • even

      public FlowSpec even()
      Set all periods to compare to the final period. This method has the same effect as
       even(0, periods, periods);
       
    • even

      public FlowSpec even(int anchor)
      Set all periods to compare to the same anchor period. This method has the same effect as
       even(0, periods, anchor);
       
      Parameters:
      anchor - The period for all other periods to compare to
    • even

      public FlowSpec even(int low, int high, int anchor)
      Set selected periods to compare to the same anchor period. All periods between low and high inclusive are set to compare to the anchor period.
      Parameters:
      low - the lowest period to set
      high - the highest period to set
      anchor - The period for all other periods to compare to
    • ndy

      public FlowSpec ndy(int offset)
      Set all periods to compare to the period with the same offset. This method has the same effect as
       ndy(0, periods, offset);
       
      Parameters:
      offset - The offset for all other periods to compare to
    • ndy

      public FlowSpec ndy(int low, int high, int offset)
      Set selected periods to compare to the period with the same offset. All periods between low and high inclusive are set to compare to the offset period.
      Parameters:
      low - the lowest period to set
      high - the highest period to set
      offset - The offset to the period to compare to
    • nop

      public FlowSpec nop()
      Set all periods to not compare
    • nop

      public FlowSpec nop(int period)
      Set a single period to not compare
      Parameters:
      period - the period that will not be compared
    • nop

      public FlowSpec nop(int low, int high)
      Set selected periods to not be compared. All periods between low and high inclusive are set to not compare. to the offset period.
      Parameters:
      low - the lowest period to set
      high - the highest period to set
    • pass

      public FlowSpec pass(int period)
      Pass a value from the input account unchanged. This option is only appropriate for FlowValueTarget.
      Parameters:
      period - the period that should have the unchanged value
    • incrementFrom

      public FlowSpec incrementFrom(int start)
      Set to calculate the increment from period to period, starting with start period. Periods earlier than the start period will show zero values. The start period will show the value of start period of the input account, and all remaining periods will show the increment from the previous period.
    • toString

      public String toString()
      Overrides:
      toString in class Object