Package com.opttek.optquest
Class OptQuestSolution
java.lang.Object
com.opttek.optquest.OptQuestSolution
The class that defines a solution object for managing inputs, outputs, constraints, and objectives
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInternal OptTek use only.OptQuestSolution
(OptQuestModel opt, int id, com.opttek.optquest.COptQuestSolution csol) Internal OptTek use only.OptQuestSolution
(OptQuestModel opt, com.opttek.optquest.COptQuestSolution csol) Internal OptTek use only. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Used to supply solutions to the engine where the outputs have already been calculated.boolean
Used to supply "warm start" solutions to the engine.int
int
Returns the number of evaluated replications of a solution.int
Returns the replication number for this solution.This is the unique number assigned to a replication of a solution when it is first created and sent out for evaluation.double
Returns the value associated with the named Variable, Objective, or Constraint.boolean
Returns true if the solution has met confidence requirements when being evaluated in variable replication mode.boolean
Returns true if all of the replications for a solution have been completed.boolean
Returns true if the solution is a suggested solution with input values and output values.boolean
boolean
IsValid()
Call this method when using the Manual Optimization pattern to verify CreateSolution() has returned a valid solution.void
Print()
int
Reject()
Only used for Manual Optimization loops.boolean
Sets the value of a named input or output variable in an OptQuestSolution.int
Submit()
Only used for Manual Optimization loops.boolean
Update()
Only used for Manual Optimization loops.
-
Field Details
-
id
public final int id
-
-
Constructor Details
-
OptQuestSolution
public OptQuestSolution()Internal OptTek use only. -
OptQuestSolution
Internal OptTek use only. -
OptQuestSolution
Internal OptTek use only.
-
-
Method Details
-
IsValid
public boolean IsValid()Call this method when using the Manual Optimization pattern to verify CreateSolution() has returned a valid solution. If the optimization engine cannot generate a new solution (e.g., the feasible space is too small or has been exhaustively searched), it will return an empty solution with no valid values.- Returns:
- true if the solution has been successfully created, false if the model could not create a solution.
-
GetIteration
public int GetIteration()- Returns:
- - returns the iteration number OptQuest assigned to the solution. This is the unique number assigned to a solution when it is first created and sent out for evaluation. Multiple replications can have the same iteration number.
-
GetReplication
public int GetReplication()Returns the replication number for this solution.This is the unique number assigned to a replication of a solution when it is first created and sent out for evaluation. The replication number will be between 1 and the maximum number of replications.- Returns:
- Returns the replication number OptQuest assigned to the solution.
-
GetNumberOfCompletedReplications
public int GetNumberOfCompletedReplications()Returns the number of evaluated replications of a solution.- Returns:
- - number of evaluated replications.
-
IsEvaluated
public boolean IsEvaluated()Returns true if the solution is a suggested solution with input values and output values. The solution was added using the AddEvaluated() method which is used to supply solutions to the engine where the outputs have already been calculated.- Returns:
- true if the suggested solution was evaluated.
-
IsComplete
public boolean IsComplete()Returns true if all of the replications for a solution have been completed.- Returns:
- true if the solution has completed evaluation.
-
IsFeasible
public boolean IsFeasible()- Returns:
- true if the solution satisfies all constraints.
-
HasMetConfidence
public boolean HasMetConfidence()Returns true if the solution has met confidence requirements when being evaluated in variable replication mode. If confidence was set on multiple objectives, the method will return true if all objectives met the confidence criteria.- Returns:
- true if the solution met the replication confidence testing criteria
-
GetValue
Returns the value associated with the named Variable, Objective, or Constraint. If the requested value is not available in the solution, NaN is returned.
Additional parameters may be passed in as part of the name to retrieve specific information:
Outputs: if a solution has multiple replications, requesting the output by its name returns the aggregated value. To retrieve the value of a specific replication, add a ";#" to the name. For example, sol.GetValue("output") will retrieve the aggregated value of the variable named "output", sol.GetValue("output;2") will retrieve the value of the variable named "output" for replication #2.
Objectives: if a solution has multiple replications, requesting the objective by its name returns the aggregated value. To retrieve the value of a specific replication, add a ";#" to the name. For example, sol.GetValue("objective") will retrieve the aggregated value of the variable named "objective", sol.GetValue("objecitve;3") will retrieve the value of the objective named "objective" for replication #3.
Objectives: if variable replications are being used, OptQuest tracks the width of the confidence interval for each objective. To retrieve that width, append ";cw". For example sol.GetValue("objective;cw") will return the confidence width of the objective named "objective".
Constraints: If only the constraint name is requested, the feasibility of the constraint is returned. Additionally, constraints have two sides to the expression, the left and right, and may have multiple clauses. Each side of the constraint expression may be retrieved using a ";LHS;#" or ";RHS;#" suffix, where LHS is for the left side of the equation, and RHS is for the right side, and the number is the clause number, which is usually 1 except for complex constraints with "or" conditions. For example, consider this constraint named constraint1, input1-input2 < 3 or input2+input3 > 5-input2 sol.GetValue("constraint1") will return 1.0 if that constraint is feasible in the solution, 0.0 if it is infeasible sol.GetValue("constraint1;LHS;1") will return the value of input1-input2 sol.GetValue("constraint1;RHS;1") will return 3 sol.GetValue("constraint1;LHS;2") will return the value of input2+input3 sol.GetValue("constraint1;RHS;2") will return 5-input2- Parameters:
name
- - name of the object- Returns:
- - A double value representing the requested information, NaN if the information is not available.
- Throws:
com.opttek.optquest.COptQuestException
- - An exception is thrown if there was an error retrieving the value.
-
SetValue
Sets the value of a named input or output variable in an OptQuestSolution. This is primarily used to assign values to output variables during solution evaluation. However, clients can also override input variable values if needed.
This method is also used to set input values for suggested solutions.- Parameters:
name
- - name of the input or output variablevalue
- - value assigned to the input or output- Returns:
- true if the call was successful, false if there was an error such as a variable with the input name does not exist.
- Throws:
com.opttek.optquest.COptQuestException
- - An exception is thrown if there was an error setting the value.
-
Submit
public int Submit() throws com.opttek.optquest.COptQuestExceptionOnly used for Manual Optimization loops. Submits an evaluated solution back to the Optimization Engine.- Returns:
- - Returns the total number of evaluated solutions, including this one. This can be useful to track how many solutions have been processed including other concurrent threads.
- Throws:
com.opttek.optquest.COptQuestException
- - An exception is thrown if there was an error.
-
Reject
public int Reject() throws com.opttek.optquest.COptQuestExceptionOnly used for Manual Optimization loops. Rejects an OptQuestSolution, signaling to the optimization engine that it could not be evaluated due to external constraints or simulation failures. It indicates the solution has no valid output values. Calls to GetValue() will return NaN.- Returns:
- - Returns the total number of evaluated solutions, including this one. This can be useful to track how many solutions have been processed including other concurrent threads.
- Throws:
com.opttek.optquest.COptQuestException
- - An exception is thrown if there was an error.
-
Update
public boolean Update()Only used for Manual Optimization loops. Updates the internal state of a solution after it has been returned (Submitted or Rejected) to the Optimization engine.- Returns:
- -true if the call was successful, false if there was an error.
-
AddSuggested
public boolean AddSuggested() throws com.opttek.optquest.COptQuestExceptionUsed to supply "warm start" solutions to the engine. If certain solutions are known to be good, before starting an optimization, suggesting them as starting points can speed convergence. The caller supplies values for the Input Variables. OptQuest will evaluate suggested solutions before generating new solutions.- Returns:
- - true if the call was successful, false if there was an error.
- Throws:
com.opttek.optquest.COptQuestException
- - - An exception is thrown if there was an error.
-
AddEvaluated
public boolean AddEvaluated() throws com.opttek.optquest.COptQuestExceptionUsed to supply solutions to the engine where the outputs have already been calculated. If previous simulations have been run and the output values have been computed for specific inputs, sending them in as evaluated solutions can save computational effort. The caller supplies values for the input and output variables. OptQuest will process suggested solutions before generating new solutions.- Returns:
- - true if the call was successful, false if there was an error.
- Throws:
com.opttek.optquest.COptQuestException
- - - An exception is thrown if there was an error.
-
Print
public void Print() throws com.opttek.optquest.COptQuestException- Throws:
com.opttek.optquest.COptQuestException
-