com.opttek.optquest
Class COptQuestVariable

java.lang.Object
  extended bycom.opttek.optquest.COptQuestVariable
Direct Known Subclasses:
COptQuestContinuousVariable, COptQuestDiscountRateVariable, COptQuestDiscreteVariable, COptQuestPermutationVariable, COptQuestUserControlledVariable

public class COptQuestVariable
extends java.lang.Object

COptQuestVariable is a pure virtual class that defines a decision variable.


Constructor Summary
COptQuestVariable()
          Default constructor
COptQuestVariable(double lowerBound, double upperBound)
          Constructor that sets the lower bound and upper bound.
COptQuestVariable(java.lang.String name)
          Constructor that assigns a name to the variable.
COptQuestVariable(java.lang.String name, double lowerBound, double upperBound)
          Constructor that assigns a name to the variable and sets the lower bound and upper bound.
 
Method Summary
 double GetBestValue()
          Used to retrieve the value of the variable for the solution that produced the best objective value.
 double GetCurrentValue()
          Used to retrieve the current solution value for the variable.
 double GetCurrentValue(int pID)
          Used to retrieve the current solution value for the variable when using parallel optimzation.
 double GetExclusiveLowerBoundAt(int index)
          Returns the lower bound of the exclusive range identified by the index
 double GetExclusiveUpperBoundAt(int index)
          Returns the upper bound of the exclusive range identified by the index
 double GetLowerBound()
           
 java.lang.String GetName()
           
 double GetNthBestValue()
          Used to retrieve the value of the variable for the solution that produced the Nth best objective value.
 int GetNumberOfExclusiveRanges()
          Returns the number of exclusive ranges defined for this variable.
 int GetNumberOfObservations()
          Returns the number of elements in the observations array.
 int GetNumberOfPeriods()
          Returns the number of periods for project.
 double GetObservationAt(int index)
          Returns the value of the observation at the specified index.
 double[] GetObservations()
          Returns the array of observations set in the SetObservations() method
 double GetPeriodObservationAt(int periodNum, int index)
          Returns the value of the observations for the specified period and index
 double[] GetPeriodObservations(int periodNum)
          Returns the array of observations for the requested period.
 double GetStepSize()
           
 double GetSuggestedValue()
           
 java.lang.String GetType()
           
 double GetUpperBound()
           
 void SetCurrentValue(double Value)
          Method that sets the current value of the variable.
 void SetCurrentValue(int pID, double Value)
          Method that sets the current value of the variable when using parallel optimization.
 void SetExclusiveRange(double low, double high)
          Defines a range of values that will be excluded as possible solutions.
 void SetLowerBound(double lowerBound)
          Sets the lower bound of the decision variable
 void SetName(java.lang.String name)
          Assigns a name to the variable.
 void SetNumberOfPeriods(int numPeriods)
          Sets the number of periods in the project.
 void SetObservations(int numObservations, double[] observations)
          Sets the observations for the project.
 void SetPeriodObservations(int numObservations, int periodNum, double[] observations)
          Sets the observations by period for a portfolio optimization.
 void SetStepSize(double value)
           
 void SetSuggestedValue(double Value)
          Allows the user to suggest a solution by setting a suggested value for each variable.
 void SetUpperBound(double upperBound)
          Sets the upper bound of the decision variable
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

COptQuestVariable

public COptQuestVariable(java.lang.String name)
Constructor that assigns a name to the variable.

Parameters:
name - alphanumeric name. Note: the name can contain blanks or special characters. If the variable name is used in a COptQuestStringConstraint equation, the name should be enclosed in square brackets [] in the COptQuestStringConstraint string equation.

COptQuestVariable

public COptQuestVariable()
Default constructor


COptQuestVariable

public COptQuestVariable(java.lang.String name,
                         double lowerBound,
                         double upperBound)
Constructor that assigns a name to the variable and sets the lower bound and upper bound.

Parameters:
name - alphanumeric name. Note: the name can contain blanks or special characters. If the variable name is used in a COptQuestStringConstraint equation, the name should be enclosed in square brackets [] in the COptQuestStringConstraint string equation.
lowerBound - a value between -pow(2,31) and +pow(2,31)-1
upperBound - a value between -pow(2,31) and +pow(2,31)-1

COptQuestVariable

public COptQuestVariable(double lowerBound,
                         double upperBound)
Constructor that sets the lower bound and upper bound.

Parameters:
lowerBound - a value between -pow(2,31) and +pow(2,31)-1
upperBound - a value between -pow(2,31) and +pow(2,31)-1
Method Detail

SetCurrentValue

public void SetCurrentValue(double Value)
                     throws COptQuestException
Method that sets the current value of the variable. The user can call this method to modifiy a solution suggested by the OptQuest Engine or to set the value of a COptQuestUserControlledVariable whose value is always set by the user.

