Class COptQuestProjectVariable

Direct Known Subclasses:
COptQuestDiscountRateVariable

public class COptQuestProjectVariable extends COptQuestContinuousVariable
The COptQuestProjectVariable class defines a portfolio project variable that is used in portfolio optimization. A COptQuestProjectVariable is defined for each project in the portfolio.

Typically, a project decision variable is defined with a lower bound of 0 and an upper bound of 1 and its value represents the percentage of investment in that project.
Portfolio optimization supports 3 types of project investment.
  • Case 1: The project can be funded at any level between the lower bound and the upper bound.
  • Case 2: The project must be funded above a certain percentage or not at all.
  • Case 3: The project must be funded 100% or not at all.
For case 1 the lower bound and the upper bound define the range of investment.
For case 2, the lower bound is set to 0 and the SetExclusiveRange(double, double) method is used to define the range of variables that must be excluded from the solution. For example, if a project's funding can be 0 or any value greater than .25 (25%), you would define the lower bound as 0, the upper bound as 1 and define an exclusive range between 0 and .25. (0 and .25 will be included as possible solutions.)
For case 3, the project is defined with a low bound of 0, a high bound of 1 and an exclusive range of 0 to 1. (0 and 1 will be included as possible solutions.)

A COptQuestProjectVariable has a set of observations that are either simulated values or sampled values. If there is only one observation, it represents a single known value for the project. Note that some statistics, such as standard deviation, require more than one observation.

The observation values sent to the OptQuest Engine can be either: Net Present Values (NPV) or cash flow by period.

If the measure used is NPV, the project's NPV for each observation can be calculated. Other measures such as Internal Rate of Return (IRR) and Pay Back Period (PBP), require the cash flow for each period. If you are using Internal Rate of Return or Pay Back Period, you should set the cash flow observations for each period.

Portfolio analysis of Net Present Value can use either NPV observations or cash flow by period observations. If the portfolio analysis only uses Net Present Value, it is more efficient to use the NPV observation. However, if different measures are used in the portfolio analysis, the Cash Flow by period per observation can be used for all measures, including NPV.

Observations can be associated with the COptQuestProjectVariable by calling the SetObservations(int, double[]) method. The observations are used to calculate statistical measures and in searching for possible solutions.

The SetNumberOfPeriods(int) method sets the number of periods in the project. Project variables in an optimization do not need to have the same numbers of periods, however, periods between project variables must correspond to the same period number.

The SetPeriodObservations(int, int, double[]) method sets the observations for a particular period. It is not necessary to set observations for every period. If there are no observations for a particular period of a project, the OptQuest Engine assumes the cash flow for that period was zero. This is useful for projects that start after the first period or end before the last period.
  • Constructor Details

    • COptQuestProjectVariable

      public COptQuestProjectVariable(String name, double lowerBound, double upperBound)
    • COptQuestProjectVariable

      public COptQuestProjectVariable(double lowerBound, double upperBound)
      Constructor that assigns the lower bound and the upper bound for the project.
      Parameters:
      lowerBound - typically 0 representing 0%
      upperBound - typically 1 representing 100%
    • COptQuestProjectVariable

      public COptQuestProjectVariable()
      Default constructor
  • Method Details

    • SetObservations

      public void SetObservations(int numObservations, double[] observations)
      Sets the observations for the project.
      Parameters:
      numObservations - - number of entries in the observations array
      observations - - array representing the observations for the project.
    • GetNumberOfObservations

      public int GetNumberOfObservations()
      Returns the number of elements in the observations array.
      Returns:
      - number of observations. Value was set by the SetObservations() method.
    • GetObservations

      public double[] GetObservations()
      Returns the array of observations set in the SetObservations() method
      Returns:
      array of doubles representing the observations for this project.
    • GetObservationAt

      public double GetObservationAt(int index)
      Returns the value of the observation at the specified index.
      Parameters:
      index - - value between 0 and the number of observations -1
      Returns:
      the value of the observation at the specified index.
    • GetPeriodObservationAt

      public double GetPeriodObservationAt(int periodNum, int index)
      Returns the value of the observations for the specified period and index
      Parameters:
      periodNum - - value between 1 and the total number of periods.
      index - - value between 0 and the number of observations -1
      Returns:
      the value of the observation at the specified period and index
    • SetNumberOfPeriods

      public void SetNumberOfPeriods(int numPeriods) throws COptQuestException
      Sets the number of periods in the project.
      Parameters:
      numPeriods - - value > 0
      Throws:
      COptQuestException - if a problem is encountered
    • GetNumberOfPeriods

      public int GetNumberOfPeriods()
      Returns the number of periods for project. Value was set by the SetNumberOfPeriods() method.
      Returns:
      the number of periods.
    • SetPeriodObservations

      public void SetPeriodObservations(int numObservations, int periodNum, double[] observations) throws COptQuestException
      Sets the observations by period for a portfolio optimization.
      Parameters:
      numObservations - - number of elements in the observations array
      periodNum - - identifies the period number. The value must be between 1 and the value set by the SetNumberOfPeriods() method.
      observations - - array representing the observations for the project.
      Throws:
      COptQuestException - if the number of observations for this period differs from the setting for another period.
    • GetPeriodObservations

      public double[] GetPeriodObservations(int periodNum) throws COptQuestException
      Returns the array of observations for the requested period. The observations for the period were set by the SetPeriodObservations() method. Returns null if no observations were defined for this period.
      Parameters:
      periodNum - - Number from 1 to number of periods set by SetNumberOfPeriods();
      Returns:
      array of observations
      Throws:
      COptQuestException - if a bad number of periods is specified