Package ca.spatial.patchworks
Class Horizon
java.lang.Object
ca.spatial.patchworks.Horizon
This class keeps track of the length of the planning horizon
and the division into planning period intervals. This is a
pure static class that is initialized by the Control object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int[]
static int[]
static int
static float[]
static int[]
static double[]
static double[]
static int[]
static int
static int[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
discount(double rate)
Return an array having discount values for the time mid-points of each planning period.static double[]
discount(double rate, int startYear)
Return an array having discount values for the time mid-points of each planning period.static double[]
factors(double factor)
Return an array that is the length of the planning period (plus time 0) with all array entries having the factor value.static double[]
factors(double[] factors)
Return an array that is the length of the planning period (plus time 0) with array entries being assigned from the input factors array.static double[]
factors(double[][] factors)
Return an array that is the length of the planning period (plus time 0) with array entries being assigned from the input factors array.static boolean
Identifies if the horizon has been initialized.static int
getPeriodForYear(int year)
Return the period that the year falls in to.static int
Return the number of planning periods (not including time 0)static double[]
productOfFactors(double[] f1, double f2)
Return an array that is the product of an input array and a scalar.static double[]
productOfFactors(double[] f1, double[] f2)
Return an array that is the product of the two input arrays.static int
setHorizon(int[] intervals)
Iniitalize the planning horizon to list of variable width periods.static int
setHorizon(int periods, int interval)
Initialize the planning horizon to be a specified number of fixed width periods.static String
simplifyFactors(double[] factors)
Return a string having the factor values in their most simplified form.static String
simplifyFactors(double[] factors, boolean round)
static String
simplifyTable(double[] factors)
Return an HTML string having the factor values in a compact table format
-
Field Details
-
periodList
public static int[] periodList -
activeList
public static int[] activeList -
periods
public static int periods -
horizon
public static int horizon -
lookup
public static int[] lookup -
census
public static int[] census -
intervals
public static float[] intervals -
periodWidths
public static int[] periodWidths -
oneFactors
public static double[] oneFactors -
negoneFactors
public static double[] negoneFactors
-
-
Constructor Details
-
Horizon
public Horizon()
-
-
Method Details
-
setHorizon
public static int setHorizon(int periods, int interval)Initialize the planning horizon to be a specified number of fixed width periods. -
setHorizon
public static int setHorizon(int[] intervals)Iniitalize the planning horizon to list of variable width periods. -
getIsInitialized
public static boolean getIsInitialized()Identifies if the horizon has been initialized. -
getPeriods
public static int getPeriods()Return the number of planning periods (not including time 0) -
getPeriodForYear
public static int getPeriodForYear(int year)Return the period that the year falls in to. -
factors
public static double[] factors(double factor)Return an array that is the length of the planning period (plus time 0) with all array entries having the factor value.- Parameters:
factor
- the value to assign to all array cells
-
factors
public static double[] factors(double[] factors)Return an array that is the length of the planning period (plus time 0) with array entries being assigned from the input factors array. Each position in the input factors array contains a value for one planning period. If the input array does not have enough values then the reamining positions are filled with the last value. If the input array has too many values then the excess are ignored.- Parameters:
factors
- the values to assign to the array cells
-
factors
public static double[] factors(double[][] factors)Return an array that is the length of the planning period (plus time 0) with array entries being assigned from the input factors array. Each position in the input values array contains an array of two values: a repetition count and the value to assign. Array positions are filled up with the value to assign according to the repetition count. After the repetition is used up the process advances to the next input pair. If the input array does contain enough repetitions then the reamining positions are filled with the last value. If the input array has too many values then the excess are ignored.- Parameters:
factors
- the repetition count, value pairs to assign to the array cells
-
productOfFactors
public static double[] productOfFactors(double[] f1, double[] f2)Return an array that is the product of the two input arrays.- Parameters:
f1
- the first input arrayf2
- the second input array
-
productOfFactors
public static double[] productOfFactors(double[] f1, double f2)Return an array that is the product of an input array and a scalar.- Parameters:
f1
- the input arrayf2
- the scalar value
-
discount
public static double[] discount(double rate)Return an array having discount values for the time mid-points of each planning period.- Parameters:
rate
- the discount rate as a fraction
-
discount
public static double[] discount(double rate, int startYear)Return an array having discount values for the time mid-points of each planning period.- Parameters:
rate
- the discount rate as a fraction
-
simplifyFactors
Return a string having the factor values in their most simplified form. If all factor values are the same then return a single number. Otherwise return a list of with any trailing repeated values truncated. -
simplifyFactors
-
simplifyTable
Return an HTML string having the factor values in a compact table format
-