Class OptQuestModel
OptQuest is a black-box metaheuristic optimizer suitable for complex, simulation-based, or non-linear problems where derivative information is unavailable. It handles single and multi-objective optimization, variable replications for stochastic responses, confidence testing, adaptive sampling, and surrogate modeling.
Use AddContinuousVariable(String, double, double) (and the many other
Add*Variable methods) to define the model, SetReplications(int, int) for
stochastic simulations, then call one of the Optimize(...) methods with a custom
IOptQuestEvaluator to evaluate solutions.
Solutions are managed via OptQuestSolution instances. Best solutions or frontier
points can be retrieved with GetBestSolutions().
Names: OptQuest matches names without regard to case. Flow and
flow are the same name, in the API and in expressions. So a model cannot have both
Flow and flow: the second Add call returns false because the name already
exists. OptQuestSolution.GetInputNames() and OptQuestSolution.GetOutputNames()
return each name as you wrote it when you added it.
A variable name must not be the name of a function or a constant of the expression language,
such as rate, max, pi or e. In Java the Add call throws
COptQuestException with the message "The variable name is a reserved function name."
Numbering: the index and position numbers that OptQuest reports start at 1. These are:
- the selected tuple of a tuple variable and the selected location of a geolocation variable;
- the option of a design or choice variable;
- the bin of an assignment variable and the group of a partition variable;
- the rank of a sequence, multi-stage sequence or topological sequence variable, and the position of an element of a permutation variable;
- the position of a node on a path variable;
- the element numbers in generated names, such as
v@1for the first element of a vector; - the iteration number (
OptQuestSolution.GetIteration()) and the replication number (OptQuestSolution.GetReplication()).
k as an index into your own array,
read element k - 1. A value of 0 has its own meaning: an assignment bin of 0 means that
the item is in no bin, and a path position of 0 means that the node is not on the path.- Author:
- OptTek Systems, Inc.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConstants used for confidence-interval based replication stopping rules.static classConstants for sampling methods used with adaptive sampling and surrogate modeling.static classNames of variogram models used when building the surrogate (Kriging) model for adaptive sampling.static classConstants for statistics that can be computed over replications of an output or objective in stochastic simulations.static classPossible reasons why an optimization terminated. -
Field Summary
FieldsModifier and TypeFieldDescriptionMap of all constraints by name.Map of all input (decision) variables by name.Map of all objectives by name (single- or multi-objective).Map of all output (user-controlled) variables by name.final Map<com.opttek.optquest.COptQuestSingleObjective, double[]> Internal map used only when Response Distribution Sampling (RDS) is enabled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCopies every evaluated solution of the source modelsrcinto this model.booleanAddAngleVariable(String name, double minDeg, double maxDeg) Adds an angle variable.booleanAddAssignmentVariable(String name, int m, int n) Adds an assignment variable.booleanAddAssignmentVariable(String name, int m, int n, boolean[] mustAssign, int[] binCapacitiesMin, int[] binCapacitiesMax) Adds an assignment variable with separate rules for each item and each bin.booleanAddAssignmentVariable(String name, int m, int n, boolean mustAssign, int binCapacityMin, int binCapacityMax) Adds an assignment variable with the same rules for every item and every bin.booleanAddBetaRandomVariable(String name, double alpha, double beta) Adds a Beta-distributed random variable (used as a random input drawn each replication).booleanAddBinaryMatrixVariable(String name, int m, int n) Adds a binary matrix variable: anmbynmatrix of binary variables.booleanAddBinaryNDVariable(String name, int[] dims) Adds a binary N-dimensional variable: an array of binary variables with the shapedims.booleanAddBinaryVariable(String name) Adds a binary variable with the given name.booleanAddBinaryVectorVariable(String name, int k) Adds a binary vector variable:kbinary variables.booleanAddBSplineCorrectionMatrixVariable(String name, double[][] initial, int knotRows, int knotCols, double min, double max) Adds a B-spline correction matrix variable.booleanAddBSplineCorrectionVectorVariable(String name, double[] initial, int numKnots, double min, double max) Adds a B-spline correction vector variable.booleanAddBSplineMatrixVariable(String name, int rows, int cols, int knotRows, int knotCols, double min, double max) Adds a B-spline matrix variable.booleanAddBSplineVectorVariable(String name, int length, int numKnots, double min, double max) Adds a B-spline vector variable.booleanAddBudgetedSelectionVariable(String name, int n, double[] costs, double budgetMax) Adds a budgeted selection variable that selects candidates whose total cost is at mostbudgetMax.booleanAddBudgetedSelectionVariable(String name, int n, double[] costs, double budgetMin, double budgetMax, int kMin, int kMax) Adds a budgeted selection variable with a budget range and a range for the number of selected candidates.booleanAddCauchyRandomVariable(String name, double location, double scale) Adds a Cauchy-distributed random variable.booleanAddChiSquareRandomVariable(String name, int df) Adds a Chi-square-distributed random variable.booleanAddChoiceVariable(String name, int k) Adds a choice variable.booleanAddConstraint(String name, String expression) Defines a linear or non-linear constraint where the expression may include variables and outputs.booleanAddContinuousVariable(String name, double min, double max) Adds a continuous variable with the given name, minimum value and maximum value.booleanAddDAGVariable(String name, String[] nodeNames) Adds a DAG variable.booleanAddDAGVariable(String name, String[] nodeNames, String startNode, String endNode, boolean connected, Map<String, List<String>> predecessors) Adds a DAG variable with an optional start node, an optional end node, the connected option and optional precedences.booleanAddDesignVariable(String name, int num) Deprecated.Use a choice variable instead.booleanAddDiscreteMatrixVariable(String name, int m, int n, double min, double max, double step) Adds a discrete matrix variable: anmbynmatrix of discrete variables.booleanAddDiscreteNDVariable(String name, int[] dims, double min, double max, double step) Adds a discrete N-dimensional variable: an array of discrete variables with the shapedims.booleanAddDiscreteVariable(String name, double min, double max, double step) Adds a discrete variable with the given name, minimum value, maximum value and step size.booleanAddDiscreteVectorVariable(String name, int n, double min, double max, double step) Adds a discrete vector variable:ndiscrete variables.booleanAddEnumerationVariable(String name, double[] items) Adds an enumeration variable: a decision variable that has an enumerated set of values such as 5,7 and 25.booleanAddExchangeableGroup(String name, String[] variables) Declares a group of identical items, one variable for each item, whose values you can exchange without a change to the result.booleanAddExchangeableGroup(String name, String[][] variables) Declares a group of identical items, each described by a row of variables, whose values you can exchange row for row without a change to the result.booleanAddExponentialRandomVariable(String name, double scale) Adds an exponentially distributed random variable.booleanAddExpressionVariable(String name, String expression) Defines a variable that is evaluated as an expression of other variables in the model.booleanAddFixGroup(String name, String[] variables) Declares a fix group: a set of decision variables that the optimizer holds at the values of the best solution found so far while it searches the other variables.booleanAddFloatGroup(String name, String[] variables) Declares a float group: a set of decision variables that the optimizer searches while it holds all the other variables at the values of the best solution found so far.booleanAddFourierCorrectionMatrixVariable(String name, double[][] initial, int freqRows, int freqCols, double min, double max) Adds a Fourier correction matrix variable.booleanAddFourierCorrectionVectorVariable(String name, double[] initial, int numFreq, double min, double max) Adds a Fourier correction vector variable.booleanAddFourierMatrixVariable(String name, int rows, int cols, int freqRows, int freqCols, double min, double max) Adds a Fourier matrix variable.booleanAddFourierVectorVariable(String name, int length, int numFreq, double min, double max) Adds a Fourier vector variable.booleanAddGammaRandomVariable(String name, double shape, double scale) Adds a Gamma-distributed random variable.booleanAddGeolocationVariable(String name, double[][] locations) Adds a geolocation variable: a decision variable whose values are lists of latitude and longitude.booleanAddIncrementalLowRankCorrectionMatrixVariable(String name, double[][] initial, int rank, double min, double max) Adds an incremental low-rank correction matrix variable.booleanAddIncrementalTimeSeriesCorrectionVectorVariable(String name, double[] initial, int longScale, int shortScale, int rank, double min, double max) Adds an incremental time-series correction vector variable.booleanAddIntegerMatrixVariable(String name, int m, int n, double min, double max) Adds an integer matrix variable: anmbynmatrix of integer variables.booleanAddIntegerNDVariable(String name, int[] dims, double min, double max) Adds an integer N-dimensional variable: an array of integer variables with the shapedims.booleanAddIntegerVariable(String name, double min, double max) Adds an integer variable with the given name, minimum value and maximum value.booleanAddIntegerVectorVariable(String name, int n, double min, double max) Adds an integer vector variable:ninteger variables.booleanAddItemSelectionVariable(String name, int n, int k) Adds an item selection variable that selects exactlykofncandidates.booleanAddItemSelectionVariable(String name, int n, int kMin, int kMax) Adds an item selection variable that selects fromkMintokMaxofncandidates.booleanAddLogNormalRandomVariable(String name, double shape, double scale) Adds a log-normal distributed random variable.booleanAddLowRankCorrectionMatrixVariable(String name, double[][] initial, int rank, double min, double max) Adds a low-rank correction matrix variable.booleanAddLowRankMatrixVariable(String name, int rows, int cols, int rank, double min, double max) Adds a low-rank matrix variable.booleanAddMatrixVariable(String name, int m, int n, double min, double max) Adds a matrix variable: anmbynmatrix of continuous variables.booleanAddMaximizeObjective(String name, String expression) Defines an objective whose value the optimizer maximizes.booleanAddMinimizeObjective(String name, String expression) Defines an objective whose value the optimizer minimizes.booleanAddMixtureVariable(String name, String[] components, double[] lowerBounds, double[] upperBounds, double sumTo) Adds a mixture variable.booleanAddMultiChoiceVariable(String name, String[] choices, int minSelect, int maxSelect) Adds a multi-choice variable.booleanAddMultiStageSequenceVariable(String name, String[][] stageGroups) Adds a multi-stage sequence variable.booleanAddNDVariable(String name, int[] dims, double min, double max) Adds a N-dimensional variable: an array of continuous variables with the shapedims.booleanAddNormalRandomVariable(String name, double mean, double sigma) Adds a normally distributed random variable.booleanAddObjective(String name, String dir, String expression) Defines an objective whose value the optimizer minimizes or maximizes.booleanAddOutputMatrixVariable(String name, int rows, int cols) Adds an output matrix variable: arowsbycolsmatrix of output variables.booleanAddOutputNDVariable(String name, int[] dims) Adds an output N-dimensional variable: an array of output variables with the shapedims.booleanAddOutputVariable(String name) Adds an output variable.booleanAddOutputVectorVariable(String name, int n) Adds an output vector variable:noutput variables.booleanAddParetoRandomVariable(String name, double gamma, double loc, double scale) Adds a Pareto-distributed random variable.booleanAddPartitionVariable(String name, int m, int k) Adds a partition variable.booleanAddPathVariable(String name, String[] nodeNames, String startNode, String endNode, String[] requiredNodes) Adds a path variable.booleanAddPermutationVariable(String group, String[] names) Deprecated.Use a sequence variable instead.booleanAddPoissonRandomVariable(String name, double lambda) Adds a Poisson-distributed random variable.booleanAddPolicySequenceVariable(String name, double[][] featureMatrix, String[] itemNames, String[] featureNames) Adds a policy sequence variable.booleanAddPowerRandomVariable(String name, double rmin, double rmax, double power) Adds a random variable whose value is fromrmintormax.booleanAddRegionVariable(String name, double[][] polygon) Adds a region variable.booleanAddSampleMetric(String name, String responseExpression, String errorExpression) Defines a response metric and an error metric that the engine tracks for adaptive sampling.booleanAddSelectionVariable(String name, String[] selVars) Selection variables are used to add or remove other variables from the optimization.booleanAddSequenceVariable(String name, String[] components, Integer topK) Adds a sequence variable.booleanAddSphericalAngleVariable(String name, double minThetaDeg, double maxThetaDeg, double minPhiDeg, double maxPhiDeg) Adds a spherical angle variable.booleanAddSphericalElevationRandomVariable(String name, double min, double max) Adds a spherical elevation random variable.booleanAddSphericalRegionVariable(String name, double[][] polygon) Adds a spherical region variable.booleanAddSplineCorrectionMatrixVariable(String name, double[][] initial, int knotRows, int knotCols, double min, double max) Adds a spline correction matrix variable.booleanAddSplineCorrectionVectorVariable(String name, double[] initial, int numKnots, double min, double max) Adds a spline correction vector variable.booleanAddSplineMatrixVariable(String name, int rows, int cols, int knotRows, int knotCols, double min, double max) Adds a spline matrix variable.booleanAddSplineVectorVariable(String name, int length, int numKnots, double min, double max) Adds a spline vector variable.booleanAddStudentTRandomVariable(String name, int df) Adds a Student's t-distributed random variable.booleanAddTimeSeriesCorrectionVectorVariable(String name, double[] initial, int longScale, int shortScale, int rank, double min, double max) Adds a time-series correction vector variable.booleanAddTimeSeriesVectorVariable(String name, int longScale, int shortScale, int rank, double min, double max) Adds a time-series vector variable.booleanAdds a topological sequence variable.booleanAddTreeVariable(String name, String[] nodeNames) Adds a tree variable.booleanAddTreeVariable(String name, String[] nodeNames, String rootNode, Map<String, List<String>> predecessors) Adds a tree variable with an optional fixed root and optional precedences.booleanAddTupleVariable(String name, double[][] tuples) Adds a tuple variable: a decision variable whose values are lists of tuples.booleanAddUniformRandomVariable(String name, double min, double max) Adds a uniform random variable.booleanAddVariableExclusiveRange(String name, double min, double max) Defines a range of values that will be excluded as possible solutions for the variable identified by the name.booleanAddVectorVariable(String name, int n, double min, double max) Adds a vector variable:ncontinuous variables.booleanAddWeibullRandomVariable(String name, double shape, double scale) Adds a Weibull-distributed random variable.voidCleanUp()Closes the log files opened byLogSetup(String)andLogSolutions(String).voidContinue()Restarts an optimization that was interrupted with a call to Interrupt().Make a copy of the input OptQuestSolution.CreateAsyncChannel(int npar) Creates an asynchronous communication channel to send signals to the model during an optimizationRequests the OptQuestModel to generate a new trial solution for evaluation.Describe()Generates a string describing the model parameters.Returns all evaluated solutions.If the OptQuestModel has a single objective, this method returns the best solution.GetBestSolutions(int limit) If the OptQuestModel has a single objective, this method returns the best n solutions where n is the limit parameter.Creates an empty OptQuestSolution.intReturns the maximum number of replications set bySetReplications(int, int), or 0 before the model has initialized successfully.intReturns the number of solutions that have been evaluated.intReturns why the last run stopped, as one of theOptQuestModel.TerminationReasonconstants.booleanPrepares the model to run and moves it from the definition stage to the execution stage, after which the model is immutable.voidSignals the OptQuestModel to stop generating new solutions during manual optimization loops.booleanLogSetup() logs the OptQuestModel setup in an xml formatted file.booleanLogSolutions(String filespec) LogSolutions() logs all solutions in a csv formatted file.booleanOptimize(int nsol) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(int npar, int nsol) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(int npar, int nsol, IOptQuestEvaluator eval) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(int nsol, IOptQuestEvaluator eval) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(OptQuestModelChannel ipc, int nsol) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) Starts the optimization and stops when nsol solutions have been evaluated.booleanOptimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) Starts the optimization and stops when nsol solutions have been evaluated.booleanSample(int nsol) Starts an adaptive sampling run and stops when nsol solutions have been evaluated.booleanSample(int npar, int nsol) Starts a concurrent adaptive sampling run using npar parallel evaluators and stops when nsol solutions have been evaluated.booleanSample(int npar, int nsol, IOptQuestEvaluator eval) Starts a concurrent adaptive sampling run using npar parallel evaluators.booleanSample(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) Starts a concurrent adaptive sampling run using npar parallel evaluators.booleanSample(int nsol, IOptQuestEvaluator eval) Starts an adaptive sampling run and stops when nsol solutions have been evaluated.booleanSample(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) Starts an adaptive sampling run and stops when nsol solutions have been evaluated.booleanSample(OptQuestModelChannel ipc, int nsol) Starts an asynchronous adaptive sampling run.booleanSample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) Starts an asynchronous adaptive sampling run with a custom evaluator.booleanSample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) Starts an asynchronous adaptive sampling run with a custom evaluator and monitor.booleanSetLicense(String license) Sets the license ID that OptTek Systems, Inc.booleanSetObjectiveConfidence(String name, int ctype, int clevel, double epct) Sets the values used for replication confidence testing on the specified objective.booleanSetObjectiveGoal(String name, double min, double max) Sets a target range, from min to max inclusive, for an objective in a model with two or more objectives.booleanSetObjectiveStatistic(String name, int statistic) Defines the statistic for the replications of an objective.booleanSetObjectiveStatistic(String name, int statistic, double statisticValue) Defines the percentile statistic for the replications of an objective.booleanSetOutputStatistic(String name, int statistic) Defines the statistic for the replications of an output variable.booleanSetOutputStatistic(String name, int statistic, double statisticValue) Defines the percentile statistic for the replications of an output variable.booleanSetParallelHint(int npar) Sets a hint for the number of parallel evaluations that are expected to happen.booleanSetRandomSeed(int seed) Sets the random seed.booleanSetReplications(int reps) Sets the number of fixed replications to be run for each solution.booleanSetReplications(int min, int max) Sets the number of variable replications to be run for each solution.booleanSetSampleMethod(int method) Sets the sample method to be used when using sample metrics.booleanSetSampleRDSBeta(String name, int nBins, double alpha, double beta) Sets the bins to use if response distribution sampling is enabled, from a Beta distribution.booleanSetSampleRDSCauchy(String name, int nBins, double location, double scale) Sets the bins to use if response distribution sampling is enabled, from a Cauchy distribution.booleanSetSampleRDSChiSquare(String name, int nBins, double nu) Sets the bins to use if response distribution sampling is enabled, from a Chi-square distribution.booleanSetSampleRDSDiscrete(String name, double[] binEdges) Sets the bins to use if response distribution sampling is enabled, from a list of bin edges.booleanSetSampleRDSExponential(String name, int nBins, double scale) Sets the bins to use if response distribution sampling is enabled, from an exponential distribution.booleanSetSampleRDSGamma(String name, int nBins, double a, double scale) Sets the bins to use if response distribution sampling is enabled, from a Gamma distribution.booleanSetSampleRDSLogNormal(String name, int nBins, double s, double scale) Sets the bins to use if response distribution sampling is enabled, from a log-normal distribution.booleanSetSampleRDSNormal(String name, int nBins, double mu, double sigma) Sets the bins to use if response distribution sampling is enabled, from a normal distribution.booleanSetSampleRDSParams(String name, String distribution, double[] params) Sets the bins to use if response distribution sampling is enabled, from a named distribution.booleanSetSampleRDSPareto(String name, int nBins, double gamma, double loc, double scale) Sets the bins to use if response distribution sampling is enabled, from a Pareto distribution.booleanSetSampleRDSPoisson(String name, int nBins, double lambda) Sets the bins to use if response distribution sampling is enabled, from a Poisson distribution.booleanSetSampleRDST(String name, int nBins, double nu) Sets the bins to use if response distribution sampling is enabled, from a Student's t distribution.booleanSetSampleRDSUniform(String name, int nBins, double a, double b) Sets the bins to use if response distribution sampling is enabled, from a uniform distribution.booleanSetSampleRDSWeibull(String name, int nBins, double c, double scale) Sets the bins to use if response distribution sampling is enabled, from a Weibull distribution.booleanSetSampleVariogram(String variogram) Sets the sample variogram to be used when building the surrogate model.booleanRuns the replications of each solution serially.booleanSetStopCycles(int cycles) Stops the optimization aftercyclessearch cycles.booleanSetStopImprovement(double improvement, int iterations) Stops the optimization wheniterationsconsecutive iterations pass without a cumulative improvement of more than the fractionimprovement.booleanSetStopTime(int seconds) Sets the number of seconds the optimization should run before stopping.voidSetTerminationReason(int reason) Sets the termination reason.booleanSets a flag so that the optimization stops as soon as it finds an optimal solution in the case that the optimization is a mixed integer linear program (MILP).booleanRestricts the model to the solutions you supply.
-
Field Details
-
inputs
Map of all input (decision) variables by name. Populated automatically when anyAdd*Variablemethod is called. LinkedHashMap preserves insertion order. -
outputs
Map of all output (user-controlled) variables by name. Includes expression variables and variables added viaAddOutputVariable(String). LinkedHashMap preserves insertion order, matchinginputs. -
constraints
Map of all constraints by name. LinkedHashMap preserves insertion order. -
objectives
Map of all objectives by name (single- or multi-objective). LinkedHashMap preserves insertion order. -
RDSBins
Internal map used only when Response Distribution Sampling (RDS) is enabled. -
solutions
-
-
Constructor Details
-
OptQuestModel
public OptQuestModel()
-
-
Method Details
-
SetLicense
Sets the license ID that OptTek Systems, Inc. assigned to you. If no license is set, the demo license is used, which limits the number of iterations to 50.- Parameters:
license- - license ID- Returns:
- true if the method was successful.
-
LogSetup
LogSetup() logs the OptQuestModel setup in an xml formatted file. This is used for debugging optimization setup problems.- Parameters:
filespec- path to a file that will contain the logging info- Returns:
- true if the method was successful.
-
LogSolutions
LogSolutions() logs all solutions in a csv formatted file.- Parameters:
filespec- path to a file that will contain the solution log- Returns:
- true if the method was successful.
-
AddContinuousVariable
public boolean AddContinuousVariable(String name, double min, double max) throws com.opttek.optquest.COptQuestException Adds a continuous variable with the given name, minimum value and maximum value. A continuous variable can have any value between the minimum bound and the maximum bound.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.min- - minimum value for the continuous variablemax- - maximum value for the continuous variable- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddIntegerVariable
public boolean AddIntegerVariable(String name, double min, double max) throws com.opttek.optquest.COptQuestException Adds an integer variable with the given name, minimum value and maximum value. The variable takes the valuesmin,min+ 1,min+ 2, and so on, up tomax. Give whole-number bounds to get whole-number values.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.min- - minimum value for the integer variablemax- - maximum value for the integer variable- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddDiscreteVariable
public boolean AddDiscreteVariable(String name, double min, double max, double step) throws com.opttek.optquest.COptQuestException Adds a discrete variable with the given name, minimum value, maximum value and step size. The variable takes the valuesmin,min+step,min+ 2 ×step, and so on. The largest value is the one nearest tomax, so it can differ frommaxwhenmax-minis not a whole multiple ofstep.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.min- - minimum value for the variablemax- - maximum value for the variablestep- - step between values; must be greater than 0- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddBinaryVariable
Adds a binary variable with the given name.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddDesignVariable
@Deprecated public boolean AddDesignVariable(String name, int num) throws com.opttek.optquest.COptQuestException Deprecated.Use a choice variable instead. Add it withAddChoiceVariable(String, int). A choice variable gives the number of the selected option, from 1 to the number of options.Design variables are used when the value of the decision variable represents an alternative, and not a quantity. For example, the variable may take on the values red, green or blue. Design variables are useful in optimization problems where the decision variables consist of choosing the best alternative from a catalog, and a larger number may not imply the commitment of more resources. Therefore, choice #10 may not be a more costly or a better choice than choice #1. Adds a design variable with the given name and the number of possible choices.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.num- - number of possible choices.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddEnumerationVariable
public boolean AddEnumerationVariable(String name, double[] items) throws com.opttek.optquest.COptQuestException Adds an enumeration variable: a decision variable that has an enumerated set of values such as 5,7 and 25.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.items- - the array of valid values- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddPermutationVariable
@Deprecated public boolean AddPermutationVariable(String group, String[] names) throws com.opttek.optquest.COptQuestException Deprecated.Use a sequence variable instead. Add it withAddSequenceVariable(String, String[], Integer). A sequence variable gives the same ranks, from 1 to n, and it also has a top-k mode.Permutation variables are used to solve sequencing problems. For example, you could use permutation variables to determine the order in which paint should be mixed to minimize cleanup time between color changes. The value of a permutation variable represents its position within the sequence. A decision variable will be created for each entry in the names[] array. They will be named with the prefixgroup@signifying their membership in the group.- Parameters:
group- - Group identifier.names- - the list of the names in the sequence.- Returns:
- true if the variables were added; false if the group name or a member name is not valid, for example if it is already in use or contains whitespace or a semicolon, or if two member names are the same
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddTupleVariable
public boolean AddTupleVariable(String name, double[][] tuples) throws com.opttek.optquest.COptQuestException Adds a tuple variable: a decision variable whose values are lists of tuples. Tuple variables are used for discrete choices in multiple dimensions, and are intended to be used when a Euclidean distance between values is meaningful. For example, consider three options (a1,b1), (a2,b2), and (a3,b3). The 2D Euclidean distance between the options will be used to determine closeness when searching for good solutions.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.tuples- - the list of discrete choices- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddGeolocationVariable
public boolean AddGeolocationVariable(String name, double[][] locations) throws com.opttek.optquest.COptQuestException Adds a geolocation variable: a decision variable whose values are lists of latitude and longitude. This is a specialization of the tuple with extra restrictions on the size of the tuple (2) and distance is on a sphere rather than Euclidean distance.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.locations- - list of latitude and longitude for the geolocation.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddSelectionVariable
public boolean AddSelectionVariable(String name, String[] selVars) throws com.opttek.optquest.COptQuestException Selection variables are used to add or remove other variables from the optimization. With a COptQuestSelectionGroup, the user has a binary variable whose value indicates an on/off state, where the off state indicates that other variables are not used in the evaluation. The OptQuest Engine maps the dependent variables to their lower bounds when the variable indicating the state is set to the off state.- Parameters:
name- - The name of the newly created binary variable to signify selection.selVars- - the list of the names of other variables to be included when the name binary variable is true.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddExchangeableGroup
public boolean AddExchangeableGroup(String name, String[] variables) throws com.opttek.optquest.COptQuestException Declares a group of identical items, one variable for each item, whose values you can exchange without a change to the result. An example is the capacities of three identical chillers. In each trial solution that the optimizer generates, it puts the values of the members in ascending order, in the order ofvariables: the first member has the smallest value. Thus the optimizer does not evaluate two solutions that differ only by an exchange of values. The optimizer evaluates a solution that you suggest with the values that you give.Use an exchangeable group only for items that have the same type, the same bounds and the same role in your evaluation. If the items differ, for example machines with different capacities, a solution and the same solution with two values exchanged are different solutions, and the optimizer evaluates only one of them. If the bounds differ, the optimizer searches only values that fit the bounds of the members in ascending order. Put a variable in no more than one exchangeable group. If a variable is in two groups, the order of the second group can break the order of the first group.
Each member must be a decision variable that is already in the model: a continuous, integer, discrete, binary, design, enumeration, tuple, geolocation or selection variable, or an element of a vector, matrix, N-dimensional, item-selection or budgeted-selection variable under its generated name, such as
v@1. The values of a manifold variable, such asdir@theta, are not accepted. Names are matched without regard to case.- Parameters:
name- - group name; must be unique in the model and free of whitespace and semicolons. This call adds no variable.variables- - names of the members, one for each item.- Returns:
- - true if the group was added; false if the model is already initialized, if the name is not valid or is already in use, or if a member is not a decision variable of the model.
- Throws:
com.opttek.optquest.COptQuestException- - if the engine cannot add the group.
-
AddExchangeableGroup
public boolean AddExchangeableGroup(String name, String[][] variables) throws com.opttek.optquest.COptQuestException Declares a group of identical items, each described by a row of variables, whose values you can exchange row for row without a change to the result. An example is three identical machines, each with an x and a y position. In each trial solution that the optimizer generates, it puts the rows in ascending order, in the order ofvariables: by the value of the first variable of each row, then by the second variable when the first values are equal, and so on. Thus the optimizer does not evaluate two solutions that differ only by an exchange of rows. The optimizer evaluates a solution that you suggest with the values that you give.Every row must have the same number of variables, in the same order: in the machine example, x first and y second in each row. Use an exchangeable group only for items that have the same type, the same bounds and the same role in your evaluation. If the items differ, a solution and the same solution with two rows exchanged are different solutions, and the optimizer evaluates only one of them. If the bounds differ, the optimizer searches only values that fit the bounds of the members in ascending order. Put a variable in no more than one exchangeable group. If a variable is in two groups, the order of the second group can break the order of the first group.
Each member must be a decision variable that is already in the model: a continuous, integer, discrete, binary, design, enumeration, tuple, geolocation or selection variable, or an element of a vector, matrix, N-dimensional, item-selection or budgeted-selection variable under its generated name, such as
v@1. The values of a manifold variable, such asdir@theta, are not accepted. Names are matched without regard to case.- Parameters:
name- - group name; must be unique in the model and free of whitespace and semicolons. This call adds no variable.variables- - one row for each item, each row holding the names of the variables of that item.- Returns:
- - true if the group was added; false if the model is already initialized, if the name is not valid or is already in use, or if a member is not a decision variable of the model.
- Throws:
com.opttek.optquest.COptQuestException- - EXCEPT_BADVARIABLEDIMENSIONS, "Variable definitions are of unequal length.", if the rows do not all have the same number of variables.
-
AddFixGroup
public boolean AddFixGroup(String name, String[] variables) throws com.opttek.optquest.COptQuestException Declares a fix group: a set of decision variables that the optimizer holds at the values of the best solution found so far while it searches the other variables. After an initial part of the search, the optimizer makes one more trial solution from each new trial solution. In that trial solution, the members of the group have the values of the best solution, and all the other variables keep the values of the new trial solution. The optimizer also evaluates the new trial solution. The length of the initial part increases with the number of variables. The optimizer counts these trial solutions in the iteration budget, and it does not evaluate one that duplicates a solution it already has.Use a fix group when you want more of the search to change the other variables near the best solution. With a fix group of a set of variables, the optimizer makes the same trial solutions as with a float group (
AddFloatGroup(String, String[])) of all the other decision variables, so declare the smaller set. For each group that you add, the optimizer makes its own trial solutions. For a group with no members and for a group that holds every decision variable, the optimizer makes no extra trial solutions.Each member must be a decision variable that is already in the model: a continuous, integer, discrete, binary, design, enumeration, tuple, geolocation or selection variable, or an element of a vector, matrix, N-dimensional, item-selection or budgeted-selection variable under its generated name, such as
v@1. The values of a manifold variable, such asdir@theta, are not accepted. Names are matched without regard to case.- Parameters:
name- group name; must be unique in the model and free of whitespace and semicolons. This call adds no variable.variables- names of the members- Returns:
trueif the group was added;falseif the model is already initialized, if the name is not valid or is already in use, or if a member is not a decision variable of the model- Throws:
com.opttek.optquest.COptQuestException- if the engine cannot add the group
-
AddFloatGroup
public boolean AddFloatGroup(String name, String[] variables) throws com.opttek.optquest.COptQuestException Declares a float group: a set of decision variables that the optimizer searches while it holds all the other variables at the values of the best solution found so far. After an initial part of the search, the optimizer makes one more trial solution from each new trial solution. In that trial solution, the members of the group keep the values of the new trial solution, and all the other variables have the values of the best solution. The optimizer also evaluates the new trial solution. The length of the initial part increases with the number of variables. The optimizer counts these trial solutions in the iteration budget, and it does not evaluate one that duplicates a solution it already has.Use a float group when you want more of the search to change a small set of variables near the best solution. With a float group of a set of variables, the optimizer makes the same trial solutions as with a fix group (
AddFixGroup(String, String[])) of all the other decision variables, so declare the smaller set. For each group that you add, the optimizer makes its own trial solutions. For a group with no members and for a group that holds every decision variable, the optimizer makes no extra trial solutions.Each member must be a decision variable that is already in the model: a continuous, integer, discrete, binary, design, enumeration, tuple, geolocation or selection variable, or an element of a vector, matrix, N-dimensional, item-selection or budgeted-selection variable under its generated name, such as
v@1. The values of a manifold variable, such asdir@theta, are not accepted. Names are matched without regard to case.- Parameters:
name- group name; must be unique in the model and free of whitespace and semicolons. This call adds no variable.variables- names of the members- Returns:
trueif the group was added;falseif the model is already initialized, if the name is not valid or is already in use, or if a member is not a decision variable of the model- Throws:
com.opttek.optquest.COptQuestException- if the engine cannot add the group
-
AddVariableExclusiveRange
public boolean AddVariableExclusiveRange(String name, double min, double max) throws com.opttek.optquest.COptQuestException Defines a range of values that will be excluded as possible solutions for the variable identified by the name. Any value > min and < max will be excluded. Multiple ranges can be defined on one variable.- Parameters:
name- - name of the variable that will have the exclusive range.min- - any value > min will be excludedmax- - any value < max will be excluded- Returns:
- - true if the variable was added successfully; false if an input with the name does not exist.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddVectorVariable
public boolean AddVectorVariable(String name, int n, double min, double max) throws com.opttek.optquest.COptQuestException Adds a vector variable:ncontinuous variables. The elements are ordinary input variables.Variable names:
<name>@1to<name>@n, one for each element.The value of each element is a continuous value from
mintomax.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of elements; must be at least 1min- lower bound of each elementmax- upper bound of each element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1
-
AddMatrixVariable
public boolean AddMatrixVariable(String name, int m, int n, double min, double max) throws com.opttek.optquest.COptQuestException Adds a matrix variable: anmbynmatrix of continuous variables. The elements are ordinary input variables.Variable names:
<name>@<row>,<col>for each element, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].The value of each element is a continuous value from
mintomax.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of rows; must be at least 1n- number of columns; must be at least 1min- lower bound of each elementmax- upper bound of each element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1
-
AddBinaryVectorVariable
public boolean AddBinaryVectorVariable(String name, int k) throws com.opttek.optquest.COptQuestException Adds a binary vector variable:kbinary variables. The elements are ordinary input variables.Variable names:
<name>@1to<name>@k, one for each element.The value of each element is 0 or 1.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonk- number of elements; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifkis less than 1
-
AddBinaryMatrixVariable
public boolean AddBinaryMatrixVariable(String name, int m, int n) throws com.opttek.optquest.COptQuestException Adds a binary matrix variable: anmbynmatrix of binary variables. The elements are ordinary input variables.Variable names:
<name>@<row>,<col>for each element, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].The value of each element is 0 or 1.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of rows; must be at least 1n- number of columns; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1
-
AddIntegerVectorVariable
public boolean AddIntegerVectorVariable(String name, int n, double min, double max) throws com.opttek.optquest.COptQuestException Adds an integer vector variable:ninteger variables. The elements are ordinary input variables.Variable names:
<name>@1to<name>@n, one for each element.Each element takes the values
min,min+ 1,min+ 2, and so on, up tomax. Give whole-number bounds to get whole-number values.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of elements; must be at least 1min- lower bound of each elementmax- upper bound of each element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1
-
AddIntegerMatrixVariable
public boolean AddIntegerMatrixVariable(String name, int m, int n, double min, double max) throws com.opttek.optquest.COptQuestException Adds an integer matrix variable: anmbynmatrix of integer variables. The elements are ordinary input variables.Variable names:
<name>@<row>,<col>for each element, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].Each element takes the values
min,min+ 1,min+ 2, and so on, up tomax. Give whole-number bounds to get whole-number values.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of rows; must be at least 1n- number of columns; must be at least 1min- lower bound of each elementmax- upper bound of each element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1
-
AddDiscreteVectorVariable
public boolean AddDiscreteVectorVariable(String name, int n, double min, double max, double step) throws com.opttek.optquest.COptQuestException Adds a discrete vector variable:ndiscrete variables. The elements are ordinary input variables.Variable names:
<name>@1to<name>@n, one for each element.Each element takes the values
min,min+step,min+ 2 ×step, and so on. The largest value is the one nearest tomax, so it can differ frommaxwhenmax-minis not a whole multiple ofstep.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of elements; must be at least 1min- lower bound of each elementmax- upper bound of each elementstep- step between values; must be greater than 0- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1
-
AddDiscreteMatrixVariable
public boolean AddDiscreteMatrixVariable(String name, int m, int n, double min, double max, double step) throws com.opttek.optquest.COptQuestException Adds a discrete matrix variable: anmbynmatrix of discrete variables. The elements are ordinary input variables.Variable names:
<name>@<row>,<col>for each element, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].Each element takes the values
min,min+step,min+ 2 ×step, and so on. The largest value is the one nearest tomax, so it can differ frommaxwhenmax-minis not a whole multiple ofstep.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of rows; must be at least 1n- number of columns; must be at least 1min- lower bound of each elementmax- upper bound of each elementstep- step between values; must be greater than 0- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1
-
AddNDVariable
public boolean AddNDVariable(String name, int[] dims, double min, double max) throws com.opttek.optquest.COptQuestException Adds a N-dimensional variable: an array of continuous variables with the shapedims. The elements are ordinary input variables.Variable names:
<name>@<i1>,<i2>,...for each element, with one 1-based index for each dimension. The last index changes fastest. With two or more dimensions, each name contains a comma, so write it in brackets in an expression:[<name>@1,2,3].The value of each element is a continuous value from
mintomax.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolondims- size of each dimension; there must be at least one dimension, and each size must be at least 1min- lower bound of each elementmax- upper bound of each element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifdimsis null or empty, or if a size is less than 1
-
AddIntegerNDVariable
public boolean AddIntegerNDVariable(String name, int[] dims, double min, double max) throws com.opttek.optquest.COptQuestException Adds an integer N-dimensional variable: an array of integer variables with the shapedims. The elements are ordinary input variables.Variable names:
<name>@<i1>,<i2>,...for each element, with one 1-based index for each dimension. The last index changes fastest. With two or more dimensions, each name contains a comma, so write it in brackets in an expression:[<name>@1,2,3].Each element takes the values
min,min+ 1,min+ 2, and so on, up tomax. Give whole-number bounds to get whole-number values.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolondims- size of each dimension; there must be at least one dimension, and each size must be at least 1min- lower bound of each elementmax- upper bound of each element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifdimsis null or empty, or if a size is less than 1
-
AddDiscreteNDVariable
public boolean AddDiscreteNDVariable(String name, int[] dims, double min, double max, double step) throws com.opttek.optquest.COptQuestException Adds a discrete N-dimensional variable: an array of discrete variables with the shapedims. The elements are ordinary input variables.Variable names:
<name>@<i1>,<i2>,...for each element, with one 1-based index for each dimension. The last index changes fastest. With two or more dimensions, each name contains a comma, so write it in brackets in an expression:[<name>@1,2,3].Each element takes the values
min,min+step,min+ 2 ×step, and so on. The largest value is the one nearest tomax, so it can differ frommaxwhenmax-minis not a whole multiple ofstep.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolondims- size of each dimension; there must be at least one dimension, and each size must be at least 1min- lower bound of each elementmax- upper bound of each elementstep- step between values; must be greater than 0- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifdimsis null or empty, or if a size is less than 1
-
AddBinaryNDVariable
public boolean AddBinaryNDVariable(String name, int[] dims) throws com.opttek.optquest.COptQuestException Adds a binary N-dimensional variable: an array of binary variables with the shapedims. The elements are ordinary input variables.Variable names:
<name>@<i1>,<i2>,...for each element, with one 1-based index for each dimension. The last index changes fastest. With two or more dimensions, each name contains a comma, so write it in brackets in an expression:[<name>@1,2,3].The value of each element is 0 or 1.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolondims- size of each dimension; there must be at least one dimension, and each size must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifdimsis null or empty, or if a size is less than 1
-
AddOutputNDVariable
public boolean AddOutputNDVariable(String name, int[] dims) throws com.opttek.optquest.COptQuestException Adds an output N-dimensional variable: an array of output variables with the shapedims. The elements are ordinary output variables.Variable names:
<name>@<i1>,<i2>,...for each element, with one 1-based index for each dimension. The last index changes fastest. With two or more dimensions, each name contains a comma, so write it in brackets in an expression:[<name>@1,2,3].Your evaluator writes a value to each element before it submits the solution.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolondims- size of each dimension; there must be at least one dimension, and each size must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifdimsis null or empty, or if a size is less than 1
-
AddAngleVariable
public boolean AddAngleVariable(String name, double minDeg, double maxDeg) throws com.opttek.optquest.COptQuestException Adds an angle variable. Its value is an angle in degrees on an arc of the circle. Use an angle variable when the decision is a direction in a plane, such as a panel orientation or a turbine yaw.In every solution that the engine generates, the angle is on the arc from
minDegtomaxDeg. When the difference betweenmaxDegandminDegis 360 or more, the arc is the full circle. Otherwise the arc goes fromminDegtomaxDegin the direction of increasing angle, so an arc withminDeggreater thanmaxDeg, such as 320 to 40, crosses 0.Variable names:
<name>@theta, the angle in degrees.The engine reports the angle as its equivalent from 0 up to, but not including, 360, not in the range that you declare. For example, for an arc declared from -45 to 45, the engine reports -45 as 315. To compare the value with the declared bounds, add or subtract 360 until the value is at least
minDegand less thanminDeg+ 360. The value is then fromminDegtomaxDeg. WhenminDegis greater thanmaxDeg, compare the value withmaxDeg+ 360 instead ofmaxDeg. For example, on the arc from 320 to 40, a reported 10 becomes 370, which is from 320 to 400.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonminDeg- start of the arc, in degreesmaxDeg- end of the arc, in degrees- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminDegormaxDegis NaN
-
AddSphericalAngleVariable
public boolean AddSphericalAngleVariable(String name, double minThetaDeg, double maxThetaDeg, double minPhiDeg, double maxPhiDeg) throws com.opttek.optquest.COptQuestException Adds a spherical angle variable. Its value is a direction in three dimensions, given as an elevation and an azimuth in degrees. Use a spherical angle variable when the decision is a pointing direction, such as an antenna boresight or a sensor line of sight.In every solution that the engine generates, the elevation is from
minThetaDegtomaxThetaDeg, and the azimuth is on the arc fromminPhiDegtomaxPhiDeg. The azimuth arc follows the same rules as the arc of an angle variable: a difference of 360 or more is the full circle, and an arc withminPhiDeggreater thanmaxPhiDegcrosses 0.Variable names:
<name>@theta: the elevation in degrees, from -90 (straight down) through 0 (the horizon) to 90 (straight up).<name>@phi: the azimuth in degrees, where 0 is north and 90 is east.
The engine reports the azimuth as its equivalent from 0 up to, but not including, 360, not in the range that you declare. For example, for an azimuth declared from -60 to 60, the engine reports -60 as 300. To compare the azimuth with the declared bounds, use the rule for an angle variable, with
minPhiDegandmaxPhiDeg. The engine reports the elevation as it is, within the declared range.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonminThetaDeg- smallest elevation, in degrees; must be from -90 to 90maxThetaDeg- largest elevation, in degrees; must be fromminThetaDegto 90minPhiDeg- start of the azimuth arc, in degreesmaxPhiDeg- end of the azimuth arc, in degrees- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if a bound is NaN, if an elevation bound is outside [-90, 90], or ifminThetaDegis greater thanmaxThetaDeg
-
AddMixtureVariable
public boolean AddMixtureVariable(String name, String[] components, double[] lowerBounds, double[] upperBounds, double sumTo) throws com.opttek.optquest.COptQuestException Adds a mixture variable. Its value is a set of continuous weights, one for each component, and the weights sum tosumTo. Use a mixture variable when the decision is a set of proportions, such as portfolio weights, blend fractions or allocation ratios.In every solution that the engine generates, the weights sum to
sumTowithin 1e-12, and each weight is within the bounds of its component.Variable names:
<name>@<component>for each component, in the order ofcomponents. The value of each name is the weight of that component.With a negative lower bound, a weight can be below zero, down to that bound.
Supply both bound arrays or neither.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloncomponents- names of the components; each must be unique and must not contain whitespace, a semicolon, a comma or@lowerBounds- lower bound of each component, or null for a lower bound of 0 on every componentupperBounds- upper bound of each component, or null for no upper boundssumTo- sum of the weights; must be greater than 0- Returns:
- true if the variable was added; false if the name is not valid, for example if it
is already in use or contains whitespace or a semicolon, or if only one of
lowerBoundsandupperBoundsis null - Throws:
com.opttek.optquest.COptQuestException- ifcomponentsis empty or holds a name that is not valid, ifsumTois not greater than 0, if a bound array does not have one entry for each component, if a lower bound is greater than its upper bound, or if no set of weights within the bounds sums tosumTo
-
AddLowRankMatrixVariable
public boolean AddLowRankMatrixVariable(String name, int rows, int cols, int rank, double min, double max) throws com.opttek.optquest.COptQuestException Adds a low-rank matrix variable. Its value is arowsbycolsmatrix that is a constant matrix plus a correction of low rank. Use a low-rank matrix variable when the decision is a large table that a few row and column patterns describe.In every solution that the engine generates, every entry is from
mintomax, and the matrix is the constant matrix (min+max) / 2 plus a correction of rank at mostrank.The value of
rankis the number of row patterns that the engine can combine. With rank 1, each row of the matrix is the middle value (min+max) / 2 plus one row pattern, multiplied by an amount that can differ from row to row. Each extra unit of rank adds one more row pattern. With rank 0, every entry is the middle value.Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonrows- number of rows; must be at least 1cols- number of columns; must be at least 1rank- largest rank of the correction. A value greater than the number of rows or columns is reduced to it, and a value of 0 or less gives a constant matrix.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminormaxis NaN, or ifminis greater thanmax
-
AddLowRankCorrectionMatrixVariable
public boolean AddLowRankCorrectionMatrixVariable(String name, double[][] initial, int rank, double min, double max) throws com.opttek.optquest.COptQuestException Adds a low-rank correction matrix variable. Its value is a baseline matrix,initial, plus a correction of low rank. Use a low-rank correction matrix variable to keep a known table and change it with a few row and column patterns.In every solution that the engine generates, every entry is from
mintomax, and the matrix isinitialplus a correction of rank at mostrank. The engine first moves each entry ofinitialinto [min,max].The value of
rankis the number of row patterns that the engine can combine in the correction. With rank 1, each row of the correction is one row pattern, multiplied by an amount that can differ from row to row. Each extra unit of rank adds one more row pattern. With rank 0, the value isinitialwith no correction.Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline matrix; the variable has as many rows and columns asinitialrank- largest rank of the correction. A value greater than the number of rows or columns is reduced to it, and a value of 0 or less givesinitialwith no correction.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminormaxis NaN, or ifminis greater thanmax
-
AddIncrementalLowRankCorrectionMatrixVariable
public boolean AddIncrementalLowRankCorrectionMatrixVariable(String name, double[][] initial, int rank, double min, double max) throws com.opttek.optquest.COptQuestException Adds an incremental low-rank correction matrix variable. Its value is a baseline matrix,initial, plus a correction of rank 1. Use this variable to build a correction one rank at a time. Run an optimization, pass its best value asinitialof the next variable of this type, and repeat. Each variable adds a correction of rank 1 and does not keep the corrections of earlier variables.In every solution that the engine generates, every entry is from
mintomax, and the matrix isinitialplus a correction of rank at most 1. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline matrix; the variable has as many rows and columns asinitialrank- the number of this variable in the sequence. Pass 1 for the first variable in the sequence, 2 for the next, and so on. The value must be at least 1. It does not change the values of this variable.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminormaxis NaN, ifminis greater thanmax, or ifrankis less than 1
-
AddTimeSeriesVectorVariable
public boolean AddTimeSeriesVectorVariable(String name, int longScale, int shortScale, int rank, double min, double max) throws com.opttek.optquest.COptQuestException Adds a time-series vector variable. Its value is a vector oflongScale×shortScalevalues. The engine arranges the values row by row as alongScalebyshortScalematrix, and the matrix is a constant plus a correction of low rank. Use a time-series vector variable when the decision is a long vector with a repeating pattern, such as hourly values over many days.In every solution that the engine generates, every value is from
mintomax, and the matrix is the constant matrix (min+max) / 2 plus a correction of rank at mostrank.The value of
rankis the number of patterns that the engine can combine. With days as rows and hours as columns and rank 1, each day is the middle value (min+max) / 2 plus one pattern over the hours, multiplied by an amount that can differ from day to day. So every day has the same shape, and the size of the change can differ from day to day. Each extra unit of rank adds one more pattern. With rank 0, every value is the middle value.Variable names:
<name>@1to<name>@n, where n islongScale×shortScale. The names go row by row. With days as rows and hours as columns, the firstshortScalenames are the hours of day 1, the nextshortScalenames are the hours of day 2, and so on. Hour h of day d is<name>@k, where k is (d - 1) ×shortScale+ h, with d and h counted from 1.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonlongScale- number of rows of the matrix, for example the number of days; must be at least 1shortScale- number of columns of the matrix, for example the number of hours in a day; must be at least 1rank- largest rank of the correction. A value greater than the number of rows or columns is reduced to it, and a value of 0 or less gives a constant matrix.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminormaxis NaN, or ifminis greater thanmax
-
AddTimeSeriesCorrectionVectorVariable
public boolean AddTimeSeriesCorrectionVectorVariable(String name, double[] initial, int longScale, int shortScale, int rank, double min, double max) throws com.opttek.optquest.COptQuestException Adds a time-series correction vector variable. Its value is a baseline vector,initial, plus a correction. The engine arranges the values row by row as alongScalebyshortScalematrix, and the correction to that matrix has low rank. Use a time-series correction vector variable to keep a known profile and change it with a few repeating patterns.In every solution that the engine generates, every value is from
mintomax, and the matrix isinitialplus a correction of rank at mostrank. The engine first moves each entry ofinitialinto [min,max].The value of
rankis the number of patterns that the engine can combine in the correction. With days as rows and hours as columns and rank 1, the correction to each day is one pattern over the hours, multiplied by an amount that can differ from day to day. Each extra unit of rank adds one more pattern. With rank 0, the value isinitialwith no correction.Variable names:
<name>@1to<name>@n, where n islongScale×shortScale. The names go row by row. With days as rows and hours as columns, the firstshortScalenames are the hours of day 1, the nextshortScalenames are the hours of day 2, and so on. Hour h of day d is<name>@k, where k is (d - 1) ×shortScale+ h, with d and h counted from 1.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline vector; it must havelongScale×shortScalevalueslongScale- number of rows of the matrix, for example the number of days; must be at least 1shortScale- number of columns of the matrix, for example the number of hours in a day; must be at least 1rank- largest rank of the correction. A value greater than the number of rows or columns is reduced to it, and a value of 0 or less givesinitialwith no correction.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminormaxis NaN, or ifminis greater thanmax
-
AddIncrementalTimeSeriesCorrectionVectorVariable
public boolean AddIncrementalTimeSeriesCorrectionVectorVariable(String name, double[] initial, int longScale, int shortScale, int rank, double min, double max) throws com.opttek.optquest.COptQuestException Adds an incremental time-series correction vector variable. Its value is a baseline vector,initial, plus a correction. The engine arranges the values row by row as alongScalebyshortScalematrix, and the correction to that matrix has rank 1. Use this variable to build a correction one rank at a time. Run an optimization, pass its best value asinitialof the next variable of this type, and repeat. Each variable adds a correction of rank 1 and does not keep the corrections of earlier variables.In every solution that the engine generates, every value is from
mintomax, and the matrix isinitialplus a correction of rank at most 1. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@1to<name>@n, where n islongScale×shortScale. The names go row by row. With days as rows and hours as columns, the firstshortScalenames are the hours of day 1, the nextshortScalenames are the hours of day 2, and so on. Hour h of day d is<name>@k, where k is (d - 1) ×shortScale+ h, with d and h counted from 1.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline vector; it must havelongScale×shortScalevalueslongScale- number of rows of the matrix, for example the number of days; must be at least 1shortScale- number of columns of the matrix, for example the number of hours in a day; must be at least 1rank- the number of this variable in the sequence. Pass 1 for the first variable in the sequence, 2 for the next, and so on. The value must be at least 1. It does not change the values of this variable.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifminormaxis NaN, ifminis greater thanmax, or ifrankis less than 1
-
AddBSplineVectorVariable
public boolean AddBSplineVectorVariable(String name, int length, int numKnots, double min, double max) throws com.opttek.optquest.COptQuestException Adds a B-spline vector variable. Its value is a vector oflengthvalues on a smooth curve defined bynumKnotsknots. Use a B-spline vector variable when the decision is a long profile that changes smoothly, such as a setpoint schedule.The curve is a uniform cubic B-spline. It is smooth, and it does not pass through its knots: each value is a weighted average of the nearby knot values. The knots are at evenly spaced elements, with the first and last knots at the two ends.
In every solution that the engine generates, every element is from
mintomax.Variable names:
<name>@1to<name>@length, one for each element.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonlength- number of elements; must be at least 1numKnots- number of knots; fewer knots give a smoother curve. A value less than 2 is used as 2, and a value greater than the number of elements is used as that number.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddSplineVectorVariable
public boolean AddSplineVectorVariable(String name, int length, int numKnots, double min, double max) throws com.opttek.optquest.COptQuestException Adds a spline vector variable. Its value is a vector oflengthvalues on a smooth curve throughnumKnotsknots. Use a spline vector variable when the decision is a long profile that changes smoothly, such as a setpoint schedule.The curve is a centripetal Catmull-Rom spline. It is smooth, and it passes through its knots. The knots are at evenly spaced elements, with the first and last knots at the two ends.
In every solution that the engine generates, every element is from
mintomax.Variable names:
<name>@1to<name>@length, one for each element.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonlength- number of elements; must be at least 1numKnots- number of knots; fewer knots give a smoother curve. A value less than 2 is used as 2, and a value greater than the number of elements is used as that number.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddBSplineCorrectionVectorVariable
public boolean AddBSplineCorrectionVectorVariable(String name, double[] initial, int numKnots, double min, double max) throws com.opttek.optquest.COptQuestException Adds a B-spline correction vector variable. Its value is a baseline vector,initial, plus a correction on a smooth curve defined bynumKnotsknots. Use a B-spline correction vector variable to keep a known profile and change it smoothly.The curve is a uniform cubic B-spline. It is smooth, and it does not pass through its knots: each value is a weighted average of the nearby knot values. The knots are at evenly spaced elements, with the first and last knots at the two ends.
In every solution that the engine generates, every element is from
mintomax. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@1to<name>@length, one for each element. The number of elements is the length ofinitial.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline vector; the variable has as many elements asinitialnumKnots- number of knots; fewer knots give a smoother curve. A value less than 2 is used as 2, and a value greater than the number of elements is used as that number.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddSplineCorrectionVectorVariable
public boolean AddSplineCorrectionVectorVariable(String name, double[] initial, int numKnots, double min, double max) throws com.opttek.optquest.COptQuestException Adds a spline correction vector variable. Its value is a baseline vector,initial, plus a correction on a smooth curve throughnumKnotsknots. Use a spline correction vector variable to keep a known profile and change it smoothly.The curve is a centripetal Catmull-Rom spline. It is smooth, and it passes through its knots. The knots are at evenly spaced elements, with the first and last knots at the two ends.
In every solution that the engine generates, every element is from
mintomax. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@1to<name>@length, one for each element. The number of elements is the length ofinitial.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline vector; the variable has as many elements asinitialnumKnots- number of knots; fewer knots give a smoother curve. A value less than 2 is used as 2, and a value greater than the number of elements is used as that number.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddBSplineMatrixVariable
public boolean AddBSplineMatrixVariable(String name, int rows, int cols, int knotRows, int knotCols, double min, double max) throws com.opttek.optquest.COptQuestException Adds a B-spline matrix variable. Its value is arowsbycolsmatrix on a smooth surface defined by a grid of knots. Use a B-spline matrix variable when the decision is a large table that changes smoothly in both directions.The surface is a uniform cubic B-spline. It is smooth, and it does not pass through its knots: each value is a weighted average of the nearby knot values. The knots form a
knotRowsbyknotColsgrid at evenly spaced rows and columns, with knots at all four edges.In every solution that the engine generates, every entry is from
mintomax.Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonrows- number of rows; must be at least 1cols- number of columns; must be at least 1knotRows- number of knot rows; fewer give a smoother surface down the columns. A value less than 2 is used as 2, and a value greater than the number of rows is used as that number.knotCols- number of knot columns; fewer give a smoother surface along the rows. A value less than 2 is used as 2, and a value greater than the number of columns is used as that number.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddSplineMatrixVariable
public boolean AddSplineMatrixVariable(String name, int rows, int cols, int knotRows, int knotCols, double min, double max) throws com.opttek.optquest.COptQuestException Adds a spline matrix variable. Its value is arowsbycolsmatrix on a smooth surface through a grid of knots. Use a spline matrix variable when the decision is a large table that changes smoothly in both directions.The surface is a centripetal Catmull-Rom spline. It is smooth, and it passes through its knots. The knots form a
knotRowsbyknotColsgrid at evenly spaced rows and columns, with knots at all four edges.In every solution that the engine generates, every entry is from
mintomax.Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonrows- number of rows; must be at least 1cols- number of columns; must be at least 1knotRows- number of knot rows; fewer give a smoother surface down the columns. A value less than 2 is used as 2, and a value greater than the number of rows is used as that number.knotCols- number of knot columns; fewer give a smoother surface along the rows. A value less than 2 is used as 2, and a value greater than the number of columns is used as that number.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddBSplineCorrectionMatrixVariable
public boolean AddBSplineCorrectionMatrixVariable(String name, double[][] initial, int knotRows, int knotCols, double min, double max) throws com.opttek.optquest.COptQuestException Adds a B-spline correction matrix variable. Its value is a baseline matrix,initial, plus a correction on a smooth surface defined by a grid of knots. Use a B-spline correction matrix variable to keep a known table and change it smoothly.The surface is a uniform cubic B-spline. It is smooth, and it does not pass through its knots: each value is a weighted average of the nearby knot values. The knots form a
knotRowsbyknotColsgrid at evenly spaced rows and columns, with knots at all four edges.In every solution that the engine generates, every entry is from
mintomax. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline matrix; the variable has as many rows and columns asinitialknotRows- number of knot rows; fewer give a smoother surface down the columns. A value less than 2 is used as 2, and a value greater than the number of rows is used as that number.knotCols- number of knot columns; fewer give a smoother surface along the rows. A value less than 2 is used as 2, and a value greater than the number of columns is used as that number.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddSplineCorrectionMatrixVariable
public boolean AddSplineCorrectionMatrixVariable(String name, double[][] initial, int knotRows, int knotCols, double min, double max) throws com.opttek.optquest.COptQuestException Adds a spline correction matrix variable. Its value is a baseline matrix,initial, plus a correction on a smooth surface through a grid of knots. Use a spline correction matrix variable to keep a known table and change it smoothly.The surface is a centripetal Catmull-Rom spline. It is smooth, and it passes through its knots. The knots form a
knotRowsbyknotColsgrid at evenly spaced rows and columns, with knots at all four edges.In every solution that the engine generates, every entry is from
mintomax. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline matrix; the variable has as many rows and columns asinitialknotRows- number of knot rows; fewer give a smoother surface down the columns. A value less than 2 is used as 2, and a value greater than the number of rows is used as that number.knotCols- number of knot columns; fewer give a smoother surface along the rows. A value less than 2 is used as 2, and a value greater than the number of columns is used as that number.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddFourierVectorVariable
public boolean AddFourierVectorVariable(String name, int length, int numFreq, double min, double max) throws com.opttek.optquest.COptQuestException Adds a Fourier vector variable. Its value is a vector oflengthvalues that is a sum of thenumFreqlowest-frequency cosine terms. Use a Fourier vector variable when the decision is a long profile that varies smoothly, such as a daily cycle.The first term is a constant. The second term is half of a cosine wave across the whole vector. Each next term adds one more half wave, so the later terms add finer detail. With one term, every element has the same value. For element i, counted from 1, term k is cos(π k (i - 0.5) /
length), where k counts from 0.In every solution that the engine generates, every element is from
mintomax.Variable names:
<name>@1to<name>@length, one for each element.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonlength- number of elements; must be at least 1numFreq- number of cosine terms, including the constant term; fewer give a smoother vector. A value less than 1 is used as 1, and a value greater than the number of elements is used as that number.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddFourierMatrixVariable
public boolean AddFourierMatrixVariable(String name, int rows, int cols, int freqRows, int freqCols, double min, double max) throws com.opttek.optquest.COptQuestException Adds a Fourier matrix variable. Its value is arowsbycolsmatrix that is a sum of the lowest-frequency cosine terms:freqRowsterms down the columns andfreqColsterms along the rows. Use a Fourier matrix variable when the decision is a large table that varies smoothly in both directions.The terms are products of a cosine down the columns and a cosine along the rows, like the terms of the vector type. With one term down the columns, every row is the same. With one term along the rows, every column is the same.
In every solution that the engine generates, every entry is from
mintomax.Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonrows- number of rows; must be at least 1cols- number of columns; must be at least 1freqRows- number of cosine terms down each column; fewer make the rows more alike. A value less than 1 is used as 1, and a value greater than the number of rows is used as that number.freqCols- number of cosine terms along each row; fewer make the columns more alike. A value less than 1 is used as 1, and a value greater than the number of columns is used as that number.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddFourierCorrectionVectorVariable
public boolean AddFourierCorrectionVectorVariable(String name, double[] initial, int numFreq, double min, double max) throws com.opttek.optquest.COptQuestException Adds a Fourier correction vector variable. Its value is a baseline vector,initial, plus a correction that is a sum of thenumFreqlowest-frequency cosine terms. Use a Fourier correction vector variable to keep a known profile and change it smoothly.The first term is a constant. The second term is half of a cosine wave across the whole vector. Each next term adds one more half wave, so the later terms add finer detail. With one term, the correction has the same value at every element. For element i, counted from 1, term k is cos(π k (i - 0.5) / n), where k counts from 0 and n is the length of
initial.In every solution that the engine generates, every element is from
mintomax. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@1to<name>@length, one for each element. The number of elements is the length ofinitial.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline vector; the variable has as many elements asinitialnumFreq- number of cosine terms, including the constant term; fewer give a smoother vector. A value less than 1 is used as 1, and a value greater than the number of elements is used as that number.min- lower bound of every elementmax- upper bound of every element- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddFourierCorrectionMatrixVariable
public boolean AddFourierCorrectionMatrixVariable(String name, double[][] initial, int freqRows, int freqCols, double min, double max) throws com.opttek.optquest.COptQuestException Adds a Fourier correction matrix variable. Its value is a baseline matrix,initial, plus a correction that is a sum of the lowest-frequency cosine terms:freqRowsterms down the columns andfreqColsterms along the rows. Use a Fourier correction matrix variable to keep a known table and change it smoothly.The terms are products of a cosine down the columns and a cosine along the rows, like the terms of the vector type. With one term down the columns, every row of the correction is the same. With one term along the rows, every column of the correction is the same.
In every solution that the engine generates, every entry is from
mintomax. The engine first moves each entry ofinitialinto [min,max].Variable names:
<name>@<row>,<col>for each entry, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloninitial- the baseline matrix; the variable has as many rows and columns asinitialfreqRows- number of cosine terms down each column; fewer make the rows more alike. A value less than 1 is used as 1, and a value greater than the number of rows is used as that number.freqCols- number of cosine terms along each row; fewer make the columns more alike. A value less than 1 is used as 1, and a value greater than the number of columns is used as that number.min- lower bound of every entrymax- upper bound of every entry- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurs while the variable is added
-
AddRegionVariable
public boolean AddRegionVariable(String name, double[][] polygon) throws com.opttek.optquest.COptQuestException Adds a region variable. Its value is a point (x, y) in a plane polygon. Use a region variable when the decision is a location inside a region, such as a site inside a property boundary.In every solution that the engine generates, the point is inside the polygon or on its boundary. The polygon can be non-convex. A point is inside by the even-odd rule, so a polygon whose edges cross itself is also accepted.
Variable names:
<name>@xand<name>@y, the coordinates of the point, in the units of the polygon.Give the vertices in either order, clockwise or counterclockwise. You do not need to repeat the first vertex at the end.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonpolygon- the vertices, one row {x, y} for each vertex; there must be at least three- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifpolygonis null, has fewer than three vertices or has a vertex with fewer than two coordinates, or if the polygon has no area
-
AddSphericalRegionVariable
public boolean AddSphericalRegionVariable(String name, double[][] polygon) throws com.opttek.optquest.COptQuestException Adds a spherical region variable. Its value is a point (latitude, longitude) in a polygon on the surface of the Earth. Use a spherical region variable when the decision is a location inside a geographic region, such as a sensor site inside a border.In every solution that the engine generates, the point is inside the polygon or on its boundary. The edges of the polygon are great-circle arcs, not lines of constant latitude.
List the vertices clockwise, as on a map with north up: the region is on your right as you walk from each vertex to the next. This is the Esri rule for the outer ring of a polygon. The same vertices in counterclockwise order give the rest of the Earth. A region can enclose a pole, span more than 180 degrees of longitude, or be larger than a hemisphere. For a region around the North Pole, list the vertices from east to west. You do not need to repeat the first vertex at the end. The boundary must not cross itself.
Variable names:
<name>@theta: the latitude of the point, in degrees.<name>@phi: the longitude of the point, in degrees, from -180 to 180.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonpolygon- the vertices, one row {latitude, longitude} in degrees for each vertex, with the latitude first; there must be at least three- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifpolygonis null or has a vertex with fewer than two coordinates, a coordinate that is not finite or a latitude outside [-90, 90]; if it has fewer than three different vertices or two consecutive antipodal vertices; or if the boundary doubles back on itself or encloses no area
-
AddSequenceVariable
public boolean AddSequenceVariable(String name, String[] components, Integer topK) throws com.opttek.optquest.COptQuestException Adds a sequence variable. Its value is a priority order of the components. Use a sequence variable when the decision is an order of discrete items, such as a job sequence or the priority of sensor tasks.In every solution that the engine generates, the ranks are valid. In a full ranking, the values are a permutation of 1 to n, where n is the number of components and 1 is the highest priority. In a top-k ranking, the first
topKcomponents get the ranks 1 totopK, and every other component gets the ranktopK+ 1.Variable names:
<name>@<component>for each component, in the order ofcomponents. The value of each name is the integer rank of that component.When a suggested solution gives two components the same rank, the component that comes first in
componentsgets the better rank.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicoloncomponents- names of the components; each must be unique and must not contain whitespace, a semicolon, a comma or@topK- null for a full ranking, or the number of components to rank. A value of n or more gives a full ranking, and a value less than 1 is used as 1. WithtopK= 1, the most important component gets rank 1, and every other component gets rank 2.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifcomponentsis empty or holds a name that is not valid
-
AddMultiStageSequenceVariable
public boolean AddMultiStageSequenceVariable(String name, String[][] stageGroups) throws com.opttek.optquest.COptQuestException Adds a multi-stage sequence variable. Its value is one priority order for each stage, over the components of that stage. Use a multi-stage sequence variable when the decision is a set of orders, one for each stage, such as the job order on each of several machines.In every solution that the engine generates, the ranks in each stage are a permutation of 1 to the number of components in that stage, where 1 is the highest priority. The engine ranks each stage separately.
Variable names:
<name>@<component>for every component, stage by stage, in the order ofstageGroups. The value of each name is the integer rank of that component within its stage.A component name can appear in only one stage. To rank the same item in two stages, give it a different name in each stage.
When a suggested solution gives two components of a stage the same rank, the component that comes first in that stage gets the better rank.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonstageGroups- one array of component names for each stage. Each stage must have at least one component. Each name must be unique across all stages and must not contain whitespace, a semicolon, a comma or@.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifstageGroupsis empty, if a stage is empty, or if a component name is not valid or appears more than once
-
AddPolicySequenceVariable
public boolean AddPolicySequenceVariable(String name, double[][] featureMatrix, String[] itemNames, String[] featureNames) throws com.opttek.optquest.COptQuestException Adds a policy sequence variable. Its value is a priority score for each item of a set, and one weight for each feature of the items. The score of an item is a weighted sum of its features, and the engine chooses the weights. Use a policy sequence variable when a good order depends on a few item attributes, and the weights themselves are a useful result, for example dispatch order by urgency and setup family.In every solution that the engine generates, the item scores come from one set of feature weights applied to the feature matrix. Sort the items by descending score to get the ranked list: a higher score means a higher priority. This is the opposite of a sequence variable, where 1 is the highest priority.
Variable names:
<name>@<itemName>for each item, an input: the priority score of that item.<name>@<featureName>for each feature, an output: the coefficient of that feature, which is the change in score for one unit of the feature. Multiply each raw feature value of an item by its coefficient and add the products to score a new item. That sum can differ from the reported score by a constant that is the same for every item, so it gives the same order.<name>@<featureName>@contributionfor each feature, an output: the signed share of that feature in the rule, in [-1, 1]. The absolute values of all the contributions sum to 1.<name>@<featureName>@confidencefor each feature, an output: a confidence in [0, 1] for the weight of that feature. A feature whose values are all equal gets 0.<name>@<itemName>@confidencefor each item, an output: a confidence in [0, 1] that the item is in the right place relative to its neighbors in the order. With one item, the value is 1.
The engine computes every value of a policy sequence variable. The item scores are inputs. The coefficients, the contributions and the confidences are outputs. Your evaluator can read these outputs, and must not write them. Item names and feature names share one set of names, so every item name and feature name must be different from all the others.
Give the feature values in their own units. You do not need to scale them. In a suggested solution, the engine reads only the item scores, and it can change them. For an evaluated or required solution, the engine computes the coefficient, contribution and confidence outputs from the policy that best fits the supplied item scores. It does not change the scores.
Each item name and feature name must not contain whitespace, a semicolon, a comma or
@.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonfeatureMatrix- feature values, one row for each item and one column for each featureitemNames- names of the items, one for each row offeatureMatrixfeatureNames- names of the features, one for each column offeatureMatrix- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- iffeatureMatrixis empty, if the number of item names is not the number of rows, if the number of feature names is not the number of columns, or if an item name or feature name is not valid or is used more than once
-
AddChoiceVariable
Adds a choice variable. Its value is one option out ofkoptions. Use a choice variable when the decision is one selection from options that have no natural order, such as a machine type, a supplier or an operating mode.In every solution that the engine generates, exactly one option is selected.
Variable names:
<name>@choice, the 1-based index of the selected option, a whole number from 1 tok.In a suggested solution, the engine rounds the value to the nearest whole number from 1 to
k.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonk- number of options; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifkis less than 1
-
AddMultiChoiceVariable
public boolean AddMultiChoiceVariable(String name, String[] choices, int minSelect, int maxSelect) throws com.opttek.optquest.COptQuestException Adds a multi-choice variable. Its value is a subset of the choices that has fromminSelecttomaxSelectmembers. Use a multi-choice variable when the decision is an unordered selection of several items, such as which sensors to turn on or which assets to include.In every solution that the engine generates, each choice is either selected or not, and the number of selected choices is from
minSelecttomaxSelect.Variable names:
<name>@<choice>for each choice, in the order ofchoices. The value of each name is 1 if the choice is selected and 0 if it is not.In a suggested solution, a value greater than 0.5 means that the choice is selected. If more than
maxSelectchoices are selected, the engine keeps the selected choices that come first inchoices. If fewer thanminSelectare selected, the engine adds the unselected choices that come first.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonchoices- names of the choices; each must be unique and must not contain whitespace, a semicolon, a comma or@minSelect- smallest number of selected choices; must be at least 0maxSelect- largest number of selected choices; must be at leastminSelectand at most the number of choices- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifchoicesis empty or holds a name that is not valid, or ifminSelectandmaxSelectare not valid
-
AddDAGVariable
public boolean AddDAGVariable(String name, String[] nodeNames) throws com.opttek.optquest.COptQuestException Adds a DAG variable. Its value is a directed acyclic graph (DAG) over the given nodes: a set of directed edges with no cycle. Use a DAG variable when the decision is a set of one-way links with no loop, such as dependencies between tasks or a flow network.In every solution that the engine generates, the edges form no cycle. Any DAG over the nodes can occur, including the graph with no edges.
Variable names:
<name>@<nodeFrom>,<nodeTo>for every ordered pair of nodes, including a node paired with itself: the full n by n adjacency matrix, row by row in the order ofnodeNames. The value of each name is 1 if the edge fromnodeFromtonodeTois present and 0 if it is not. The diagonal is always 0. Each name contains a comma, so write it in brackets in an expression:[<name>@A,B].In a suggested solution, a value greater than 0.5 is an edge. The engine keeps a suggested DAG as it is. If the suggested edges form a cycle, the engine removes edges until no cycle remains.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonnodeNames- names of the nodes; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or@- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnodeNamesis empty or holds a name that is not valid
-
AddDAGVariable
public boolean AddDAGVariable(String name, String[] nodeNames, String startNode, String endNode, boolean connected, Map<String, List<String>> predecessors) throws com.opttek.optquest.COptQuestExceptionAdds a DAG variable with an optional start node, an optional end node, the connected option and optional precedences. Its value is a directed acyclic graph (DAG) over the given nodes: a set of directed edges with no cycle.In every solution that the engine generates, the edges form no cycle, and:
- the start node, when given, has no incoming edge;
- the end node, when given, has no outgoing edge;
- with
connected, every node can be reached from the start node when there is one, and every node can reach the end node when there is one; - no directed path runs from a node to one of its predecessors.
The variable names and the rules for a suggested solution are the same as for
AddDAGVariable(String, String[]). In a suggested solution, the engine also removes edges that break the start node, the end node or a precedence, and withconnectedit adds edges until the graph is connected.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonnodeNames- names of the nodes; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or@startNode- the node with no incoming edge, or null or emptyendNode- the node with no outgoing edge, or null or emptyconnected- true to connect every node to the start node and the end node; it needs a start node, an end node or bothpredecessors- map from a node to the nodes that must come before it, or null. Names that are not nodes are ignored.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnodeNamesis empty or holds a name that is not valid, if the start or end node is not one of the nodes, if the start node and the end node are the same node, ifconnectedis true with no start node and no end node, if the start node has a predecessor, if the end node is a predecessor, if a node lists itself as a predecessor, or if the precedences form a cycle
-
AddTreeVariable
public boolean AddTreeVariable(String name, String[] nodeNames) throws com.opttek.optquest.COptQuestException Adds a tree variable. Its value is a directed spanning tree over the given nodes: one node is the root, every other node has exactly one incoming edge, and every node can be reached from the root. Use a tree variable when the decision is a hierarchy that connects every node, such as a cueing network or a reporting structure.In every solution that the engine generates, the edges form a spanning tree. The tree has exactly n - 1 edges and no cycle. Any node can be the root.
Variable names:
<name>@<nodeFrom>,<nodeTo>for every ordered pair of nodes, including a node paired with itself: the full n by n adjacency matrix, row by row in the order ofnodeNames. The value of each name is 1 if the edge fromnodeFromtonodeTois present and 0 if it is not. The diagonal is always 0. Each name contains a comma, so write it in brackets in an expression:[<name>@A,B].In a suggested solution, a value greater than 0.5 is an edge. The engine keeps a suggested tree as it is. Otherwise, the engine keeps one incoming edge for each node other than the root, and it uses a suggested edge where it can.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonnodeNames- names of the nodes; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or@- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnodeNamesis empty or holds a name that is not valid
-
AddTreeVariable
public boolean AddTreeVariable(String name, String[] nodeNames, String rootNode, Map<String, List<String>> predecessors) throws com.opttek.optquest.COptQuestExceptionAdds a tree variable with an optional fixed root and optional precedences. Its value is a directed spanning tree over the given nodes: one node is the root, every other node has exactly one incoming edge, and every node can be reached from the root.In every solution that the engine generates, the edges form a spanning tree with exactly n - 1 edges and no cycle. When
rootNodeis given, it is the root of every tree. Otherwise any node can be the root. A node never comes above one of its predecessors: no path from the root to a predecessor passes through the node.The variable names and the rules for a suggested solution are the same as for
AddTreeVariable(String, String[]). In a suggested solution, the engine also changes a tree whose root is notrootNodeor that puts a node above one of its predecessors.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonnodeNames- names of the nodes; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or@rootNode- the root of every tree, or null or empty to let any node be the rootpredecessors- map from a node to the nodes that must come before it, or null. Names that are not nodes are ignored.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnodeNamesis empty or holds a name that is not valid, ifrootNodeis not one of the nodes, if the root node has a predecessor, if a node lists itself as a predecessor, or if the precedences form a cycle
-
AddTopologicalSequenceVariable
public boolean AddTopologicalSequenceVariable(String name, String[] tasks, Map<String, List<String>> predecessors) throws com.opttek.optquest.COptQuestExceptionAdds a topological sequence variable. Its value is an order of the tasks in which every task comes after its predecessors. Use a topological sequence variable when the decision is the order in which to do a set of tasks, and some tasks must always come before others, such as project steps with dependencies or an assembly sequence.In every solution that the engine generates, the order keeps every precedence: a predecessor always has a smaller rank than the task that depends on it.
Variable names:
<name>@<task>for each task, in the order oftasks. The value of each name is the integer rank of that task in the order, where 1 is first and n is last. The ranks are a permutation of 1 to n.In a suggested solution, the engine keeps an order that meets every precedence, and it gives equal ranks different values in the order of
tasks. If the order breaks a precedence, the engine changes it: at each step, of the tasks that can go next, the task with the smallest suggested rank goes next.The engine checks that no task lists itself as a predecessor and that the precedences form no cycle. It ignores names in
predecessorsthat are not intasks.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolontasks- names of the tasks; there must be at least one, and each must be unique and must not contain whitespace, a semicolon, a comma or@predecessors- for each task that has predecessors, the tasks that must come before it; null for no precedences- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- iftasksis empty or holds a name that is not valid, if a task lists itself as a predecessor, or if the precedences form a cycle
-
AddPathVariable
public boolean AddPathVariable(String name, String[] nodeNames, String startNode, String endNode, String[] requiredNodes) throws com.opttek.optquest.COptQuestException Adds a path variable. Its value is a simple path through some of the given nodes: an order of nodes in which no node appears twice. Use a path variable when the decision is a route that visits some of the candidate nodes, such as a patrol route or a delivery tour.In every solution that the engine generates, the path is valid. The positions of the nodes on the path are 1 to L, where L is the length of the path, with no gap and no repeat. The start node, when given, has position 1. The end node, when given and different from the start node, has position L. When the start node and the end node are the same node, it has position 1 only. Every required node is on the path. The path can have only one node.
Variable names:
<name>@<node>for each node, in the order ofnodeNames. The value of each name is the 1-based position of that node on the path, or 0 if the node is not on the path.In a suggested solution, a value of 0 or less means that the node is off the path, and the engine uses the other values only for the order of the nodes. The engine numbers the positions again, and it adds the start node, the end node and the required nodes when they are missing.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonnodeNames- names of the candidate nodes; there must be at least two, and each must be unique and must not contain whitespace, a semicolon, a comma or@startNode- the node at position 1, or null for any start nodeendNode- the node at the last position, or null for any end noderequiredNodes- nodes that must be on the path, or null for none- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnodeNameshas fewer than two nodes or holds a name that is not valid, or ifstartNode,endNodeor a required node is not innodeNames
-
AddAssignmentVariable
public boolean AddAssignmentVariable(String name, int m, int n) throws com.opttek.optquest.COptQuestException Adds an assignment variable. Its value is an assignment of each ofmitems to one ofnbins. Use an assignment variable when the decision is an assignment of items to bins, such as jobs to machines or tasks to workers.The engine adds the assignment rules to the model as constraints, so a solution that breaks a rule is infeasible. With this method, every item is in exactly one bin, and a bin can hold any number of items.
Variable names:
<name>@1to<name>@m, one for each item. The value of each name is the number of the bin that the item is in, counted from 1.In a suggested solution, the engine rounds each value to the nearest bin index. The engine can then change the assignment so that it meets the rules.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of items; must be at least 1n- number of bins; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1
-
AddAssignmentVariable
public boolean AddAssignmentVariable(String name, int m, int n, boolean mustAssign, int binCapacityMin, int binCapacityMax) throws com.opttek.optquest.COptQuestException Adds an assignment variable with the same rules for every item and every bin. Its value is an assignment of each ofmitems to one ofnbins. Use an assignment variable when the decision is an assignment of items to bins, such as jobs to machines or tasks to workers.The engine adds the assignment rules to the model as constraints, so a solution that breaks a rule is infeasible. When
mustAssignis true, every item is in exactly one bin. When it is false, every item is in at most one bin. Every bin holds frombinCapacityMintobinCapacityMaxitems.Variable names:
<name>@1to<name>@m, one for each item. The value of each name is the number of the bin that the item is in, counted from 1, or 0 when the item is in no bin.In a suggested solution, the engine rounds each value to the nearest bin index. A value outside 1 to
nmeans that the item is in no bin. The engine can then change the assignment so that it meets the rules.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of items; must be at least 1n- number of bins; must be at least 1mustAssign- true if every item must be in a bin, false if an item can be in no binbinCapacityMin- smallest number of items in each binbinCapacityMax- largest number of items in each bin- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1, ifbinCapacityMaxis negative or less thanbinCapacityMin, if the bin minimums add up to more thanmitems, or ifmustAssignis true and the bins cannot hold every item
-
AddAssignmentVariable
public boolean AddAssignmentVariable(String name, int m, int n, boolean[] mustAssign, int[] binCapacitiesMin, int[] binCapacitiesMax) throws com.opttek.optquest.COptQuestException Adds an assignment variable with separate rules for each item and each bin. Its value is an assignment of each ofmitems to one ofnbins. Use an assignment variable when the decision is an assignment of items to bins, such as jobs to machines or tasks to workers.The engine adds the assignment rules to the model as constraints, so a solution that breaks a rule is infeasible. Item i is in exactly one bin when
mustAssign[i]is true, and in at most one bin when it is false. Bin j holds frombinCapacitiesMin[j]tobinCapacitiesMax[j]items.Variable names:
<name>@1to<name>@m, one for each item. The value of each name is the number of the bin that the item is in, counted from 1, or 0 when the item is in no bin.In a suggested solution, the engine rounds each value to the nearest bin index. A value outside 1 to
nmeans that the item is in no bin. The engine can then change the assignment so that it meets the rules.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of items; must be at least 1n- number of bins; must be at least 1mustAssign- one entry for each item: true if the item must be in a bin, false if it can be in no binbinCapacitiesMin- one entry for each bin: the smallest number of items in the binbinCapacitiesMax- one entry for each bin: the largest number of items in the bin- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifmornis less than 1, if an array is null or does not have one entry for each item or bin, if a bin maximum is negative or less than its minimum, if the bin minimums add up to more thanmitems, or if the bins cannot hold every item that must be assigned
-
AddItemSelectionVariable
public boolean AddItemSelectionVariable(String name, int n, int k) throws com.opttek.optquest.COptQuestException Adds an item selection variable that selects exactlykofncandidates. Use an item selection variable when the decision is which candidates to include, such as which sites to open. This variable is not the same asAddSelectionVariable(String, String[]), which turns a group of variables on or off.The engine adds the selection rule to the model as a constraint, so a solution that selects a different number of candidates is infeasible.
Variable names:
<name>@1to<name>@n, one for each candidate. These are ordinary binary inputs. The value of each name is 1 if the candidate is selected and 0 if it is not.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of candidates; must be at least 1k- number of candidates to select; must be from 0 ton- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1, or ifkis less than 0 or greater thann
-
AddItemSelectionVariable
public boolean AddItemSelectionVariable(String name, int n, int kMin, int kMax) throws com.opttek.optquest.COptQuestException Adds an item selection variable that selects fromkMintokMaxofncandidates. Use an item selection variable when the decision is which candidates to include, such as which sites to open. This variable is not the same asAddSelectionVariable(String, String[]), which turns a group of variables on or off.The engine adds the selection rule to the model as a constraint, so a solution that selects fewer than
kMinor more thankMaxcandidates is infeasible.Variable names:
<name>@1to<name>@n, one for each candidate. These are ordinary binary inputs. The value of each name is 1 if the candidate is selected and 0 if it is not.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of candidates; must be at least 1kMin- smallest number of candidates to select; must be at least 0kMax- largest number of candidates to select; must be fromkMinton- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1, or if no selection has fromkMintokMaxcandidates
-
AddBudgetedSelectionVariable
public boolean AddBudgetedSelectionVariable(String name, int n, double[] costs, double budgetMax) throws com.opttek.optquest.COptQuestException Adds a budgeted selection variable that selects candidates whose total cost is at mostbudgetMax. Use a budgeted selection variable when the decision is which candidates to include within a budget, such as which projects to fund.The engine adds the budget rule to the model as a constraint, so a solution whose selected candidates cost more than
budgetMaxis infeasible.Variable names:
<name>@1to<name>@n, one for each candidate. These are ordinary binary inputs. The value of each name is 1 if the candidate is selected and 0 if it is not.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of candidates; must be at least 1costs- cost of each candidate, one entry for each candidatebudgetMax- largest total cost of the selected candidates- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1, ifcostsis null or does not havenentries, or ifbudgetMaxis less than the lowest possible total cost
-
AddBudgetedSelectionVariable
public boolean AddBudgetedSelectionVariable(String name, int n, double[] costs, double budgetMin, double budgetMax, int kMin, int kMax) throws com.opttek.optquest.COptQuestException Adds a budgeted selection variable with a budget range and a range for the number of selected candidates. Use a budgeted selection variable when the decision is which candidates to include within a budget, such as which projects to fund.The engine adds the budget and count rules to the model as constraints, so a solution that breaks a rule is infeasible. The total cost of the selected candidates is from
budgetMintobudgetMax, and the number of selected candidates is fromkMintokMax.Variable names:
<name>@1to<name>@n, one for each candidate. These are ordinary binary inputs. The value of each name is 1 if the candidate is selected and 0 if it is not.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of candidates; must be at least 1costs- cost of each candidate, one entry for each candidatebudgetMin- smallest total cost of the selected candidates; 0 or less for no smallest totalbudgetMax- largest total cost of the selected candidateskMin- smallest number of candidates to select; 0 for no smallest numberkMax- largest number of candidates to select;nfor no largest number- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1, ifcostsis null or does not havenentries, if no selection has fromkMintokMaxcandidates, ifbudgetMaxis less than the lowest possible total cost, or ifbudgetMinis positive and greater thanbudgetMaxor than the highest possible total cost
-
AddPartitionVariable
public boolean AddPartitionVariable(String name, int m, int k) throws com.opttek.optquest.COptQuestException Adds a partition variable. Its value is a division ofmitems into exactlykgroups. The groups have no order, and no group is empty. Use a partition variable when the decision is a division of items into groups, such as crews into shifts or customers into delivery zones.In every solution that the engine generates, every group has at least one item, and the same division into groups always gets the same group numbers.
Variable names:
<name>@1to<name>@m, one for each item. The value of each name is the number of the group that the item is in, counted from 1. Item 1 is always in group 1. For each later item, the group number is at most one more than the largest group number among the items before it.In a suggested solution, the engine rounds each value to the nearest group number from 1 to
k. It then fills any empty group and numbers the groups again, so the values can change.- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonm- number of items; must be at leastkk- number of groups; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifkis less than 1 ormis less thank
-
AddBetaRandomVariable
public boolean AddBetaRandomVariable(String name, double alpha, double beta) throws com.opttek.optquest.COptQuestException Adds a Beta-distributed random variable (used as a random input drawn each replication).The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)alpha- shape parameterbeta- shape parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddCauchyRandomVariable
public boolean AddCauchyRandomVariable(String name, double location, double scale) throws com.opttek.optquest.COptQuestException Adds a Cauchy-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)location- location parameterscale- scale parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddChiSquareRandomVariable
public boolean AddChiSquareRandomVariable(String name, int df) throws com.opttek.optquest.COptQuestException Adds a Chi-square-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)df- degrees of freedom- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddExponentialRandomVariable
public boolean AddExponentialRandomVariable(String name, double scale) throws com.opttek.optquest.COptQuestException Adds an exponentially distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)scale- scale parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddGammaRandomVariable
public boolean AddGammaRandomVariable(String name, double shape, double scale) throws com.opttek.optquest.COptQuestException Adds a Gamma-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)shape- shape parameterscale- scale parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddLogNormalRandomVariable
public boolean AddLogNormalRandomVariable(String name, double shape, double scale) throws com.opttek.optquest.COptQuestException Adds a log-normal distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)shape- shape parameterscale- scale parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddNormalRandomVariable
public boolean AddNormalRandomVariable(String name, double mean, double sigma) throws com.opttek.optquest.COptQuestException Adds a normally distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)mean- meansigma- standard deviation- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddParetoRandomVariable
public boolean AddParetoRandomVariable(String name, double gamma, double loc, double scale) throws com.opttek.optquest.COptQuestException Adds a Pareto-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)gamma- shape parameterloc- location parameterscale- scale parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddPoissonRandomVariable
public boolean AddPoissonRandomVariable(String name, double lambda) throws com.opttek.optquest.COptQuestException Adds a Poisson-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)lambda- rate parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddPowerRandomVariable
public boolean AddPowerRandomVariable(String name, double rmin, double rmax, double power) throws com.opttek.optquest.COptQuestException Adds a random variable whose value is fromrmintormax. Usepowerto set where the values are most frequent. Withpower= 1, every value in the range is equally likely. Withpower= 2, the values are the distances from the center of points spread evenly over the area of a ring with the radiirminandrmax. Withpower= 3, they are the distances from the center of points spread evenly over the volume of a spherical shell. With a largerpower, more values are nearrmax. With apowerbetween 0 and 1, more values are nearrmin.The probability density is proportional to
x^(power - 1):pdf(x) = power * x^(power - 1) / (rmax^power - rmin^power)forrmin <= x <= rmax. Withpower= 1, the density is the constant1 / (rmax - rmin).The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)rmin- inner radius; must be non-negativermax- outer radius; must be greater thanrminpower- sets where the values are most frequent, as described above; must be greater than 0. Zero is not the uniform case (uniform ispower = 1), and the engine refuses zero and any negative value- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddSphericalElevationRandomVariable
public boolean AddSphericalElevationRandomVariable(String name, double min, double max) throws com.opttek.optquest.COptQuestException Adds a spherical elevation random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)min- minimum elevationmax- maximum elevation- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddStudentTRandomVariable
public boolean AddStudentTRandomVariable(String name, int df) throws com.opttek.optquest.COptQuestException Adds a Student's t-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)df- degrees of freedom- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddUniformRandomVariable
public boolean AddUniformRandomVariable(String name, double min, double max) throws com.opttek.optquest.COptQuestException Adds a uniform random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)min- minimum valuemax- maximum value- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddWeibullRandomVariable
public boolean AddWeibullRandomVariable(String name, double shape, double scale) throws com.opttek.optquest.COptQuestException Adds a Weibull-distributed random variable.The engine draws a new value at the start of every replication. Without
SetReplications(int), each trial solution has one replication, so it gets one draw, and its result depends on that one draw. To compare trial solutions by the combined result of several draws, callSetReplicationswith more than one replication.- Parameters:
name- name of the variable (must be unique, no whitespace or ;)shape- shape parameterscale- scale parameter- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred adding the variable
-
AddOutputVariable
Adds an output variable. You set the value of an output variable. It can be an output of a simulation or a value calculated from the values of decision variables. Output variables can be used in the mathematical expression of constraints and objectives.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
SetOutputStatistic
public boolean SetOutputStatistic(String name, int statistic) throws com.opttek.optquest.COptQuestException Defines the statistic for the replications of an output variable. Available statistics include:- Statistic.None = 0
- Statistic.Mean = 1
- Statistic.Median = 2
- Statistic.StdDev = 4
- Statistic.Variance = 6
- Statistic.CoeffOfVar = 8
- Statistic.Min = 14
- Statistic.Max = 15
- Statistic.Sum = 16
With
Statistic.None, the result is the same as with no call: the engine uses the mean of the replications. The exception is an output that is used by an objective with its own statistic. The engine does not combine that output, soGetValueon it returns the value of the replication that completed last.- Parameters:
name- - name of the output variablestatistic- - the statistic to be applied to the output- Returns:
- - true if the statistic was added successfully; false if an output with the name does not exist.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
SetOutputStatistic
public boolean SetOutputStatistic(String name, int statistic, double statisticValue) throws com.opttek.optquest.COptQuestException Defines the percentile statistic for the replications of an output variable.- Parameters:
name- - name of the output variable.statistic- - Statistic.PercentilestatisticValue- - target value- Returns:
- - true if the statistic was added successfully; false if an output with the name does not exist.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
AddOutputVectorVariable
public boolean AddOutputVectorVariable(String name, int n) throws com.opttek.optquest.COptQuestException Adds an output vector variable:noutput variables. The elements are ordinary output variables.Variable names:
<name>@1to<name>@n, one for each element.Your evaluator writes a value to each element before it submits the solution.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonn- number of elements; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifnis less than 1
-
AddOutputMatrixVariable
public boolean AddOutputMatrixVariable(String name, int rows, int cols) throws com.opttek.optquest.COptQuestException Adds an output matrix variable: arowsbycolsmatrix of output variables. The elements are ordinary output variables.Variable names:
<name>@<row>,<col>for each element, with 1-based row and column numbers, row by row. Each name contains a comma, so write it in brackets in an expression:[<name>@1,2].Your evaluator writes a value to each element before it submits the solution.
- Parameters:
name- base name of the variable; it must be unique and must not contain whitespace or a semicolonrows- number of rows; must be at least 1cols- number of columns; must be at least 1- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- ifrowsorcolsis less than 1
-
AddExpressionVariable
public boolean AddExpressionVariable(String name, String expression) throws com.opttek.optquest.COptQuestException Defines a variable that is evaluated as an expression of other variables in the model. The expression may include variables and outputs. For example, the objective may be to minimize "2*Var1 + 3*Var2 + 1.5*Var3". "Var1", "Var2" and "Var3" must be names that were assigned to variables. A list of the supported mathematical functions can be found in the "Functions Available In Expressions" section in the Help.- Parameters:
name- - name of the variable. The name must be unique to the model and must not contain whitespace or semicolons.expression- - the string expression.- Returns:
- true if the variable was added; false if the name is not valid, for example if it is already in use or contains whitespace or a semicolon
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the expression variable.
-
AddConstraint
public boolean AddConstraint(String name, String expression) throws com.opttek.optquest.COptQuestException Defines a linear or non-linear constraint where the expression may include variables and outputs. "2*Var1 + 3*Var2 + 1.5*Var3 ≤ 100" could be used to define a budget constraint. "Var1", "Var2" and "Var3" must be names that were assigned to variables. A list of the supported mathematical functions can be found in the "Functions Available In Expressions" section in the Help.The engine checks a constraint that uses only ordinary input variables before the evaluation. In every solution that the engine generates, the inputs meet the constraint. The engine checks a constraint that uses an output, or an expression that depends on an output, after the evaluation. A solution that breaks it is infeasible.
A constraint that uses a value of a manifold variable is checked after the evaluation, like a constraint on an output. These values have names with
'@', such asmix@compAordir@theta, andCOptQuestManifoldVariable.getProjectedInputVariables()returns them. The same applies to a constraint that uses a random variable. Your evaluator can receive values that break such a constraint, and the solution is then infeasible. The values of an item selection variable and a budgeted selection variable are ordinary inputs.- Parameters:
name- - name of the constraint. The name must be unique to the model and must not contain whitespace or semicolons.expression- - the string expression.- Returns:
- - true if the constraint was added successfully; false if the name was not unique to the model or contained whitespace or semicolons.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the constraint.
-
AddObjective
Defines an objective whose value the optimizer minimizes or maximizes. The expression may include variables and outputs. For example, the objective may be to minimize "2*Var1 + 3*Var2 + 1.5*Var3". "Var1", "Var2" and "Var3" must be names that were assigned to variables. A list of the supported mathematical functions can be found in the "Functions Available In Expressions" section in the Help.- Parameters:
name- - name of the objective. The name must be unique to the model and must not contain whitespace or semicolons.dir- - "MIN" or "MAX"expression- - the string expression.- Returns:
- - true if the objective was added successfully; false if objective name is not unique or contains whitespace or semicolons.
-
AddMinimizeObjective
Defines an objective whose value the optimizer minimizes. The expression may include variables and outputs. For example, the objective may be to minimize "2*Var1 + 3*Var2 + 1.5*Var3". "Var1", "Var2" and "Var3" must be names that were assigned to variables. A list of the supported mathematical functions can be found in the "Functions Available In Expressions" section in the Help.- Parameters:
name- - name of the objective. The name must be unique to the model and must not contain whitespace or semicolons.expression- - the string expression.- Returns:
- - true if the objective was added successfully; false if objective name is not unique or contains whitespace or semicolons.
-
AddMaximizeObjective
Defines an objective whose value the optimizer maximizes. The expression may include variables and outputs. For example, the objective may be to maximize "2*Var1 + 3*Var2 + 1.5*Var3". "Var1", "Var2" and "Var3" must be names that were assigned to variables. A list of the supported mathematical functions can be found in the "Functions Available In Expressions" section in the Help.- Parameters:
name- - name of the objective. The name must be unique to the model and must not contain whitespace or semicolons.expression- - the string expression.- Returns:
- - true if the objective was added successfully; false if the objective name is not unique to the model or contains whitespace or semicolons.
-
SetObjectiveGoal
Sets a target range, from min to max inclusive, for an objective in a model with two or more objectives. It is ignored if the model has a single objective.OptQuest uses the goal to decide where to search. After its first cycle of search phases, OptQuest uses the rest of the run to fill gaps between neighboring solutions on the Pareto frontier, while the frontier has at least two solutions. It fills first the largest gap next to a frontier solution whose objective values are inside the most goal ranges. OptQuest does not use the goal to decide feasibility, and it does not remove the solutions outside the range from the frontier:
GetBestSolutions()can return them.- Parameters:
name- - name of the objectivemin- - minimum value of the goal range.max- - maximum value of the goal range.- Returns:
- - true if the goal range was successfully added; false if an objective with the specified name does not exist in the model.
-
SetObjectiveConfidence
Sets the values used for replication confidence testing on the specified objective. Confidence testing is only available when the replication statistic is the mean value, OptQuestModel.Statistic.MeanWith these set, OptQuest stops replicating a trial solution when the half-width of the confidence interval at the level
clevelis at mostepcttimes the absolute value of the mean of the replications.- Parameters:
name- - name of the objectivectype-- OptQuestModel.Confidence.Type1 = indicates the replications should stop after the minimum replications have been run and when the confidence level is reached or the maximum number of replications is run.
- OptQuestModel.Confidence.Type2 = indicates the replications should stop after the minimum replications are run and the confidence level is reached, or the maximum number of replications is run, or when the best solution does not fall within current solutions confidence level. Type 2 is not available for COptQuestMultiObjective.
clevel-- OptQuestModel.Confidence.Level80 = 80%
- OptQuestModel.Confidence.Level90 = 90%
- OptQuestModel.Confidence.Level95 - 95%
- OptQuestModel.Confidence.Level98 = 98%
- OptQuestModel.Confidence.Level99 = 99%
- OptQuestModel.Confidence.Level999 = 99.9%
epct- - the acceptable error, as a fraction of the mean of the replications. It must be greater than 0 and less than 1. For 5 percent, pass 0.05. The engine checks the value when the model initializes, not at this call. With a value outside that range, the run fails with the message "Bad value for the replication confidence error percent."- Returns:
- - true if the objective confidence was set successfully. false if it failed.
-
SetObjectiveStatistic
public boolean SetObjectiveStatistic(String name, int statistic) throws com.opttek.optquest.COptQuestException Defines the statistic for the replications of an objective. Available statistics include:- Statistic.None = 0
- Statistic.Mean = 1
- Statistic.Median = 2
- Statistic.StdDev = 4
- Statistic.Variance = 6
- Statistic.CoeffOfVar = 8
- Statistic.Min = 14
- Statistic.Max = 15
- Statistic.Sum = 16
With
Statistic.None, or with no call, the engine combines each output that the objective uses, with the statistic of that output (the mean unlessSetOutputStatistic(String, int)sets another), and computes the objective expression once from those values. With any other statistic, the engine computes the expression in each replication and applies the statistic to those values. For an objectivey*yand two replications with y = 1 and y = 3, no statistic gives 4.0,Statistic.Meangives 5.0 andStatistic.Maxgives 9.0. When the model initializes, the engine refuses a statistic on the objective together with a statistic other thanNoneon an output that the objective uses.- Parameters:
name- - name of the objective variablestatistic- - the statistic to be applied to the objective- Returns:
- - true if the statistic was added successfully; false if the add failed.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred setting the statistic
-
SetObjectiveStatistic
public boolean SetObjectiveStatistic(String name, int statistic, double statisticValue) throws com.opttek.optquest.COptQuestException Defines the percentile statistic for the replications of an objective.- Parameters:
name- - name of the objective variable.statistic- - Statistic.PercentilestatisticValue- - target value- Returns:
- - true if the statistic was added successfully; false if the add failed.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the variable.
-
SetReplications
public boolean SetReplications(int reps) Sets the number of fixed replications to be run for each solution. A value of 1 runs without replications.- Parameters:
reps- - number of replications to be run on each solution.- Returns:
- - true if replications were set successfully.
-
SetReplications
public boolean SetReplications(int min, int max) Sets the number of variable replications to be run for each solution. Variable replications are used with confidence settings to control when replication processing is complete. min must be at least 1 and max at least min; max of 1 runs without replications. A confidence interval needs two replications, so a min of 1 runs at least 2 when max is greater than 1.The replications stop early when the objective meets the confidence set with
SetObjectiveConfidence(String, int, int, double). WithoutSetObjectiveConfidence, the engine runsmaxreplications for every trial solution.SetObjectiveStatistic(String, int)andSetOutputStatistic(String, int)set how the engine combines the replications into one value. They do not stop the replications early.- Parameters:
min- - minimum number of replications to be run on each solution.max- - maximum number of replications to be run on each solution.- Returns:
- - true if replications were set successfully.
-
SetSerialReplications
public boolean SetSerialReplications()Runs the replications of each solution serially. If you are running replications and using multiple evaluators, the replication solutions can be run in parallel, or they can be run serially. If they are run in parallel, solution n, replication 1 can be evaluated at the same time as solution n, replication 2. If you run the replications serially, solution n, replication 1 must finish before solution n, replication 2 can be run, and they could both run on the same evaluator. Running serially may be beneficial if your simulation requires a warm-up period.Most users do not need this method. It has an effect only on a model with replications whose solutions are evaluated in parallel.
- Returns:
- true if the serial replication management was set successfully.
-
SetParallelHint
public boolean SetParallelHint(int npar) Sets a hint for the number of parallel evaluations that are expected to happen. This should correspond to the number of processors/computer available for evaluation. OptQuest defaults to a single evaluator, so this method is only needed if more than one evaluator is desired. This value is a hint to how many solutions are expected to be evaluated in parallel. It is used to configure the internal metaheuristics. During evaluation any number (up to 5000) solutions may be evaluated in parallel. Optimization will be most efficient when the number matches this hint.Most users do not need this method. It has an effect only in a manual loop with several solutions out at once. The parallel
Optimize(npar, ...)methods set the hint to their ownnpar.- Parameters:
npar- number of parallel evaluators- Returns:
- true if the hint was set successfully.
-
SetRandomSeed
public boolean SetRandomSeed(int seed) Sets the random seed. The engine uses the random seed in solution generation, so a change to the seed can change the set of solutions.Use it to find out how much a result depends on the random choices of the search: run the same model with several seeds and compare the best objective values. By default the engine always uses the same seed, so an optimization is repeatable.
- Parameters:
seed- value to be used as the random seed; it must be greater than 0. A seed of 0 or less is accepted but ignored, and the default seed is used.- Returns:
- true if the random seed was set.
-
StopOnSuccessfulMILP
public boolean StopOnSuccessfulMILP()Sets a flag so that the optimization stops as soon as it finds an optimal solution in the case that the optimization is a mixed integer linear program (MILP).- Returns:
- true if the flag was set.
-
SuggestedSolutionsOnly
public boolean SuggestedSolutionsOnly()Restricts the model to the solutions you supply. OptQuest evaluates the solutions added withAddSuggested(),AddEvaluated()andAddRequired(), and generates none of its own.Suggested solutions are still mapped to the feasible space and still checked for duplicates, so you can use the model as a batch mapper: supply a set of points and
CreateSolution()returns the ones that map to distinct feasible solutions. When the supplied solutions run out,CreateSolution()returns an invalid solution andGetTerminationReason()reportsFactoriesDone, so the caller reads back however many solutions remain without knowing the count in advance.Only
AddSuggested()points are mapped. The solutions from all three supply methods are evaluated and deduplicated, but the engine maps to the feasible space only the solutions fromAddSuggested(). A solution fromAddEvaluated()holds a response that was already measured for its input values, and a solution fromAddRequired()is evaluated exactly as supplied. So the engine deliberately does not map either kind, and they come back with the caller's raw values.The model still requires an objective, and each solution returned by
CreateSolution()must be returned to the engine withSubmit()orReject(). The engine checks for duplicates across the whole run rather than in a single batch, and a model cannot be refilled after its supplied solutions are used up. OnceCreateSolution()reports the queue empty, solutions added afterwards are accepted but never evaluated. So use a separate model for each set of points that should be mapped independently.Use this mode with the manual
CreateSolution()loop, not withOptimize(n, ...). Running out of supplied solutions is the normal end of a mapping run, but the serialOptimize(nsol, ...)overload reports it as a failure: it returnsfalseonce the supplied solutions are exhausted beforensolis reached, without throwing and with no error message, so a successful mapping run returns the same value as a real failure. The parallel overload returnstruein the same situation. In this mode the caller does not know in advance how many solutions remain, sonsolis almost always larger than that number.Must be called before the model is initialized.
- Returns:
- true if the flag was set.
-
SetStopCycles
public boolean SetStopCycles(int cycles) Stops the optimization aftercyclessearch cycles. The run then ends with the termination reasonAutoStop(4). A search cycle is one pass of the engine's search methods, and the number of iterations in a cycle depends on the problem. An improvement of the best solution does not reset the count of cycles.- Parameters:
cycles- - the number of cycles to try before stopping.- Returns:
- true if the cycles were set successfully.
-
SetStopImprovement
public boolean SetStopImprovement(double improvement, int iterations) Stops the optimization wheniterationsconsecutive iterations pass without a cumulative improvement of more than the fractionimprovement. The improvement is relative, measured against the best and worst feasible objective values found so far. For example,SetStopImprovement(0.01, 100)stops the run when, over the last 100 iterations, the best objective changed by 1 percent or less of the difference between the best and the worst feasible objective values. The run then ends with the termination reasonAutoStop(4).The rule applies only to a model with one objective. The engine ignores it when the model has two or more objectives.
- Parameters:
improvement- - the fraction; use a value from 0.0 to 0.2iterations- - number of consecutive iterations- Returns:
- true if the stopping rule was set successfully.
-
SetStopTime
public boolean SetStopTime(int seconds) Sets the number of seconds the optimization should run before stopping. The current iteration will complete before the optimization stops. If the evaluation is long (such as running a simulation) the actual time the optimization runs may be longer than specified.- Parameters:
seconds- maximum number of seconds- Returns:
- true if the stop time was set successfully.
-
AddSampleMetric
Defines a response metric and an error metric that the engine tracks for adaptive sampling. The expressions may include variables and outputs. For example, the objective may be to minimize "2*Var1 + 3*Var2 + 1.5*Var3". "Var1", "Var2" and "Var3" must be names that were assigned to variables. A list of the supported mathematical functions can be found in the "Functions Available In Expressions" section in the Help.- Parameters:
name- - name of the objective. The name must be unique to the model.responseExpression- - the string expression for the response value to track.errorExpression- - the string expression for the error in the response value.- Returns:
- - true if the objective was added successfully; false if the add failed.
-
SetSampleMethod
public boolean SetSampleMethod(int method) Sets the sample method to be used when using sample metrics. Available sampling methods include:- SampleMethod.Stochastic
- SampleMethod.Dynamic
- SampleMethod.Async
- SampleMethod.Variance
- SampleMethod.Uniform
- SampleMethod.Zero
- SampleMethod.Gradient
- SampleMethod.Min
- SampleMethod.Max
- Parameters:
method- - bitwise or'd values to turn on one or more of the sampling methods- Returns:
- true if the sampling method was set successfully.
-
SetSampleVariogram
Sets the sample variogram to be used when building the surrogate model. By default the engine chooses a variogram with a heuristic. Most users do not need this method: use the default unless OptTek support advises a different variogram. Available variograms include:- SampleVariogram.Spherical
- SampleVariogram.Pow
- SampleVariogram.Exp
- SampleVariogram.Gaussian
- SampleVariogram.Tanh
- SampleVariogram.Sech
- SampleVariogram.Linear
- SampleVariogram.Quadratic
- SampleVariogram.Partition
- SampleVariogram.Matern
- Parameters:
variogram- - name of the variogram to use- Returns:
- true if the sampling variogram was set successfully.
-
SetSampleRDSParams
Sets the bins to use if response distribution sampling is enabled, from a named distribution.- Parameters:
name- - metric namedistribution- - name of the distributionparams- - parameters for the distribution- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSUniform
Sets the bins to use if response distribution sampling is enabled, from a uniform distribution.- Parameters:
name- - metric namenBins- - number of binsa- Lower boundb- Upper bound- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSNormal
Sets the bins to use if response distribution sampling is enabled, from a normal distribution.- Parameters:
name- - metric namenBins- - number of binsmu- Meansigma- Standard deviation- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSLogNormal
Sets the bins to use if response distribution sampling is enabled, from a log-normal distribution.- Parameters:
name- - metric namenBins- - number of binss- Shape parameterscale- Scale parameter- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSBeta
Sets the bins to use if response distribution sampling is enabled, from a Beta distribution.- Parameters:
name- - metric namenBins- - number of binsalpha- Shape parameterbeta- : Shape parameter- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSPoisson
Sets the bins to use if response distribution sampling is enabled, from a Poisson distribution.- Parameters:
name- - metric namenBins- - number of binslambda- Rate parameter- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSExponential
Sets the bins to use if response distribution sampling is enabled, from an exponential distribution.- Parameters:
name- - metric namenBins- - number of binsscale- Scale parameter.- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSCauchy
Sets the bins to use if response distribution sampling is enabled, from a Cauchy distribution.- Parameters:
name- - metric namenBins- - number of binslocation- Location parameter.scale- Scale parameter.- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSGamma
Sets the bins to use if response distribution sampling is enabled, from a Gamma distribution.- Parameters:
name- - metric namenBins- - number of binsa- Shape parameterscale- Scale parameter.- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSChiSquare
Sets the bins to use if response distribution sampling is enabled, from a Chi-square distribution.- Parameters:
name- - metric namenBins- - number of binsnu- Degrees of freedom- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSPareto
Sets the bins to use if response distribution sampling is enabled, from a Pareto distribution.- Parameters:
name- - metric namenBins- - number of binsgamma- Shape parameter.loc- Location parameter.scale- Scale parameter.- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDST
Sets the bins to use if response distribution sampling is enabled, from a Student's t distribution.- Parameters:
name- - metric namenBins- - number of binsnu- Degrees of freedom- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSWeibull
Sets the bins to use if response distribution sampling is enabled, from a Weibull distribution.- Parameters:
name- - metric namenBins- - number of binsc- Shape parameterscale- Scale parameter- Returns:
- true if the sampling method was set successfully.
-
SetSampleRDSDiscrete
Sets the bins to use if response distribution sampling is enabled, from a list of bin edges.- Parameters:
name- - metric namebinEdges- list of binEdges to use for an arbitrary response distribution- Returns:
- true if the sampling method was set successfully.
-
Describe
Generates a string describing the model parameters.- Returns:
- string that describes the model setup
-
Initialize
public boolean Initialize() throws com.opttek.optquest.COptQuestExceptionPrepares the model to run and moves it from the definition stage to the execution stage, after which the model is immutable.Calling this is optional: every method that needs an initialized model calls it first. Call it explicitly only to find out whether the model is well formed before generating any solutions.
- Returns:
- true if the model initialized successfully.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there was an error building the model.
-
Interrupt
public void Interrupt()Signals the OptQuestModel to stop generating new solutions during manual optimization loops. Only used for manual optimizations. -
Continue
public void Continue()Restarts an optimization that was interrupted with a call to Interrupt(). Only used for manual optimizations. After Interrupt(), no new solutions will be generated unless Continue() is called. -
CleanUp
public void CleanUp()Closes the log files opened byLogSetup(String)andLogSolutions(String).The setup log is XML and is only well formed once its closing elements are written, so a model that logged its setup must be cleaned up before the file is read. Calling this more than once is harmless. It is called for you when the model is deleted through the C API or a language binding; a caller holding the Java object directly has no other way to release the files, which stay locked on Windows until the process exits.
-
CreateSolution
Requests the OptQuestModel to generate a new trial solution for evaluation. Only used for manual optimizations. OptQuest populates the solution with values for each input variable. Each output that your evaluator writes (an output variable, or an element of an output vector, matrix or N-dimensional variable) is NaN until you set it. If you submit the solution with an output that is not set, each objective and constraint that uses the output is NaN, and the solution is infeasible.- Returns:
- - Returns an OptQuestSolution, never null. Test IsValid() on it: false means the engine had no further solution to offer, or the model failed to initialize. Call GetTerminationReason() to tell those apart.
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred
-
GetEmptySolution
Creates an empty OptQuestSolution. This method can be used to create a suggested solution by setting values for each of the variables in the model. Call OptQuestSolution.AddSuggested() to add the solution to the model.Use the solution with
AddSuggested(),AddEvaluated()orAddRequired(). Do not callSubmit()orReject()on it: the engine did not issue it, and Java does not refuse the call.- Returns:
- - returns an empty OptQuestSolution
- Throws:
com.opttek.optquest.COptQuestException- An exception is thrown if an error occurred creating an empty solution.
-
CopySolution
public OptQuestSolution CopySolution(OptQuestSolution src) throws com.opttek.optquest.COptQuestException Make a copy of the input OptQuestSolution. This can be used to populate a new OptQuestModel instance with solutions from a previously run OptQuestModel. After calling CopySolution(), call AddEvaluated() for the copied solution.The copy contains the input values, the output values, and the per-replication values of each output. Each manifold variable in the copy has the same values as in
src.Use the copy with
AddSuggested(),AddEvaluated()orAddRequired(). Do not callSubmit()orReject()on it: the engine did not issue it, and Java does not refuse the call.- Parameters:
src- - the solution to be copied- Returns:
- - the copy of
src. If the model cannot initialize, the method returns a solution for whichOptQuestSolution.IsValid()returns false. - Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred copying the solution.
-
AddAllSolutions
Copies every evaluated solution of the source modelsrcinto this model. Use it to continue an optimization after you change the model, for example its constraints or objectives. Each copy is added in the same way as withAddEvaluated(): the engine does not evaluate it again, and it uses its input and output values as given. The engine computes the objectives and constraints of each copy with the definitions of this model, so a copy that breaks a constraint of this model is infeasible.The two models must declare the same input names and the same output names, compared without regard to case. The variable types are not compared. If the names are different, the call returns false and copies nothing.
- Parameters:
src- - OptQuestModel with evaluated solutions.- Returns:
- - true if every solution was copied; false if the names are different or a copy failed
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if an error occurred adding the solutions.
-
CreateAsyncChannel
Creates an asynchronous communication channel to send signals to the model during an optimization- Parameters:
npar- - number of concurrent threads to support in Optimize call().- Returns:
- - OptQuestModelChannel object tied to this model.
-
Optimize
public boolean Optimize(int nsol) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated.- Parameters:
nsol- - number of solutions to generate before stopping.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during the optimization.
-
Optimize
public boolean Optimize(int nsol, IOptQuestEvaluator eval) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. The custom evaluator eval will be called to evaluate each solution.- Parameters:
nsol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during the optimization.
-
Optimize
public boolean Optimize(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. The custom evaluator eval.Evaluate() will be called to evaluate each solution. When a solution has completed evaluation and OptQuest has updated the best solution or frontier solutions, the custom monitor.Monitor() is called.- Parameters:
nsol- - number of solutions to generateeval- - custom class used to evaluate each solution.monitor- - custom class to monitor optimization progress.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during the optimization.
-
Optimize
public boolean Optimize(int npar, int nsol) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. The optimization is run with npar number of parallel evaluators meaning npar evaluations will be done in parallel.- Parameters:
npar- - number of parallel evaluators to usensol- - number of solutions to generate- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during the optimization.
-
Optimize
public boolean Optimize(int npar, int nsol, IOptQuestEvaluator eval) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. The optimization is run with npar number of parallel evaluators meaning npar evaluations will be done in parallel. The custom evaluator eval.Evaluate() will be called to evaluate each solution.- Parameters:
npar- - number of parallel evaluators to usensol- - number of solutions to generateeval- - custom class used to evaluate each solution.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during the optimization.
-
Optimize
public boolean Optimize(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. The optimization is run with npar number of parallel evaluators meaning npar evaluations will be done in parallel. The custom evaluator eval.Evaluate() will be called to evaluate each solution. When a solution has completed evaluation and OptQuest has updated the best solution or frontier solutions, the custom monitor.Monitor() is called.- Parameters:
npar- - number of parallel evaluators to usensol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.monitor- - custom class to monitor optimization progress.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- throws a COptQuestException if an error occurred during the optimization.
-
Optimize
public boolean Optimize(OptQuestModelChannel ipc, int nsol) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. Signals are sent to the OptQuestModelChannel as the optimization progresses.- Parameters:
ipc- - an asynchronous communication channel.nsol- - number of solutions to generate- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- throws a COptQuestException if an error occurred during the optimization.
-
Optimize
public boolean Optimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. Signals are sent to the OptQuestModelChannel as the optimization progresses. The custom evaluator eval.Evaluate() will be called to evaluate each solution.- Parameters:
ipc- - an asynchronous communication channel.nsol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- throws a COptQuestException if an error occurred during the optimization.
-
Optimize
public boolean Optimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) throws com.opttek.optquest.COptQuestException Starts the optimization and stops when nsol solutions have been evaluated. Signals are sent to the OptQuestModelChannel as the optimization progresses. The custom evaluator eval.Evaluate() will be called to evaluate each solution. When a solution has completed evaluation and OptQuest has updated the best solution or frontier solutions, the custom monitor.Monitor() is called.- Parameters:
ipc- - an asynchronous communication channel.nsol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.monitor- - custom class to monitor optimization progress.- Returns:
- - true if the optimization completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- throws a COptQuestException if an error occurred during the optimization.
-
Sample
public boolean Sample(int nsol) throws com.opttek.optquest.COptQuestException Starts an adaptive sampling run and stops when nsol solutions have been evaluated. In a sampling run, the engine explores the response surface described by the metrics registered withAddSampleMetric(com.opttek.optquest.COptQuestStringObjective, com.opttek.optquest.COptQuestStringObjective)rather than searching for an optimum.- Parameters:
nsol- - number of solutions to generate- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(int nsol, IOptQuestEvaluator eval) throws com.opttek.optquest.COptQuestException Starts an adaptive sampling run and stops when nsol solutions have been evaluated. The custom evaluator eval will be called to evaluate each solution.- Parameters:
nsol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) throws com.opttek.optquest.COptQuestException Starts an adaptive sampling run and stops when nsol solutions have been evaluated. The custom evaluator eval.Evaluate() will be called to evaluate each solution, and monitor.Monitor() is called once each solution has been processed.- Parameters:
nsol- - number of solutions to generateeval- - custom class used to evaluate each solution.monitor- - custom class to monitor sampling progress.- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(int npar, int nsol) throws com.opttek.optquest.COptQuestException Starts a concurrent adaptive sampling run using npar parallel evaluators and stops when nsol solutions have been evaluated.- Parameters:
npar- - number of solutions to evaluate concurrentlynsol- - number of solutions to generate- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(int npar, int nsol, IOptQuestEvaluator eval) throws com.opttek.optquest.COptQuestException Starts a concurrent adaptive sampling run using npar parallel evaluators. The custom evaluator eval will be called to evaluate each solution.- Parameters:
npar- - number of solutions to evaluate concurrentlynsol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) throws com.opttek.optquest.COptQuestException Starts a concurrent adaptive sampling run using npar parallel evaluators. The custom evaluator eval.Evaluate() will be called to evaluate each solution, and monitor.Monitor() is called once each solution has been processed.- Parameters:
npar- - number of solutions to evaluate concurrentlynsol- - number of solutions to generateeval- - custom class used to evaluate each solution.monitor- - custom class to monitor sampling progress.- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(OptQuestModelChannel ipc, int nsol) throws com.opttek.optquest.COptQuestException Starts an asynchronous adaptive sampling run. Solutions are delivered through the supplied channel rather than through an evaluator callback.- Parameters:
ipc- - channel created byCreateAsyncChannel(int)nsol- - number of solutions to generate- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) throws com.opttek.optquest.COptQuestException Starts an asynchronous adaptive sampling run with a custom evaluator.- Parameters:
ipc- - channel created byCreateAsyncChannel(int)nsol- - number of solutions to generateeval- - custom evaluator used to evaluate each solution.- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
Sample
public boolean Sample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) throws com.opttek.optquest.COptQuestException Starts an asynchronous adaptive sampling run with a custom evaluator and monitor.- Parameters:
ipc- - channel created byCreateAsyncChannel(int)nsol- - number of solutions to generateeval- - custom class used to evaluate each solution.monitor- - custom class to monitor sampling progress.- Returns:
- - true if the sampling run completed successfully. Return false if there were any errors.
- Throws:
com.opttek.optquest.COptQuestException- - An exception is thrown if there were any errors in the model setup or during sampling.
-
GetBestSolutions
If the OptQuestModel has a single objective, this method returns the best solution. If the model has multiple objectives, this method returns the points on the frontier.The list is empty when the model has no completed iterations, for example before the first run or after a failed initialization, so test its length before you read the first entry. The first entry can be infeasible when the run found no feasible solution, so test
OptQuestSolution.IsFeasible()on it.For a single objective, the feasible solutions come first, then the infeasible solutions, then the solutions that the evaluator rejected, whose objective is NaN. Each group is in objective order, and equal values are in iteration order. The order does not depend on the size of a constraint violation, so when no solution is feasible, the first entry is the infeasible solution with the best objective value. For several objectives, the frontier is in no particular order.
- Returns:
- - The best solution for a single objective model. The points on the frontier for a multi-objective model.
-
GetBestSolutions
If the OptQuestModel has a single objective, this method returns the best n solutions where n is the limit parameter. If limit equals 0, all solutions are returned, ordered from best to worst. If limit is less than 0, the worst |limit| solutions are returned, worst first. If the model has multiple objectives, this method returns the points on the frontier.The list is empty when the model has no completed iterations, for example before the first run or after a failed initialization, so test its length before you read the first entry. The first entry can be infeasible when the run found no feasible solution, so test
OptQuestSolution.IsFeasible()on it.For a single objective, the feasible solutions come first, then the infeasible solutions, then the solutions that the evaluator rejected, whose objective is NaN. Each group is in objective order, and equal values are in iteration order. The order does not depend on the size of a constraint violation, so when no solution is feasible, the first entry is the infeasible solution with the best objective value. An infeasible solution whose objective is NaN, for example because the evaluator did not set an output that the objective uses, comes after the infeasible solutions whose objective is a number, for a minimized and for a maximized objective. For several objectives, the frontier is in no particular order.
- Parameters:
limit- - for a single objective OptQuestModel, the top n solutions are returned where n = limit.- Returns:
- - the points on the frontier for a multi objective model. For a single objective model, the top n solutions.
-
GetAllSolutions
Returns all evaluated solutions.- Returns:
- list of evaluated solutions.
- Throws:
com.opttek.optquest.COptQuestException- if an error occurred
-
GetNumberOfCompletedIterations
public int GetNumberOfCompletedIterations()Returns the number of solutions that have been evaluated. The count includes feasible solutions, infeasible solutions and rejected solutions.- Returns:
- - the number of solutions.
-
GetMaxReplications
public int GetMaxReplications()Returns the maximum number of replications set bySetReplications(int, int), or 0 before the model has initialized successfully.- Returns:
- the maximum replication count, or 0 if the model is not yet initialized
-
GetTerminationReason
public int GetTerminationReason()Returns why the last run stopped, as one of theOptQuestModel.TerminationReasonconstants.- NotStarted = 0
- No run has started.
- Running = 1
- A run is in progress, or
Continue()cleared an interrupt. - LP = 3
- The objective and every constraint are linear, and the engine solved the problem exactly.
- AutoStop = 4
- The engine stopped the run because of a stop rule set with
SetStopCycles(int)orSetStopImprovement(double, int). - OptimalFound = 5
- The engine has no other candidate to try, for example because it evaluated every combination of values or because the constraints fix the values.
- MaxIterations = 6
- The run completed the number of iterations that you asked for.
- MaxTime = 7
- The engine stopped the run because it reached the time set with
SetStopTime(int). - UserStopped = 8
- The run was stopped, for example by
Interrupt()or by a monitor that returned false. - BestFound = 9
- Not used. The engine does not set this reason.
- Exception = 10
- The run stopped because of an error.
- FactoriesDone = 11
- The engine has no more solutions to generate. With
SuggestedSolutionsOnly(), the supplied solutions are used up. - Infeasible = 12
- No input values satisfy the constraints.
- CannotGenerate = 13
- The engine cannot generate a solution that is different from the solutions it already has.
- MaxDemoIterations = 14
- No license is set, and the run stopped at 50 iterations. Call
SetLicense(String).
- Returns:
- termination reason
-
SetTerminationReason
public void SetTerminationReason(int reason) Sets the termination reason. Internal OptTek use only.
-