Parameters:
Value - - value of the variable
Throws:
COptQuestException

SetCurrentValue

public void SetCurrentValue(int pID,
                            double Value)
                     throws COptQuestException
Method that sets the current value of the variable when using parallel optimization. The user can call this method to modifiy a solution suggested by the OptQuest Engine or to set the value of a COptQuestUserControlledVariable whose value is always set by the user.

Parameters:
pID - parallel ID from COptQuestOptimization::Evaluate()
Value - - value of the variable
Throws:
COptQuestException

SetLowerBound

public void SetLowerBound(double lowerBound)
                   throws COptQuestException
Sets the lower bound of the decision variable

Parameters:
lowerBound - a value between -pow(2,31) and +pow(2,31)-1
Throws:
COptQuestException

SetUpperBound

public void SetUpperBound(double upperBound)
                   throws COptQuestException
Sets the upper bound of the decision variable

Parameters:
upperBound - a value between -pow(2,31) and +pow(2,31)-1
Throws:
COptQuestException

SetExclusiveRange

public void SetExclusiveRange(double low,
                              double high)
                       throws COptQuestException
Defines a range of values that will be excluded as possible solutions. Any value > low and < high will be excluded. Multiple ranges can be defined on one variable.

Parameters:
low - - any value > low will be excluded
high - - any value < high will be exluded
Throws:
COptQuestException

SetSuggestedValue

public void SetSuggestedValue(double Value)
Allows the user to suggest a solution by setting a suggested value for each variable. Calling COptQuestOptimization.AddSuggestedSolution() indicates the suggested solution is complete and should be added to the set of solutions to be evaluated.

Parameters:
Value - - suggested value for this variable.

SetName

public void SetName(java.lang.String name)
Assigns a name to the variable. Names must be alphanumeric and cannot be a function name recognized by the COptQuestEquationSolver.

Parameters:
name - = name of the variable.

GetCurrentValue

public double GetCurrentValue()
                       throws COptQuestException
Used to retrieve the current solution value for the variable. This value should be used in COptQuestOptmization.Evaluate() to calculate the objective of the optmization.

Returns:
- current solution value.
Throws:
COptQuestException

GetCurrentValue

public double GetCurrentValue(int pID)
                       throws COptQuestException
Used to retrieve the current solution value for the variable when using parallel optimzation. The pID parameter is the value from COptQuestOptimization.Evaluate(). This current solution value should be used in COptQuestOptmization.Evaluate() to calculate the objective of the optmization.

Parameters:
pID - parallel ID from the COptQuestOptimization.Evaluate() method
Returns:
the current solution value for this variable
Throws:
COptQuestException

GetBestValue

public double GetBestValue()
Used to retrieve the value of the variable for the solution that produced the best objective value.

Returns:
- value of the variable associated with the best solution.

GetLowerBound

public double GetLowerBound()

GetUpperBound

public double GetUpperBound()

GetSuggestedValue

public double GetSuggestedValue()

GetName

public java.lang.String GetName()

GetType

public java.lang.String GetType()

GetStepSize

public double GetStepSize()

GetNumberOfExclusiveRanges

public int GetNumberOfExclusiveRanges()
Returns the number of exclusive ranges defined for this variable. Each call to COptQuestVariable.SetExclusiveRange() defines one range.

Returns:
- the number of exclusive ranges defined for this variable.

GetExclusiveLowerBoundAt

public double GetExclusiveLowerBoundAt(int index)
Returns the lower bound of the exclusive range identified by the index

Parameters:
index - 0 based index
Returns:
lower bound of the exclusive range identified by the index

GetExclusiveUpperBoundAt

public double GetExclusiveUpperBoundAt(int index)
Returns the upper bound of the exclusive range identified by the index

Parameters:
index - 0 based index
Returns:
upper bound of the exclusive range identified by the index

GetNthBestValue

public double GetNthBestValue()
Used to retrieve the value of the variable for the solution that produced the Nth best objective value. The Nth best solution is identified by calling COptQuestOptimization::SetNthBest()

Returns:
the variable's value for the Nth best solution.

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 obeservations for this project.

GetObservationAt

public double GetObservationAt(int index)
                        throws COptQuestException
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.
Throws:
COptQuestException

GetPeriodObservationAt

public double GetPeriodObservationAt(int periodNum,
                                     int index)
                              throws COptQuestException
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
Throws:
COptQuestException

SetNumberOfPeriods

public void SetNumberOfPeriods(int numPeriods)
                        throws COptQuestException
Sets the number of periods in the project.

Parameters:
numPeriods - - value > 0
Throws:
COptQuestException

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

SetStepSize

public void SetStepSize(double value)
                 throws COptQuestException
Throws:
COptQuestException