The OptQuest 10 API introduces a unified declarative interface across Java, C#, C++, C and Python, ensuring consistency and ease of use. In Java, the legacy OptQuest 9 API remains supported with no plans for deprecation. The OptQuest 10 API is the exclusive interface for accessing the OptQuest Engine in C#, C++, C, and Python.
Optimization technology empowers analysts to identify optimal solutions for complex business and engineering challenges by systematically evaluating decision variables against defined objectives and constraints.
The OptQuest® Engine, developed by OptTek Systems, Inc., is a powerful optimization tool designed to address critical questions, including:
Manually evaluating all possible scenarios is often impractical or infeasible due to time and computational constraints. The OptQuest Engine overcomes these limitations by employing a robust search algorithm that efficiently identifies optimal decisions. This enables users to rapidly determine the variable combinations that best achieve their objectives, eliminating the inefficiencies of trial-and-error approaches.
The OptQuest Engine employs a sophisticated search algorithm driven by metaheuristics to efficiently identify high-quality solutions. This algorithm leverages historical solution performance to recombine effective solutions, generating better solutions. It is designed to avoid getting stuck in local optima and remains robust against noisy or uncertain model data.
The engine integrates multiple optimization techniques, including:
This composite approach forms a highly efficient, general-purpose global optimization algorithm, delivering superior performance compared to traditional methods. OptTek’s technology achieves better solution identification faster than competing approaches.
The OptQuest Engine operates as a “black-box” global optimization solver, requiring minimal user configuration. It employs a diverse set of heuristics and metaheuristics to ensure rapid convergence to globally optimal solutions. The algorithm is guaranteed to perform effectively across all problem domains, making it a versatile tool for complex optimization challenges.
The OptQuest 10 API was developed to streamline the definition and management of optimization models and includes native support for parallel execution, eliminating the need for manual thread or queue management as well as provide a consistent pattern across all supported languages.
The transition from the OptQuest 9 API to the OptQuest 10 API is designed to be seamless, offering a direct mapping of functionality with reduced client-side management overhead. In OptQuest 9, the primary interface was the COptQuestOptmization
object, where clients defined a subclass with custom virtual function overrides to specify the optimization model and perform solution evaluation using a dependency-injection approach. The OptQuest 10 API encapsulates the optimization model within an opaque, immutable OptQuestModel
object, with solution evaluation driven by callback functions.
In OptQuest 9, clients were responsible for creating and managing the lifecycle of objects representing decision variables, objectives, and constraints, which were then added to the custom COptQuestOptmization
subclass. The OptQuest 10 API shifts this responsibility to the OptQuestModel
, which internally manages these objects. Clients interact with decision variables, objectives, and constraints using unique identifiers rather than direct object references. This encapsulation enhances functionality, enabling features such as reliable optimization pausing and resuming, as well as built-in concurrent evaluation for improved performance in parallel computing environments.
A key change in the OptQuest 10 API is the redefinition of objectives. Unlike OptQuest 9, where objectives could directly receive values from simulations, objectives in OptQuest 10 are strictly defined as expressions composed of input and output variables. To replicate the OptQuest 9 behavior of assigning a simulation output to an objective, clients should define an output variable to capture the simulation result and set the objective expression to reference that output variable. For scenarios replacing a COptQuestUserControlledObjective
tied to a simulation output in OptQuest 9, the OptQuest 10 API requires defining an output variable to hold the simulation result and configuring the objective to use this variable in its expression. This approach maintains equivalent functionality while aligning with the new API’s declarative structure.
//to be collected from the simulation
AddOutputVariable("simOutput");
OptQuestModel.
//the expression for the objective is just the output value
AddMinimizeObjective("objective","simOutput"); OptQuestModel.
The examples below provides a quick reference to map the the OptQuest 9 API to the OptQuest 10 API.
class MyOptimization extends COptQuestOptimization {
//remember to pass into this object a reference
//to all the variables and objectives
public void Evaluate(COptQuestSolution sol)
throws COptQuestException {
double myVarValue = sol.GetVariableValue(myVar);
double myOutputValue = //run my simulation;
SetVariableValue(myOutput, myOutputValue);
sol.
}
}
new MyOptimization(); MyOptimization myOpt =
new OptQuestModel(); OptQuestModel myModel =
new COptQuestContinuousVariable(min, max);
COptQuestVariable myVar = AddVariable(myVar); myOpt.
AddContinuousVariable("myVar", min, max); myModel.
new COptQuestUserControlledVariable();
COptQuestVariable myOutput = AddVariable(myOutput); myOpt.
AddOutput("myOutput"); myModel.
class MyObjective extends
COptQuestUserControlledObjective {//remember to pass into this object a reference to all the variables and objectives
protected void calculateObjective(Solution sol)
throws COptQuestException {
double myVarValue = sol.GetVariableValue(myVar);
double myOutputValue = sol.GetVariableValue(myOutput);
double myObjValue = myVarValue+myOutputValue;
SetObjectiveValue(myObj, myObjValue);
sol.
}
}new MyObjective()
COptQuestSingleObjective myObj = SetMinimize();
myObj.AddObjective(myObj) myOpt.
AddMinimizeObjective("myObj", "myVar + myOutput"); myModel.
class MyObjective1 extends COptQuestUserControlledObjective {
//remember to pass into this object a reference to all the variables and objectives
protected void calculateObjective(Solution sol)
throws COptQuestException {
double myVarValue = sol.GetVariableValue(myVar);
double myOutputValue = sol.GetVariableValue(myOutput);
double myObjValue = myVarValue - myOutputValue;
SetObjectiveValue(myObj1, myObjValue);
sol.
}
}
class MyObjective2 extends
COptQuestUserControlledObjective {//remember to pass into this object a reference to all the variables and objectives
protected void calculateObjective(Solution sol)
throws COptQuestException {
double myVarValue = sol.GetVariableValue(myVar);
double myOutputValue = sol.GetVariableValue(myOutput);
double myObjValue = myVarValue / myOutputValue;
SetObjectiveValue(myObj2, myObjValue);
sol.
}
}
new MyObjecitve1()
COptQuestSingleObjective myObj1 = SetMinimize();
myObj.new MyObjecitve2()
COptQuestSingleObjective myObj2 = SetMaximize();
myObj.
COptQuestFrontierMultiObjective myMultiObj;AddObjective(myObj1)
myMultiObj.AddObjective(myObj2)
myMultiObj.AddObjective(myMultiObj) myOpt.
AddMinimizeObjective("myObj1", "myVar - myOutput");
myModel.AddMaximizebjective("myObj2", "myVar / myOutput"); myModel.
new COptQuestLEConstraint(5);
COptQuestConstraint myConstraint = AddVariable(myVar, 1);
myConstraint.AddVariable(myOutput, -3);
myConstraint.AddConstraint(myConstraint); myOpt.
AddConstraint("myConstraint", "myVar - 3 * myOutput <= 5"); myModel.
Already defined in the Optimization object
class MyEvaluator implments IOptQuestEvaluator {
public bool Evaluate(OptQuestSolution sol) {
double myVarValue=sol.GetValue("myVar");
double myOutputValue = //run simulation here;
SetValue("myOutput",myOutputValue);
sol.
} }
SetMaximumIteration(50);
myOpt.Optimize(); myOpt.
Optimize(50, new MyEvaluator()); myModel.
GetBestSolution();
COptQuestSolution best = myOpt.double myBestVal = best.GetVariableValue(myVar);
double myBestObj = best.GetObjectiveValue(myObj);
GetBestSolutions().getFirst();
OptQuestSolution best = myModel.double myBestVal = best.GetValue("myVar");
double myBestObj = best.GetValue("myObj");
for (COptQuestSolution frontier : myOpt.GetPatternFrontier()){
double myBestObj1 = frontier.GetObjectiveValue(myObj1);
double myBestObj2 = frontier.GetObjectiveValue(myObj2);
}
for (OptQuestSolution frontier : myOpt.GetBestSolutions()){
double myBestObj1 = frontier.GetValue("myObj1");
double myBestObj2 = frontier.GetValue("myObj2");
}
In the Java implementation, exceptions are thrown when errors occur. The exception can be examined along with the call stack to understand the problem. In the C#, C++, and C implementations, if a function encounters an error, it will return an error flag (usually false
), and the full description of the error can be retrieved with the GetLastError()
function which returns the same information that would be in the Java exception.
In the OptQuest Engine, a model is a structured representation of an optimization problem, comprising one or more decision variables, one or more objectives, and, optionally, one or more constraints. OptQuest leverages advanced metaheuristic algorithms, including tabu search, scatter search, and neural network-enhanced strategies, to navigate the constrained variable space and identify optimal solutions. When a single objective is defined, OptQuest iteratively refines a single “best” solution to maximize or minimize the objective. For models with multiple objectives, OptQuest generates a Pareto frontier—a set of solutions representing the optimal trade-offs among competing objectives.
Decision variables form the foundation of an OptQuest model, representing the decision parameters to be optimized. Each variable is characterized by the range of values, which may be continuous (e.g., a real number between 0 and 100), discrete (e.g., integers from 1 to 10), or categorical (e.g., a set of predefined options). Special-purpose data types are also supported, including tuples, geolocations (latitude, longitude), and permutations.
Objectives are mathematical expressions that quantify the goals of the optimization problem, constructed from one or more decision variables and/or output variables derived from simulations. Each objective is associated with a direction:
For example, an objective might be defined as maximize: 2*VariableA + 3*VariableB
, where VariableA
and VariableB
are input or output variables. In multi-objective scenarios, OptQuest identifies a set of non-dominated solutions, balancing trade-offs to provide a comprehensive view of the frontier of equally optimal outcomes.
Constraints are mathematical expressions that define the feasible region of the solution space by imposing limits on variables, objectives, or their combinations. OptQuest supports:
a*VariableA + b*VariableB ≤ c
, where coefficients and bounds are constants.VariableA**2 + VariableB ≤ 100
, accommodating real-world problem complexities.Constraints ensure that solutions remain practical and relevant, filtering out infeasible combinations during the optimization process. They are defined within the OptQuestModel
and can reference both input variables and output expressions.
OptQuest’s metaheuristic algorithms systematically explore the variable space, guided by the defined objectives and constraints. The engine employs a composite search strategy that combines global exploration with local refinement, ensuring efficient convergence to optimal or near-optimal solutions. For multi-objective optimization, the Pareto frontier is iteratively updated to reflect the best trade-offs, enabling users to select solutions that align with their priorities.
The OptQuest Engine’s combination of metaheuristic algorithms and machine learning techniques to efficiently navigate complex solution spaces and identify optimal values for one or more objective functions. OptQuest excels in optimizing arbitrary functions, including Integer Programs, Linear Programs, and Mixed Integer Linear Programs. It is particularly well-suited for “black-box” simulation-optimization, where objective functions incorporate outputs from complex simulations. OptQuest can work with any type of objective function, including non-convex, discontinuous, or non-differentiable functions.
The optimization process in OptQuest follows an iterative loop, described as follows:
With each iteration, OptQuest refines its understanding of the solution space, using metaheuristics such as tabu search, scatter search, and neural network-driven pattern recognition to converge toward optimal or near-optimal solutions. This adaptive process ensures robust performance across diverse problem types, including those with noisy or uncertain data, by iteratively improving solution quality without requiring manual intervention or problem-specific tuning.
Managed Optimization simplifies the optimization process by automating the “Optimization Loop” for common use cases, reducing the need for custom implementation.
When objectives and constraints are direct functions of input variables (no external simulation), OptQuest can iterate through the optimization loop without requiring user-defined evaluation logic. Users specify only the number of iterations.
new OptQuestModel();
OptQuestModel model =
// Define input variables, objectives, and constraints
// ...
// Perform 100 iterations of the optimization loop
optimize(100); model.
For scenarios requiring simulation outputs, users provide a callback function to evaluate solutions. OptQuest invokes this function during each iteration.
new OptQuestModel();
OptQuestModel model =
// Define input variables, objectives, and constraints
// ...
// Perform 100 iterations, invoking customEvaluation for each solution
optimize(100, customEvaluation); model.
To optimize computationally expensive simulations, OptQuest supports concurrent evaluation of multiple solutions. Users specify the number of parallel threads, and OptQuest manages the creation and evaluation of solutions across these threads and handles the synchronization of the generation and learning steps:
new OptQuestModel();
OptQuestModel model =
// Define input variables, objectives, and constraints
// ...
// Perform 100 iterations with 5 concurrent threads, invoking customEvaluation
optimize(5, 100, customEvaluation); model.
This approach significantly reduces runtime for resource-intensive evaluations by leveraging parallel processing capabilities.
For long-running optimizations, OptQuest supports asynchronous execution to keep the main application responsive. A communication channel enables monitoring and control of the optimization process. This ensures seamless integration into interactive applications, with the ability to pause or stop optimizations as needed.
new OptQuestModel();
OptQuestModel model =
// Define input variables, objectives, and constraints
// ...
// Create a channel for 5 concurrent optimizations
createAsyncChannel(5);
OptQuestModelChannel channel = model.
// Start asynchronous optimization in a background thread
Thread background = new Thread(() -> {
// Blocks until 100 solutions are evaluated or interrupted
optimize(channel, 100, customEvaluation);
model.start();
}).
// Interrupt optimization in response to a user event
interrupt();
channel.
// Wait for the optimization to terminate gracefully
join(); background.
For applications requiring fine-grained control, OptQuest provides direct access to each step of the Optimization Loop, enabling custom implementations tailored to complex or high-performance computing (HPC) scenarios. This flexible interface supports custom workflows, including concurrent or distributed optimization, by allowing developers to manage solution creation, evaluation, and submission explicitly.
new OptQuestModel();
OptQuestModel model =
// Create a trial solution
createSolution();
OptQuestSolution solution = model.
// Check if the solution is valid
if (solution.isValid()) {
// Retrieve input values
// e.g., double value = solution.getValue(inputVariableId);
// Compute outputs based on inputs (e.g., via simulation)
// ...
// Set output values
// e.g., solution.setValue(outputVariableId, computedValue);
// Submit solution for learning
submit();
solution.
// Optionally retrieve the processed solution
update();
solution.// Process the updated solution as needed
}
Introduced in OptQuest 10, Adaptive Sampling provides a powerful alternative to traditional optimization for exploring the variable design space. Unlike optimization, which seeks a single optimal point (e.g., a minimum or maximum), Adaptive Sampling aims to comprehensively characterize the response surface across the entire domain, efficiently capturing global trade-offs and behaviors.
The Adaptive Sampling engine operates similarly to the optimization engine by generating trial solutions, evaluating them, and using the results to guide further exploration. However, while optimization focuses on converging to an optimal solution, Adaptive Sampling prioritizes building an accurate model of the response surface with minimal evaluations. This makes it ideal for scenarios where understanding the domain’s behavior—such as identifying trends, boundaries, or regions of interest—is the primary goal.
Adaptive Sampling monitors a user-defined metric, which consists of a value and an associated uncertainty (or error). The engine constructs an internal model of this metric’s response across the domain, predicts the response in unexplored areas, and strategically selects the next solution to evaluate based on what is deemed most “interesting.” Each evaluated solution refines the model, enabling increasingly informed selections.
The Adaptive Sampling process follows an iterative loop:
Adaptive Sampling offers multiple strategies to define “interesting” regions, tailored to different use cases:
signal - 0.5
, the engine increases sample density along the contour where the signal equals 0.5, effectively mapping transition boundaries (e.g., where signal strength drops below 50%).Adaptive Sampling is particularly valuable for applications requiring a holistic understanding of a domain, such as:
OptQuest is designed to handle stochastic simulations, where identical inputs may produce varying outputs due to inherent randomness. To optimize such simulations, OptQuest offers two approaches:
These methods ensure reliable optimization results, even in the presence of stochastic noise, by balancing computational efficiency with statistical accuracy.
This section provides detailed documentation for the OptQuest 10 API functions, covering their definitions in Java, C#, C++, and C. Unless otherwise specified, the Java, C#, and C++ implementations share identical behavior. In the C API, manual resource cleanup is often required, and such cases are explicitly highlighted to ensure proper usage. A custom interface can be written in any language that supports C bindings using the C interface.
To prepare a model for optimization or adaptive sampling in OptQuest 10, the model must be defined using a structured sequence of API functions. The typical workflow is as follows:
Language | Function Signature |
---|---|
Java | new OptQuestModel() |
C# | new OptQuestModel() |
C++ | OptQuestModel() |
C | HOptQuestModel OQCreateModel() |
Python | OptQuestModel() |
Initializes and allocates resources for a new OptQuestModel object, which serves as the foundation for defining and optimizing a model in OptQuest 10. This function must be called before adding variables, objectives, or constraints to the model.
Language | Function Signature |
---|---|
Java | Garbage Collected |
C# | Garbage Collected |
C++ | Destructed |
C | void OQDeleteModel(HOptQuestModel model) |
Python++ | Destructed |
Releases the resources associated with an OptQuestModel
object. In Java and C#, memory management is handled automatically by the garbage collector. In C++ and Python, the destructor of the OptQuestModel
class manages resource cleanup when the object goes out of scope. In C, the client must explicitly call OQDeleteModel
to free the resources associated with the HOptQuestModel
handle.
OptQuestModel
object is properly scoped to trigger the destructor automatically.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetLicense(String license) |
C# | bool OptQuestModel.SetLicense(string license) |
C++ | bool OptQuestModel::SetLicense(const char* license) |
C | int OQSetLicense(HOptQuestModel model, const char* license) |
Python | bool OptQuestModel.set_license(str license) |
Configures the OptQuestModel with a license key provided by an OptTek representative. If an empty string is passed, the model operates in “demo” mode, limiting optimization to 50 iterations regardless of the requested number.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.LogSetup(String filespec) |
C# | bool OptQuestModel.LogSetup(string filespec) |
C++ | bool OptQuestModel::LogSetup(const char* filespec) |
C | int OQLogSetup(HOptQuestModel model, const char* filespec) |
Python | bool OptQuestModel.log_setup(str filespec) |
Directs OptQuest to generate a log file at the specified filespec
path, detailing the model’s configuration. This log is primarily used for debugging or providing model information when collaborating with OptTek support.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.filespec
must be a valid, writable file path.filespec
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.LogSolutions(String filespec) |
C# | bool OptQuestModel.LogSolutions(string filespec) |
C++ | bool OptQuestModel::LogSolutions(const char* filespec) |
C | int OQLogSolutions(HOptQuestModel model, const char* filespec) |
Python | bool OptQuestModel.log_solutions(str filespec) |
Instructs OptQuest to create a log file at the specified filespec
path, recording details of solutions evaluated during optimization or sampling. This log is typically used to share solution data with OptTek support for troubleshooting or analysis.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.filespec
path is valid and writable.filespec
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddContinuousVariable(String name, double min, double max) throws COptQuestException |
C# | bool OptQuestModel.AddContinuousVariable(string name, double min, double max) |
C++ | bool OptQuestModel::AddContinuousVariable(const char* name, double min, double max) |
C | int OQAddContinuousVariable(HOptQuestModel model, const char* name, double min, double max) |
Python | bool OptQuestModel.add_continuous_variable(str name, float min, float max) |
Adds a continuous input variable identified by name
, with a domain bounded inclusively by min
and max
. The name
must be unique across all model components (inputs, outputs, constraints, objectives) and must not contain whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddIntegerVariable(String name, double min, double max) throws COptQuestException |
C# | bool OptQuestModel.AddIntegerVariable(string name, double min, double max) |
C++ | bool OptQuestModel::AddIntegerVariable(const char* name, double min, double max) |
C | int OQAddIntegerVariable(HOptQuestModel model, const char* name, double min, double max) |
Python | bool OptQuestModel.add_integer_variable(str name, float min, float max) |
Adds an integer input variable identified by name
, with a domain of integer values bounded inclusively by min
and max
. The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddDiscreteVariable(String name, double min, double max, double step) throws COptQuestException |
C# | bool OptQuestModel.AddDiscreteVariable(string name, double min, double max, double step) |
C++ | bool OptQuestModel::AddDiscreteVariable(const char* name, double min, double max, double step) |
C | int OQAddDiscreteVariable(HOptQuestModel model, const char* name, double min, double max, double step) |
Python | bool OptQuestModel.add_discrete_variable(str name, float min, float max, float step) |
Adds a discrete input variable identified by name
, with values ranging from min
to max
(inclusive) in increments of step
. The range must accommodate an integer number of steps. The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddBinaryVariable(String name) throws COptQuestException |
C# | bool OptQuestModel.AddBinaryVariable(string name) |
C++ | bool OptQuestModel::AddBinaryVariable(const char* name) |
C | int OQAddBinaryVariable(HOptQuestModel model, const char* name) |
Python | bool OptQuestModel.add_binary_variable(str name) |
Adds a binary input variable identified by name
, restricted to values 0 or 1. The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddDesignVariable(String name, int num) throws COptQuestException |
C# | bool OptQuestModel.AddDesignVariable(string name, int num) |
C++ | bool OptQuestModel::AddDesignVariable(const char* name, int num) |
C | int OQAddDesignVariable(HOptQuestModel model, const char* name, int num) |
Python | bool OptQuestModel.add_design_variable(str name, int num) |
Adds a design input variable identified by name
, representing num
distinct choices (e.g., indices {1, 2, 3} mapping to options like {red, blue, green}). The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddEnumerationVariable(String name, double[] items) throws COptQuestException |
C# | bool OptQuestModel.AddEnumerationVariable(string name, double[] items) |
C++ | bool OptQuestModel::AddEnumerationVariable(const char* name, const double* items, int n) |
C | int OQAddEnumerationVariable(HOptQuestModel model, const char* name, const double* items, int n) |
Python | bool OptQuestModel.add_enumeration_variable(str name, list items) |
Adds an enumeration input variable identified by name
, restricted to the discrete values in items
. The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.items
is an array of n
doubles, and name
must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddPermutationVariable(String group, String[] names) throws COptQuestException |
C# | bool OptQuestModel.AddPermutationVariable(string group, string[] names) |
C++ | bool OptQuestModel::AddPermutationVariable(const char* group, const char** names, int n) |
C | int OQAddPermutationVariable(HOptQuestModel model, const char* group, const char** names, int n) |
Python | bool OptQuestModel.add_permutation_variable(string group, list names) |
Adds a permutation input variable identified by group
, representing a unique ordering of the elements in names
. Each element in names
must be unique, and the variable generates permutations of these elements for optimization. The group
and all name
s must be unique and free of whitespace. OptQuest will create a decision variable for each element in names
prefixed by the group
label.
AddPermutationVariable("group", new String[]{"a","b","c"}); model.
Will create three decision variables named, group_a
, group_b
, group_c
. During the generate step of the optimization loop, OptQuest will fill the values of those variables with the order they appear in the permutation to test. For example, if group_a=1
, group_b=3
, and group_c=2
, then the solution evaluation should compute the outputs based on the ordering {a,c,b}
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.group
and each string in names
must be null-terminated; names
is an array of n
strings.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddTupleVariable(String name, double[][] tuples) throws COptQuestException |
C# | bool OptQuestModel.AddTupleVariable(string name, double[][] tuples) |
C++ | bool OptQuestModel::AddTupleVariable(const char* name, const double** tuples, int nt, int nv) |
C | int OQAddTupleVariable(HOptQuestModel model, const char* name, const double** tuples, int nt, int nv) |
Python | bool OptQuestModel.add_tuple_variable(string name, list tuples) |
Adds a tuple input variable identified by name
, restricted to the discrete tuples in tuples
. Each tuple represents a point in n-dimensional space, where Euclidean distance between tuples is considered during optimization. The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.tuples
is an array of nt
tuples, each with nv
values; name
must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddGeolocationVariable(String name, double[][] locations) throws COptQuestException |
C# | bool OptQuestModel.AddGeolocationVariable(string name, double[][] locations) |
C++ | bool OptQuestModel::AddGeolocationVariable(const char* name, const double** locations, int nl) |
C | int OQAddGeolocationVariable(HOptQuestModel model, const char* name, const double** locations, int nl) |
Python | bool OptQuestModel.add_geolocation_variable(string name, list locations) |
Adds a geolocation input variable identified by name
, restricted to the discrete (latitude, longitude) pairs in locations
. Angular distance between locations on a sphere is considered during optimization. The name
must be unique and free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.locations
is an array of nl
pairs; name
must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddVariableExclusiveRange(String name, double min, double max) throws COptQuestException |
C# | bool OptQuestModel.AddVariableExclusiveRange(string name, double min, double max) |
C++ | bool OptQuestModel::AddVariableExclusiveRange(const char* name, double min, double max) |
C | int OQAddVariableExclusiveRange(HOptQuestModel model, const char* name, double min, double max) |
Python | bool OptQuestModel.add_variable_exclusiveRange(str name, float min, float max) |
Excludes the range from min
to max
(inclusive) from the domain of the variable identified by name
. The variable must already exist. Multiple exclusive ranges can be added by calling this function repeatedly. The name
must match an existing variable and be free of whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddOutputVariable(String name) throws COptQuestException |
C# | bool OptQuestModel.AddOutputVariable(string name) |
C++ | bool OptQuestModel::AddOutputVariable(const char* name) |
C | int OQAddOutputVariable(HOptQuestModel model, const char* name) |
Python | bool OptQuestModel.add_output_variable(str name) |
Adds an output variable identified by name
to the OptQuestModel
. Unlike input variables, output variables are not assigned values by OptQuest during optimization or sampling. Instead, their values are provided by the client during solution evaluation, typically as results from simulations or complex computations. The name
must be unique across all model components (inputs, outputs, constraints, objectives) and must not contain whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetOutputStatistic(String name, int statistic) throws COptQuestException boolean OptQuestModel.SetOutputStatistic(String name, int statistic, double statisticValue) throws COptQuestException |
C# | bool OptQuestModel.SetOutputStatistic(string name, int statistic) bool OptQuestModel.SetOutputStatistic(string name, int statistic, double statisticValue) |
C++ | bool OptQuestModel::SetOutputStatistic(const char* name, int statistic) bool OptQuestModel::SetOutputStatistic(const char* name, int statistic, double statisticValue) |
C | int OQSetOutputStatistic(HOptQuestModel model, const char* name, int statistic, double statisticValue) |
Python | bool OptQuestModel.set_output_statistic(str name, int statistic, float statisticValue=None) |
Configures the statistical aggregation method for the output variable identified by name
when performing multiple replications in stochastic simulations. This setting is ignored for single-replication optimizations. The options for the statistic
value are shown in the table below. The statisticValue
is only used for selecting the percentile, it is ignored for the other statistic choices
Statistic | Java, C# | C++ | C, Python |
---|---|---|---|
Mean | OptQuestModel.Statistic.Mean |
OptQuestModel::Statistic::Mean |
OQStatisticMean |
Median | OptQuestModel.Statistic.Median |
OptQuestModel::Statistic::Median |
OQStatisticMedian |
Percentile | OptQuestModel.Statistic.Percentile |
OptQuestModel::Statistic::Percentile |
OQStatisticPercentile |
Standard Deviation | OptQuestModel.Statistic.StdDev |
OptQuestModel::Statistic::StdDev |
OQStatisticStdDev |
Variance | OptQuestModel.Statistic.Variance |
OptQuestModel::Statistic::Variance |
OQStatisticVariance |
Coefficient of Variance | OptQuestModel.Statistic.CoeffOfVar |
OptQuestModel::Statistic::CoeffOfVar |
OQStatisticCoeffOfVar |
Min | OptQuestModel.Statistic.Min |
OptQuestModel::Statistic::Min |
OQStatisticMin |
Max | OptQuestModel.Statistic.Max |
OptQuestModel::Statistic::Max |
OQStatisticMax |
Sum | OptQuestModel.Statistic.Sum |
OptQuestModel::Statistic::Sum |
OQStatisticSum |
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddMinimizeObjective(String name, String expression) boolean OptQuestModel.AddMaximizeObjective(String name, String expression) |
C# | bool OptQuestModel.AddMinimizeObjective(string name, string expression) bool OptQuestModel.AddMaximizeObjective(string name, string expression) |
C++ | bool OptQuestModel::AddMinimizeObjective(const char* name, const char* expression) bool OptQuestModel::AddMaximizeObjective(const char* name, const char* expression) |
C | int OQAddMinimizeObjective(HOptQuestModel model, const char* name, const char* expression) int OQAddMaximizeObjective(HOptQuestModel model, const char* name, const char* expression) |
Python | bool OptQuestModel.add_minimize_objective(str name, str expression) bool OptQuestModel.add_maximize_objective(str name, str expression) |
Adds an objective to the OptQuestModel
, identified by name
, with the goal of either minimizing or maximizing the specified expression
. The expression
is a mathematical formula referencing input and/or output variables by their names, supporting functions outlined in the Supported Mathematical Functions section. When multiple objectives are defined, OptQuest automatically performs multi-objective optimization, generating a Pareto-efficient frontier of solutions representing optimal trade-offs.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
must be unique across all model components and free of whitespace.name
and expression
strings must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetObjectiveGoal(String name, double min, double max) |
C# | bool OptQuestModel.SetObjectiveGoal(string name, double min, double max) |
C++ | bool OptQuestModel::SetObjectiveGoal(const char* name, double min, double max) |
C | int OQSetObjectiveGoal(HOptQuestModel model, const char* name, double min, double max) |
Python | bool OptQuestModel.set_objective_goal(str name, float min, float max) |
Applicable only in multi-objective optimization (ignored in single-objective cases), this function sets a target range for the objective identified by name
, directing OptQuest to prioritize solutions on the Pareto frontier where the objective’s value lies between min
and max
(inclusive). The objective must already exist in the model. If multiple objectives have goals, OptQuest focuses the search on frontier regions satisfying all goals. If the frontier cannot satisfy all goals simultaneously, OptQuest randomly selects a subset of goals to prioritize in each iteration.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
must match an existing objective.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetObjectiveStatistic(String name, int statistic) throws COptQuestException boolean OptQuestModel.SetObjectiveStatistic(String name, int statistic, double statisticValue) throws COptQuestException |
C# | bool OptQuestModel.SetObjectiveStatistic(string name, int statistic) bool OptQuestModel.SetObjectiveStatistic(string name, int statistic, double statisticValue) |
C++ | bool OptQuestModel::SetObjectiveStatistic(const char* name, int statistic) bool OptQuestModel::SetObjectiveStatistic(const char* name, int statistic, double statisticValue) |
C | int OQSetObjectiveStatistic(HOptQuestModel model, const char* name, int statistic, double statisticValue) |
Python | bool OptQuestModel.set_objective_statistic(const char* name, int statistic, float statisticValue=None) |
Configures the statistical aggregation method for the objective identified by name
when performing multiple replications in stochastic simulations. This setting is ignored for single-replication optimizations. The options for the statistic
value are shown in the table below. The statisticValue
is only used for selecting the percentile, it is ignored for the other statistic choices
Statistic | Java, C# | C++ | C, Python |
---|---|---|---|
Mean | OptQuestModel.Statistic.Mean |
OptQuestModel::Statistic::Mean |
OQStatisticMean |
Median | OptQuestModel.Statistic.Median |
OptQuestModel::Statistic::Median |
OQStatisticMedian |
Percentile | OptQuestModel.Statistic.Percentile |
OptQuestModel::Statistic::Percentile |
OQStatisticPercentile |
Standard Deviation | OptQuestModel.Statistic.StdDev |
OptQuestModel::Statistic::StdDev |
OQStatisticStdDev |
Variance | OptQuestModel.Statistic.Variance |
OptQuestModel::Statistic::Variance |
OQStatisticVariance |
Coefficient of Variance | OptQuestModel.Statistic.CoeffOfVar |
OptQuestModel::Statistic::CoeffOfVar |
OQStatisticCoeffOfVar |
Min | OptQuestModel.Statistic.Min |
OptQuestModel::Statistic::Min |
OQStatisticMin |
Max | OptQuestModel.Statistic.Max |
OptQuestModel::Statistic::Max |
OQStatisticMax |
Sum | OptQuestModel.Statistic.Sum |
OptQuestModel::Statistic::Sum |
OQStatisticSum |
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetObjectiveConfidence(String name, int ctype, int clevel, double epct) |
C# | bool OptQuestModel.SetObjectiveConfidence(string name, int ctype, int clevel, double epct) |
C++ | bool OptQuestModel::SetObjectiveConfidence(const char* name, int ctype, int clevel, double epct) |
C | int OQSetObjectiveConfidence(HOptQuestModel model, const char* name, int ctype, int clevel, double epct) |
Python | bool OptQuestModel.set_objective_confidence(str name, int ctype, int clevel, float epct) |
Applicable only for variable-replication optimizations (ignored in single- or fixed-replication cases), this function sets early-stopping confidence parameters for the objective identified by name
. Parameters include:
ctype
: Specifies the statistic type for early stopping (e.g., mean).clevel
: Defines the confidence level (e.g., 95 for 95% confidence).epct
: Sets the acceptable error percentage for the confidence interval.This enables OptQuest to halt replications early when the objective’s statistic meets the specified confidence criteria, optimizing computational efficiency.
The options for the ctype
value are shown in the table below. The “Type 1” option performs all of the requested replications, the “Type 2” option allows early stopping if OptQuest determines that it is impossible to meet the confidence settings on a particular solution.
Confidence Type | Java, C# | C++ | C, Python |
---|---|---|---|
Type 1 | OptQuestModel.Confidence.Type1 |
OptQuestModel::Confidence::Type1 |
OQSConfidenceType1 |
Type 2 | OptQuestModel.Confidence.Type2 |
OptQuestModel::Confidence::Type2 |
OQConfidenceType2 |
The options for the clevel
value are shown in the table below. OptQuest will stop early if the percent error in the objective is less than epct
with the confidence width defined by the options below.
Confidence Level | Java, C# | C++ | C, Python |
---|---|---|---|
80% | OptQuestModel.Confidence.Level80 |
OptQuestModel::Confidence::Level80 |
OQConfidenceLevel80 |
90% | OptQuestModel.Confidence.Level90 |
OptQuestModel::Confidence::Level90 |
OQConfidenceLevel90 |
95% | OptQuestModel.Confidence.Level95 |
OptQuestModel::Confidence::Level95 |
OQConfidenceLevel95 |
98% | OptQuestModel.Confidence.Level98 |
OptQuestModel::Confidence::Level98 |
OQConfidenceLevel98 |
99% | OptQuestModel.Confidence.Level99 |
OptQuestModel::Confidence::Level99 |
OQConfidenceLevel99 |
99.9% | OptQuestModel.Confidence.Level999 |
OptQuestModel::Confidence::Level999 |
OQConfidenceLevel999 |
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddSampleMetric(String name, String expression, String errorExpression) |
C# | bool OptQuestModel.AddSampleMetric(string name, string expression, string errorExpression) |
C++ | bool OptQuestModel::AddSampleMetric(const char* name, const char* expression, const char* errorExpression) |
C | int OQAddSampleMetric(HOptQuestModel model, const char* name, const char* expression, const char* errorExpression) |
Python | bool OptQuestModel.add_sample_metric(str name, str expression, str errorExpression) |
Adds a sampling metric identified by name
for use in adaptive sampling within the OptQuestModel
. The expression
is a mathematical formula referencing input and/or output variables by their names, representing the response value monitored during adaptive sampling. The errorExpression
is a mathematical expression that evaluates to the uncertainty or error associated with the response value; it can be set to "0"
if the response has no uncertainty. Supported mathematical functions for both expressions are detailed in the Supported Mathematical Functions section. The name
must be unique across all model components (inputs, outputs, constraints, objectives, metrics) and must not contain whitespace. OptQuest will create two named objectives with the _response
and _error
suffix that can be used in expressions.
AddSampleMetric('metric', metricExpression, errorExpression) model.
Will create metric_response
and metric_error
which may be retrieved by from a solution.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
, expression
, and errorExpression
strings must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddConstraint(String name, String expression) throws COptQuestException |
C# | bool OptQuestModel.AddConstraint(string name, string expression) |
C++ | bool OptQuestModel::AddConstraint(const char* name, const char* expression) |
C | int OQAddConstraint(HOptQuestModel model, const char* name, const char* expression) |
Python | bool OptQuestModel.add_constraint(str name, str expression) |
Adds a constraint identified by name
to the OptQuestModel
. The expression
is a mathematical formula that can reference input variables, output variables, or objectives by their names, defining a feasible region for optimization or sampling. Supported mathematical functions for the expression are detailed in the Supported Mathematical Functions section. The name
must be unique across all model components (inputs, outputs, constraints, objectives) and must not contain whitespace.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.name
and expression
strings must be null-terminated.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetReplications(double reps) boolean OptQuestModel.SetReplications(double min, double max) |
C# | bool OptQuestModel.SetReplications(double reps) bool OptQuestModel.SetReplications(double min, double max) |
C++ | bool OptQuestModel::SetReplications(double reps) bool OptQuestModel::SetReplications(double min, double max) |
C | int OQSetReplications(HOptQuestModel model, double min, double max) |
Python | bool OptQuestModel.set_replications(float reps) bool OptQuestModel.set_replications(float min, float max) |
Configures the number of replications for stochastic simulations in the OptQuestModel
. The function can:
reps
) for each solution evaluation. (Note: in C, set a fixed number of replications by setting min
and max
to the same desired number of replications.)min
and max
bounds, allowing OptQuest to adjust the number of replications dynamically based on convergence criteria (e.g., confidence intervals).true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.SetObjectiveConfidence
or SetOutputStatistic
).Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetSerialReplications() |
C# | bool OptQuestModel.SetSerialReplications() |
C++ | bool OptQuestModel::SetSerialReplications() |
C | int OQSetSerialReplications(HOptQuestModel model) |
Python | bool OptQuestModel.set_serial_replications() |
Enables “serial replication” mode for the OptQuestModel
, altering the behavior of replication handling during parallel solution evaluations. By default, when multiple solutions are evaluated concurrently, OptQuest completes all replications for one solution before generating a new one. In serial replication mode, OptQuest generates and evaluates a new solution after receiving the first replication result, ensuring that replications for different solutions are interleaved during parallel processing.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.SetSampleMethod(int method) |
C# | bool OptQuestModel.SetSampleMethod(int method) |
C++ | bool OptQuestModel::SetSampleMethod(int method) |
C | int OQSetSampleMethod(HOptQuestModel model, int method) |
Python | bool OptQuestModel.set_sample_method(int method) |
Configures the sampling method(s) for adaptive sampling in the OptQuestModel
. The method
parameter is a bitwise OR combination of supported sampling method flags, which determine how the adaptive sampling engine selects and evaluates solutions. For a detailed explanation of adaptive sampling, refer to the Adaptive Sampling section.
Method | Java, C# | C++ | C, Python |
---|---|---|---|
Stochastic | OptQuestModel.SampleMethod.Stochastic |
OptQuestModel::SampleMethod::Stochastic |
OQSampleMethodStochastic |
Dynamic | OptQuestModel.SampleMethod.Dynamic |
OptQuestModel::SampleMethod::Dynamic |
OQSampleMethodDynamic |
Async | OptQuestModel.SampleMethod.Async |
OptQuestModel::SampleMethod::Async |
OQSampleMethodAsync |
Uniform | OptQuestModel.SampleMethod.Uniform |
OptQuestModel::SampleMethod::Uniform |
OQSampleMethodUniform |
Variance | OptQuestModel.SampleMethod.Variance |
OptQuestModel::SampleMethod::Variance |
OQSampleMethodVariance |
Zero | OptQuestModel.SampleMethod.Zero |
OptQuestModel::SampleMethod::Zero |
OQSampleMethodZero |
Gradient | OptQuestModel.SampleMethod.Gradient |
OptQuestModel::SampleMethod::Gradient |
OQSampleMethodGradient |
Min | OptQuestModel.SampleMethod.Min |
OptQuestModel::SampleMethod::Min |
OQSampleMethodMin |
Max | OptQuestModel.SampleMethod.Max |
OptQuestModel::SampleMethod::Max |
OQSampleMethodMax |
The sampling methods are divided into two groups: model-building methods (Stochastic, Dynamic, Async) and feedback methods (Uniform, Variance, Zero, Gradient, Min, Max). These control how the adaptive sampling engine constructs its internal model and selects sample points, respectively.
These methods define the criteria for selecting the next sample point based on the sampling metric’s estimated value and uncertainty. Multiple feedback methods can be combined using bitwise OR, resulting in one sample per enabled method per request.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.After defining a model using the model definition functions, the following API functions facilitate running optimization or adaptive sampling on the OptQuestModel
. Once any of these functions are invoked, the model becomes immutable, preventing modifications to variables, objectives, or constraints.
Language | Function Signature |
---|---|
Java | OptQuestSolution OptQuestModel.CreateSolution() throws COptQuestException |
C# | OptQuestSolution OptQuestModel.CreateSolution() |
C++ | OptQuestSolution OptQuestModel::CreateSolution() |
C | HOptQuestSolution OQCreateSolution(HOptQuestModel model) |
Python | OptQuestSolution OptQuestModel.create_solution() |
Requests the OptQuestModel
to generate a new trial solution for evaluation. OptQuest populates the solution with values for each input variable. The caller can then provide output variable values and submit the solution for processing by the optimization or sampling engine. In C, the client is responsible for freeing the HOptQuestSolution
handle using the appropriate cleanup function (e.g., OQDeleteSolution
).
OptQuestSolution
object associated with the model. If OptQuestSolution.IsValid()
returns false
, no new solutions could be generated (e.g., due to domain exhaustion or an interrupted optimization).HOptQuestSolution
handle. Check validity using OQIsValid
.Language | Function Signature |
---|---|
Java | void OptQuestModel.Interrupt() |
C# | void OptQuestModel.Interrupt() |
C++ | void OptQuestModel::Interrupt() |
C | void OQInterrupt(HOptQuestModel model) |
Python | void OptQuestModel.interrupt() |
Signals the OptQuestModel
to stop generating new solutions during manual optimization loops. This function is relevant only for manual optimization workflows, as managed optimization handles termination internally. In multi-threaded manual optimization scenarios, calling this function notifies all threads that no further solutions will be provided. Affected threads can gracefully exit when their next call to CreateSolution()
returns an invalid OptQuestSolution
.
CreateSolution()
to handle the interruption gracefully.Language | Function Signature |
---|---|
Java | void OptQuestModel.Continue() |
C# | void OptQuestModel.Continue() |
C++ | void OptQuestModel::Continue() |
C | void OQContinue(HOptQuestModel model) |
Python | void OptQuestModel.continue_opt() |
If an optimization is interrupted with a call to Interrupt()
, no new solutions will be generated unless Continue()
is called. Use this to restart an interrupted optimization. This function is relevant only for manual optimization workflows, as managed optimization handles continuing internally.
Language | Function Signature |
---|---|
Java | OptQuestSolution OptQuestModel.CreateEmptySolution() throws COptQuestException |
C# | OptQuestSolution OptQuestModel.CreateEmptySolution() |
C++ | OptQuestSolution OptQuestModel::CreateEmptySolution() |
C | HOptQuestSolution OQCreateEmptySolution(HOptQuestModel model) |
Python | OptQuestSolution OptQuestModel.create_empty_solution() |
Creates an empty OptQuestSolution
object associated with the OptQuestModel
, allowing the caller to manually populate input and output values. This is typically used with the OptQuestSolution.Suggest()
function to propose solutions for evaluation. The caller can submit the solution as either a “Suggested” solution (input values only) or an “Evaluated” solution (both input and output values) for processing by the OptQuest engine. In C, the client must free the HOptQuestSolution
handle using the appropriate cleanup function (e.g., OQDeleteSolution
).
OptQuestSolution
object tied to the model.HOptQuestSolution
handle.Language | Function Signature |
---|---|
Java | OptQuestSolution OptQuestModel.CopySolution(OptQuestSolution src) throws COptQuestException |
C# | OptQuestSolution OptQuestModel.CopySolution(OptQuestSolution src) |
C++ | OptQuestSolution OptQuestModel::CopySolution(OptQuestSolution src) |
C | HOptQuestSolution OQCopySolution(HOptQuestModel model, HOptQuestSolution src) |
Python | OptQuestSolution OptQuestModel.copy_solution(OptQuestSolution src) |
Creates a new OptQuestSolution
object with input and output values copied from the source solution (src
) into the destination OptQuestModel
. This is useful for transferring a solution from one model to another, such as when continuing optimization with modified parameters. Values from src
matching variable names in the destination model are copied; unmatched values in src
are ignored, and missing values in the destination model are set to NaN
. The copied solution can be submitted as a “Suggested” (input values only) or “Evaluated” (input and output values) solution for processing. In C, the client must free the HOptQuestSolution
handle after submission using the appropriate cleanup function.
OptQuestSolution
object tied to the destination model, pre-filled with values from src
.HOptQuestSolution
handle.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.AddAllSolutions(OptQuestModel src) throws COptQuestException |
C# | bool OptQuestModel.AddAllSolutions(OptQuestModel src) |
C++ | bool OptQuestModel::AddAllSolutions(OptQuestModel src) |
C | int OQAddAllSolutions(HOptQuestModel model, HOptQuestModel src) |
Python | bool OptQuestModel.add_all_solutions(OptQuestModel src) |
Transfers all evaluated solutions from the source OptQuestModel
(src
) to the destination OptQuestModel
. This is typically used to resume optimization after modifying model parameters, such as constraints or objectives. Transferred solutions are reprocessed in the context of the destination model to compute new objective values. If constraints in the destination model are stricter, infeasible solutions are mapped to the feasible space and marked for re-evaluation.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.Optimize(int nsol) boolean OptQuestModel.Optimize(int nsol, IOptQuestEvaluator eval) boolean OptQuestModel.Optimize(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C# | bool OptQuestModel.Optimize(int nsol) bool OptQuestModel.Optimize(int nsol, IOptQuestEvaluator eval) bool OptQuestModel.Optimize(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C++ | bool OptQuestModel::Optimize(int nsol) bool OptQuestModel::Optimize(int nsol, const IOptQuestEvaluator& eval) bool OptQuestModel::Optimize(int nsol, const IOptQuestEvaluator& eval, const IOptQuestMonitor& monitor) |
C | int OQOptimize(HOptQuestModel model, int nsol, OQEvaluator eval, OQMonitor monitor, void* context) |
Python | bool OptQuestModel.optimize(int nsol, func eval=None, func monitor=None) |
Executes a managed optimization on the OptQuestModel
, evaluating nsol
solutions generated by the optimization engine. Three variants are available:
Optimize(int nsol)
: Use when objectives and constraints depend only on input variables, requiring no external evaluation. No callback is needed.Optimize(int nsol, IOptQuestEvaluator eval)
: Use when output variables require evaluation via a custom callback function.Optimize(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor)
: Extends the previous variant by adding a monitor callback to post-process evaluated solutions, typically for updating a UI.In C, callbacks are function pointers and may be NULL
if not required. The context
parameter allows passing user-defined data to callbacks.
In Python, callbacks are functions that take a single OptQuestSolution
parameter and may be None
if not required.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.Optimize(int npar, int nsol) boolean OptQuestModel.Optimize(int npar, int nsol, IOptQuestEvaluator eval) boolean OptQuestModel.Optimize(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C# | bool OptQuestModel.Optimize(int npar, int nsol) bool OptQuestModel.Optimize(int npar, int nsol, IOptQuestEvaluator eval) bool OptQuestModel.Optimize(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C++ | bool OptQuestModel::Optimize(int npar, int nsol) bool OptQuestModel::Optimize(int npar, int nsol, const IOptQuestEvaluator& eval) bool OptQuestModel::Optimize(int npar, int nsol, const IOptQuestEvaluator& eval, const IOptQuestMonitor& monitor) |
C | int OQParallelOptimize(HOptQuestModel model, int npar, int nsol, OQEvaluator eval, OQMonitor monitor, void* context) |
Python | bool OptQuestModel.optimize(int nsol, int npar = npar, func eval = None, func monitor = None) |
Runs a concurrent managed optimization, evaluating nsol
solutions across npar
parallel threads. This function behaves like Managed Optimization but processes npar
solutions simultaneously. OptQuest ensures thread-safe handling of the model and solutions, but the IOptQuestEvaluator
and IOptQuestMonitor
callbacks must implement proper synchronization to avoid race conditions on shared, non-OptQuest-managed state. The function blocks until all solutions are evaluated.
In C, callbacks are function pointers and may be NULL
if not required. The context
parameter allows passing user-defined data to callbacks.
In Python, callbacks are functions that take a single OptQuestSolution
parameter and may be None
if not required.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | OptQuestModelChannel OptQuestModel.CreateAsyncChannel(int npar) |
C# | OptQuestModelChannel OptQuestModel.CreateAsyncChannel(int npar) |
C++ | OptQuestModelChannel OptQuestModel::CreateAsyncChannel(int npar) |
C | HOptQuestModelChannel OQCreateAsyncChannel(HOptQuestModel model, int npar) void OQDeleteAsyncChannel(HOptQuestModelChannel ipc) |
Creates an OptQuestModelChannel
for inter-thread communication, enabling coordination between the main application and a concurrent optimization running in a background thread with npar
parallel evaluations. In C, the client must free the HOptQuestModelChannel
handle using OQDeleteAsyncChannel
.
OptQuestModelChannel
object tied to the model.HOptQuestModelChannel
handle. Returns NULL
on failure, with error details available via OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.Optimize(OptQuestModelChannel ipc, int nsol) boolean OptQuestModel.Optimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) boolean OptQuestModel.Optimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C# | bool OptQuestModel.Optimize(OptQuestModelChannel ipc, int nsol) bool OptQuestModel.Optimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) bool OptQuestModel.Optimize(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C++ | bool OptQuestModel::Optimize(OptQuestModelChannel& ipc, int nsol) bool OptQuestModel::Optimize(OptQuestModelChannel& ipc, int nsol, const IOptQuestEvaluator& eval) bool OptQuestModel::Optimize(OptQuestModelChannel& ipc, int nsol, const IOptQuestEvaluator& eval, const IOptQuestMonitor& monitor) |
C | int OQAsyncOptimize(HOptQuestModel model, HOptQuestModelChannel ipc, int nsol, OQEvaluator eval, OQMonitor monitor, void* context) |
Runs a managed optimization in a background thread, using an OptQuestModelChannel
(ipc
) to communicate with the main thread. The optimization evaluates nsol
solutions, with variants mirroring those of Managed Optimization. The main thread can call OptQuestModelChannel.Interrupt()
to request early termination, which halts new solution generation and evaluation but allows ongoing evaluations to complete. This function blocks until the optimization completes or is interrupted.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.// Create a channel for 5 concurrent solution evaluations
CreateAsyncChannel(5);
OptQuestModelChannel oqChannel = oqModel.
// Start asynchronous optimization in a background thread
Thread background = new Thread(() -> {
AsyncOptimize(oqChannel, nsol);
oqModel.start();
}).
// Interrupt optimization on user event
Interrupt();
oqChannel.
// Wait for graceful shutdown
join(); background.
Language | Function Signature |
---|---|
Java | boolean OptQuestModel.Sample(int nsol) boolean OptQuestModel.Sample(int nsol, IOptQuestEvaluator eval) boolean OptQuestModel.Sample(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C# | bool OptQuestModel.Sample(int nsol) bool OptQuestModel.Sample(int nsol, IOptQuestEvaluator eval) bool OptQuestModel.Sample(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C++ | bool OptQuestModel::Sample(int nsol) bool OptQuestModel::Sample(int nsol, const IOptQuestEvaluator& eval) bool OptQuestModel::Sample(int nsol, const IOptQuestEvaluator& eval, const IOptQuestMonitor& monitor) |
C | int OQSample(HOptQuestModel model, int nsol, OQEvaluator eval, OQMonitor monitor, void* context) |
Python | bool OptQuestModel.sample(int nsol, func eval=None, func monitor=None) |
Executes managed adaptive sampling on the OptQuestModel
, evaluating nsol
solutions generated by the adaptive sampling engine. Three variants are available:
Sample(int nsol)
: Use when metrics and constraints depend only on input variables, requiring no external evaluation. No callback is needed.Sample(int nsol, IOptQuestEvaluator eval)
: Use when output variables require evaluation via a custom callback function.Sample(int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor)
: Extends the previous variant by adding a monitor callback to post-process evaluated solutions, typically for updating a UI.In C, callbacks are function pointers and may be NULL
if not required. The context
parameter allows passing user-defined data to callbacks.
In Python, callbacks are functions that take a single OptQuestSolution
parameter and may be None
if not required.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.Sample(int npar, int nsol) boolean OptQuestModel.Sample(int npar, int nsol, IOptQuestEvaluator eval) boolean OptQuestModel.Sample(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C# | bool OptQuestModel.Sample(int npar, int nsol) bool OptQuestModel.Sample(int npar, int nsol, IOptQuestEvaluator eval) bool OptQuestModel.Sample(int npar, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C++ | bool OptQuestModel::Sample(int npar, int nsol) bool OptQuestModel::Sample(int npar, int nsol, const IOptQuestEvaluator& eval) bool OptQuestModel::Sample(int npar, int nsol, const IOptQuestEvaluator& eval, const IOptQuestMonitor& monitor) |
C | int OQParallelSample(HOptQuestModel model, int npar, int nsol, OQEvaluator eval, OQMonitor monitor, void* context) |
Python | bool OptQuestModel.sample(int nsol, int npar = npar, func eval = None, func monitor = None) |
Runs concurrent managed adaptive sampling, evaluating nsol
solutions across npar
parallel threads. This function behaves like managed adaptive sampling but processes npar
solutions simultaneously. OptQuest ensures thread-safe handling of the model and solutions, but the IOptQuestEvaluator
and IOptQuestMonitor
callbacks must implement proper synchronization to avoid race conditions on shared, non-OptQuest-managed state. The function blocks until all solutions are evaluated.
In C, callbacks are function pointers and may be NULL
if not required. The context
parameter allows passing user-defined data to callbacks.
In Python, callbacks are functions that take a single OptQuestSolution
parameter and may be None
if not required.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | boolean OptQuestModel.Sample(OptQuestModelChannel ipc, int nsol) boolean OptQuestModel.Sample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) boolean OptQuestModel.Sample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C# | bool OptQuestModel.Sample(OptQuestModelChannel ipc, int nsol) bool OptQuestModel.Sample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval) bool OptQuestModel.Sample(OptQuestModelChannel ipc, int nsol, IOptQuestEvaluator eval, IOptQuestMonitor monitor) |
C++ | bool OptQuestModel::Sample(OptQuestModelChannel& ipc, int nsol) bool OptQuestModel::Sample(OptQuestModelChannel& ipc, int nsol, const IOptQuestEvaluator& eval) bool OptQuestModel::Sample(OptQuestModelChannel& ipc, int nsol, const IOptQuestEvaluator& eval, const IOptQuestMonitor& monitor) |
C | int OQAsyncSample(HOptQuestModel model, HOptQuestModelChannel ipc, int nsol, OQEvaluator eval, OQMonitor monitor, void* context) |
Runs managed adaptive sampling in a background thread, using an OptQuestModelChannel
(ipc
) to communicate with the main thread. The sampling evaluates nsol
solutions, with variants mirroring those of managed adaptive sampling. The main thread can call OptQuestModelChannel.Interrupt()
to request early termination, which halts new solution generation and evaluation but allows ongoing evaluations to complete. This function blocks until the sampling completes or is interrupted.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastError()
.Language | Function Signature |
---|---|
Java | List<OptQuestSolution> OptQuestModel.GetBestSolutions() throws COptQuestException List<OptQuestSolution> OptQuestModel.GetBestSolutions(int limit) throws COptQuestException |
C# | List<OptQuestSolution> OptQuestModel.GetBestSolutions() List<OptQuestSolution> OptQuestModel.GetBestSolutions(int limit) |
C++ | int OptQuestModel::GetBestSolutions() int OptQuestModel::GetBestSolutions(int limit) OptQuestSolution& GetBestSolutionsAt(int i) |
C | int OQGetBestSolutions(HOptQuestModel model, int limit) HOptQuestSolution OQGetBestSolutionsAt(HOptQuestModel model, int i) |
Python | list OptQuestModel.get_best_solutions(int limit=1) |
Retrieves the best solutions identified during optimization from the OptQuestModel
. The function returns a collection (List in Java, C#, and Python) or count in C++ and C of OptQuestSolution
objects, even if only one solution is available.
GetBestSolutions()
: For single-objective optimizations, returns a collection containing the single best solution. For multi-objective optimizations, returns all solutions on the Pareto frontier.GetBestSolutions(int limit)
: For single-objective optimizations, returns up to limit
best solutions. For multi-objective optimizations, returns all Pareto frontier solutions, ignoring the limit
parameter.In C and C++, GetBestSolutions
returns the number of solutions, and individual solutions are accessed via GetBestSolutionsAt(int i)
. These functions share global state and are not reentrant; a subsequent call to GetBestSolutions
invalidates the previous list.
List
of OptQuestSolution
objects.GetBestSolutions
returns the number of solutions; GetBestSolutionsAt
returns the solution at index i
.Language | Function Signature |
---|---|
Java | List<OptQuestSolution> OptQuestModel.GetAllSolutions() throws COptQuestException |
C# | List<OptQuestSolution> OptQuestModel.GetAllSolutions() |
C++ | int OptQuestModel::GetAllSolutions() OptQuestSolution& OptQuestModel::GetAllSolutionsAt(int i) |
C | int OQGetAllSolutions(HOptQuestModel model) HOptQuestSolution OQGetAllSolutionsAt(HOptQuestModel model, int i) |
Python | list OptQuestModel.get_all_solutions() |
Retrieves the all evaluated solution during optimization from the OptQuestModel
. The function returns a collection (List in Java, C#, and Python) or count in C++ and C of OptQuestSolution
objects, even if only one solution is available.
In C and C++, GetAllSolutions
returns the number of solutions, and individual solutions are accessed via GetAllSolutionsAt(int i)
. These functions share global state and are not reentrant; a subsequent call to GetAllSolutions
invalidates the previous list.
List
of OptQuestSolution
objects.GetBestSolutions
returns the number of solutions; GetBestSolutionsAt
returns the solution at index i
.Language | Function Signature |
---|---|
Java | int OptQuestModel.GetTerminationReason() |
C# | int OptQuestModel.GetTerminationReason() |
C++ | int OptQuestModel::GetTerminationReason() |
C | void OQGetTerminationReason(HOptQuestModel model) |
Python | int OptQuestModel.get_termination_reason() |
Returns an integer indicating why an optimization stopped.
Reason | Java, C# | C++ | C, Python |
---|---|---|---|
Not Started = 0 |
OptQuestModel.TerminationReason.NotStarted |
OptQuestModel::TerminationReason::NotStarted |
OQTerminationReasonNotStarted |
Running = 1 |
OptQuestModel.TerminationReason.Running |
OptQuestModel::TerminationReason::Running |
OQTerminationReasonRunning |
LP Solved = 3 |
OptQuestModel.TerminationReason.LP |
OptQuestModel::TerminationReason::LP |
OQTerminationReasonLP |
Auto Stop = 4 |
OptQuestModel.TerminationReason.AutoStop |
OptQuestModel::TerminationReason::AutoStop |
OQTerminationReasonAutoStop |
Optimal Found = 5 |
OptQuestModel.TerminationReason.OptimalFound |
OptQuestModel::TerminationReason::OptimalFound |
OQTerminationReasonOptimalFound |
Max Iterations = 6 |
OptQuestModel.TerminationReason.MaxIterations |
OptQuestModel::TerminationReason::MaxIterations |
OQTerminationReasonMaxIterations |
Max Time = 7 |
OptQuestModel.TerminationReason.MaxTime |
OptQuestModel::TerminationReason::MaxTime |
OQTerminationReasonMaxTime |
User Stopped = 8 |
OptQuestModel.TerminationReason.UserStopped |
OptQuestModel::TerminationReason::UserStopped |
OQTerminationReasonUserStopped |
Exception = 10 |
OptQuestModel.TerminationReason.BestFound |
OptQuestModel::TerminationReason::ReasonException |
OQTerminationReasonException |
Infeasible = 12 |
OptQuestModel.TerminationReason.Infeasible |
OptQuestModel::TerminationReason::Infeasible |
OQTerminationReasonInfeasible |
Cannot Generate = 13 |
OptQuestModel.TerminationReason.CannotGenerate |
OptQuestModel::TerminationReason::CannotGenerate |
OQTerminationReasonCannotGenerate |
Max Demo Iterations = 14 |
OptQuestModel.TerminationReason.MaxDemoIterations |
OptQuestModel::TerminationReason::MaxDemoIterations |
OQTerminationReasonMaxDemoIterations |
Language | Function Signature |
---|---|
Java | String OptQuestModel.GetLastError() |
C# | string OptQuestModel.GetLastError() |
C++ | const char* OptQuestModel::GetLastError() |
C | const char* OQGetLastError(HOptQuestModel model) |
Python | str OptQuestModel.GetLastError() |
Retrieves error information for the OptQuestModel
when a function returns false
or fails. This is useful for debugging model configurations or runtime issues.
The OptQuestModel
manages OptQuestSolution
objects, which are passed between the client and the optimization or sampling engine to represent trial solutions.
Language | Function Signature |
---|---|
Java | Garbage Collected |
C# | Garbage Collected |
C++ | Destructed |
C | void OQDeleteSolution(HOptQuestSolution sol) |
Python | Destructed |
Releases resources associated with an OptQuestSolution
object. Solutions are never created directly; they are instantiated by the OptQuestModel
via CreateSolution()
, CreateEmptySolution()
, or CopySolution()
. In Java and C#, memory is managed by the garbage collector. In C++ and Python, the destructor handles cleanup when the object goes out of scope. In C, the client must explicitly call OQDeleteSolution
to free the HOptQuestSolution
handle.
Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.IsValid() |
C# | implicit operator bool(OptQuestSolution test) |
C++ | operator bool() |
C | int OQIsValid(HOptQuestSolution sol) |
Python | bool OptQuestSolution.is_valid() |
Checks if an OptQuestSolution
is valid. An invalid solution is returned when the optimization engine cannot generate a new solution, e.g., due to an exhausted feasible space or a too-restrictive domain. In C# and C++, the operator bool
pattern allows implicit conversion to a boolean for validity checks.
true
if the solution is valid, false
otherwise.Language | Function Signature |
---|---|
Java | int OptQuestSolution.GetIteration() |
C# | int OptQuestSolution.GetIteration() |
C++ | int OptQuestSolution::GetIteration() |
C | int OQGetIteration(HOptQuestSolution sol) |
Python | int OptQuestSolution.get_iteration() |
Retrieves the unique iteration number assigned to the OptQuestSolution
when it is created and sent for evaluation. Multiple replications of the same solution share the same iteration number.
int
representing the iteration number of the solution.Language | Function Signature |
---|---|
Java | int OptQuestSolution.GetReplication() |
C# | int OptQuestSolution.GetReplication() |
C++ | int OptQuestSolution::GetReplication() |
C | int OQGetReplication(HOptQuestSolution sol) |
Python | int OptQuestSolution.get_replication() |
Retrieves the unique replication number assigned to the OptQuestSolution
for a specific evaluation instance. Each replication of a solution has a distinct replication number.
int
representing the replication number of the solution.Language | Function Signature |
---|---|
Java | int OptQuestSolution.GetNumberOfCompletedReplications() throws COptQuestException |
C# | int OptQuestSolution.GetNumberOfCompletedReplications() |
C++ | int OptQuestSolution::GetNumberOfCompletedReplications() |
C | int OQGetNumberOfCompletedReplications(HOptQuestSolution sol) |
Python | int OptQuestSolution.get_number_of_completed_replications() |
Returns the total number of replications evaluated for the OptQuestSolution
.
int
representing the number of completed replications.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.IsComplete() |
C# | bool OptQuestSolution.IsComplete() |
C++ | bool OptQuestSolution::IsComplete() |
C | int OQIsComplete(HOptQuestSolution sol) |
Python | bool OptQuestSolution.is_complete() |
Checks if all required replications for the OptQuestSolution
have been evaluated, indicating that no further evaluations are needed.
true
if all replications are complete, false
otherwise.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.IsFeasible() |
C# | bool OptQuestSolution.IsFeasible() |
C++ | bool OptQuestSolution::IsFeasible() |
C | int OQIsFeasible(HOptQuestSolution sol) |
Python | bool OptQuestSolution.is_feasible() |
Verifies if the OptQuestSolution
satisfies all constraints defined in the OptQuestModel
, indicating it lies within the feasible region.
true
if the solution is feasible, false
if it violates any constraints.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.HasMetConfidence() |
C# | bool OptQuestSolution.HasMetConfidence() |
C++ | bool OptQuestSolution::HasMetConfidence() |
C | int OQHasMetConfidence(HOptQuestSolution sol) |
Python | bool OptQuestSolution.has_met_confidence() |
Checks if the OptQuestSolution
has met the confidence requirements for all objectives in variable replication mode, ensuring sufficient statistical reliability for stochastic simulations.
true
if confidence requirements are met for all objectives, false
otherwise.SetObjectiveConfidence
).Language | Function Signature |
---|---|
Java | double OptQuestSolution.GetValue(String name) throws COptQuestException |
C# | double OptQuestSolution.GetValue(string name) |
C++ | double OptQuestSolution::GetValue(const char* name) |
C | double OQGetValue(HOptQuestSolution sol, const char* name) |
Python | float OptQuestSolution.get_value(str name) |
Retrieves the value associated with a named variable (input or output), objective, or constraint in an OptQuestSolution
. If the requested value is unavailable (e.g., the name is invalid or the value is undefined), NaN
is returned. The name
parameter can include suffixes to access specific information, particularly for replications, confidence intervals, or constraint components.
Basic Usage: Use the name of the variable, objective, or constraint (e.g., "input1"
, "objective1"
, "constraint1"
).
Outputs with Replications: For solutions with multiple replications, the aggregated output value is returned by default. To access a specific replication, append ";#"
where #
is the replication number (e.g., "output;2"
for replication #2).
Objectives with Replications: Similar to outputs, the aggregated objective value is returned by default. Use ";#"
for a specific replication (e.g., "objective;3"
for replication #3). For variable replication mode, append ";cw"
to retrieve the confidence interval width (e.g., "objective;cw"
).
Constraints: By default, the constraint name returns feasibility (1.0 for feasible, 0.0 for infeasible). To access specific parts of a constraint expression, use:
input1 - input2 < 3 OR input2 + input3 > 5 - input2
).For a constraint named constraint1 defined as input1 - input2 < 3 OR input2 + input3 > 5 - input2
:
GetValue("constraint1")
: Returns 1.0 if feasible, 0.0 if infeasible.GetValue("constraint1;LHS;1")
: Returns the value of input1 - input2.GetValue("constraint1;RHS;1")
: Returns 3.GetValue("constraint1;LHS;2")
: Returns the value of input2 + input3.GetValue("constraint1;RHS;2")
: Returns the value of 5 - input2.NaN
if the information is unavailable.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.SetValue(String name, double value) throws COptQuestException |
C# | bool OptQuestSolution.SetValue(string name, double value) |
C++ | bool OptQuestSolution::SetValue(const char* name, double value) |
C | int OQSetValue(HOptQuestSolution sol, const char* name, double value) |
Python | bool OptQuestSolution.set_value(str name, float value) |
Sets the value of a named input or output variable in an OptQuestSolution
. This is primarily used to assign values to output variables during solution evaluation. However, clients can also override input variable values if needed. Objective and constraint values cannot be set directly, as they are computed from input and output variables.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastSolutionError()
.name
string must be null-terminated.Language | Function Signature |
---|---|
Java | int OptQuestSolution.Submit() throws COptQuestException |
C# | int OptQuestSolution.Submit() |
C++ | int OptQuestSolution::Submit() |
C | int OQSubmit(HOptQuestSolution sol) |
Python | int OptQuestSolution.submit() |
Submits an evaluated OptQuestSolution
back to the optimization engine for processing. This function is used exclusively in manual optimization loops; managed optimization handles submission automatically. The solution must have all required output values set (via SetValue
) before submission.
Update
after submission to refresh the solution’s state if further modifications are needed.Language | Function Signature |
---|---|
Java | int OptQuestSolution.Reject() throws COptQuestException |
C# | int OptQuestSolution.Reject() |
C++ | int OptQuestSolution::Reject() |
C | int OQReject(HOptQuestSolution sol) |
Python | int OptQuestSolution.reject() |
Rejects an OptQuestSolution
, signaling to the optimization engine that it could not be evaluated (e.g., due to external constraints or simulation failures). The rejected solution is returned to the engine and not used to guide future solution generation. This function is used only in manual optimization loops; managed optimization handles rejections internally.
Update
after rejection if the solution’s state needs refreshing.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.Update() |
C# | bool OptQuestSolution.Update() |
C++ | bool OptQuestSolution::Update() |
C | int OQUpdate(HOptQuestSolution sol) |
Python | bool OptQuestSolution.update() |
Updates the internal state of an OptQuestSolution
after it has been submitted or rejected to the optimization engine. This ensures the solution reflects the latest engine processing, such as updated constraint feasibility or objective values. This function is used only in manual optimization loops; managed optimization handles updates automatically.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastSolutionError()
.Submit
or Reject
in manual loops to ensure the solution’s state is consistent with the engine.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.AddSuggested() throws COptQuestException |
C# | bool OptQuestSolution.AddSuggested() |
C++ | bool OptQuestSolution::AddSuggested() |
C | int OQAddSuggested(HOptQuestSolution sol) |
Python | bool OptQuestSolution.add_suggested() |
Submits an OptQuestSolution
as a “warm start” to the optimization engine, providing known or promising input variable values to accelerate convergence. The client must set input variable values (via SetValue
) before calling this function. OptQuest evaluates these suggested solutions before generating new ones. This is typically used before starting an optimization to leverage prior knowledge.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastSolutionError()
.CreateEmptySolution()
or CopySolution()
for manual input specification.Language | Function Signature |
---|---|
Java | boolean OptQuestSolution.AddEvaluated() throws COptQuestException |
C# | bool OptQuestSolution.AddEvaluated() |
C++ | bool OptQuestSolution::AddEvaluated() |
C | int OQAddEvaluated(HOptQuestSolution sol) |
Python | bool OptQuestSolution.add_evaluated() |
Submits an OptQuestSolution
with pre-computed input and output variable values to the optimization engine. This is useful for incorporating results from prior simulations, saving computational effort. The client must set both input and output variable values (via SetValue
) before calling. OptQuest processes these evaluated solutions before generating new ones, integrating them into the optimization process.
true
on success, false
on failure. Error details can be retrieved using GetLastError()
.OQGetLastSolutionError()
.CreateEmptySolution()
or CopySolution()
for manual input specification.Language | Function Signature |
---|---|
Java | String OptQuestSolution.GetLastError() |
C# | string OptQuestSolution.GetLastError() |
C++ | const char* OptQuestSolution::GetLastError() |
C | const char* OQGetLastSolutionError(HOptQuestSolution sol) |
Python | str OptQuestSolution.get_last_error() |
Retrieves error information for an OptQuestSolution
when a function returns false
or fails. This is useful for debugging issues related to solution manipulation or submission.
OptQuestSolution
operation to diagnose the issue.The Managed Optimization API in OptQuest simplifies common optimization workflows by handling the optimization loop, including solution creation, evaluation, post-processing, and status updates. This can optionally run in parallel. Two optional callback functions can be provided to the Optimize()
function: one for custom solution evaluation (required when computing output variables) and one for status monitoring (e.g., updating a UI during optimization).
Language | Function Signature |
---|---|
Java | boolean IOptQuestEvaluator.Evaluate(OptQuestSolution sol) |
C# | bool IOptQuestEvaluator.Evaluate(OptQuestSolution sol) |
C++ | bool IOptQuestEvaluator::operator()(OptQuestSolution& sol) const |
C | typedef int (*OQEvaluator)(HOptQuestSolution sol, void* context) |
Python | def eval(sol) |
The solution evaluator callback is implemented by providing an IOptQuestEvaluator
interface in Java, C#, or C++, a function that accepts a solution in Python, or a function pointer of type OQEvaluator
in C. It is called by OptQuest to evaluate an OptQuestSolution
during managed optimization.
sol
) with pre-populated input variable values, accessible via GetValue()
.SetValue()
.true
, the solution is submitted to OptQuest for post-processing (equivalent to OptQuestSolution.Submit()
). If false
, the solution is rejected and excluded from post-processing (equivalent to OptQuestSolution.Reject()
).In C, the context
parameter allows passing user-defined state to the callback. In concurrent optimization (e.g., ConcurrentOptimize
or AsyncOptimize
), this function may be called simultaneously across multiple threads, so proper synchronization is required for any shared state not managed by OptQuest.
true
to submit the solution, false
to reject it.true
.Language | Function Signature |
---|---|
Java | boolean IOptQuestMonitor.Monitor(OptQuestSolution sol) |
C# | bool IOptQuestMonitor.Monitor(OptQuestSolution sol) |
C++ | bool IOptQuestMonitor::operator()(OptQuestSolution& sol) const |
C | typedef int (*OQMonitor)(HOptQuestSolution sol, void* context) |
Python | def monitor(sol) |
The solution monitor callback is implemented by providing an IOptQuestMonitor
interface in Java, C#, or C++, a function that accepts a solution in Python, or a function pointer of type OQMonitor
in C. It is called by OptQuest after post-processing an evaluated solution during managed optimization.
sol
) with values for input variables, output variables, constraints, and objectives, accessible via GetValue()
.true
, OptQuest continues generating new solutions. If false
, solution generation stops, and the optimization loop exits early. In concurrent optimization, ongoing evaluations complete, but no new solutions are generated.In C, the context
parameter allows passing user-defined state. In concurrent optimization, this function may be called simultaneously across multiple threads, requiring proper synchronization for shared, non-OptQuest-managed state.
true
to continue optimization, false
to stop generating new solutions.These functions are available when defining expressions for Objectives and Constraints.
Function | Description |
---|---|
min(x,y) |
Returns the smaller of two numbers. |
max(x,y) |
Returns the larger of two numbers. |
sqrt(x) |
Returns the square root of a number. |
log(x) |
Returns the logarithm of a specified number. |
log10(x) |
Returns the base 10 logarithm of a specified number. |
pow(x,y) |
Returns a specified number raised to the specified power. |
exp(x) |
Returns e raised to the specified power |
abs(x) |
Returns the absolute value of a specified number. |
pi |
Mathematical constant pi, approximately equal to 3.14159. |
e |
Mathematical constant e, approximately equal to 2.718. |
rand() |
Returns a random number between 0 and 1, inclusive. |
fmod(x,y) |
Returns the remainder of x / y. |
floor(x) |
Returns the largest whole number less than or equal to the specified number. |
ceil(x) |
Returns the smallest whole number greater than or equal to the specified number. |
sin(x) |
Returns the sine of x, where x is an angle in radians. |
cos(x) |
Returns the cosine of x, where x is an angle in radians. |
tan(x) |
Returns the tangent of x, where x is an angle in radians. |
sinh(x) |
Returns the hyperbolic sine of x, where x is an angle in radians. |
cosh(x) |
Returns the hyperbolic cosine of x, where x is an angle in radians. |
tanh(x) |
Returns the hyperbolic tangent of x, an angle in radians. |
asin(x) |
Returns the arcsine of x. |
acos(x) |
Returns the arccosine of x |
atan(x) |
Returns the arctangent of x. |
atan2(x,y) |
Returns the arctangent of y/x in the range –π to π radians. If both parameters of atan2 are 0, the function returns 0. |
DtoR(x) |
Converts degrees to radians. |
RtoD(x) |
Converts radians to degrees. |
eq(x,y) |
Returns 1 if x = y, otherwise 0. |
ne(x,y) |
Returns 1 if x != y, otherwise 0. |
lt(x,y) |
Returns 1 if x < y, otherwise 0. |
le(x,y) |
Returns 1 if x <= y, otherwise 0. |
gt(x,y) |
Returns 1 if x > y, otherwise 0. |
ge(x,y) |
Returns 1 if x >= y, otherwise 0. |
clamp(x,y,z) |
Returns y if x < y, z if x > z, otherwise x. |
signum(x) |
Returns -1 if x < 0, 1 if x > 0, otherwise 0. |
finite(x) |
Returns 1 if x is a finite IEEE floating point number (not NaN or Inf), otherwise 0 |
if(x,y,z) |
Returns y if x != 0, otherwise z |
We provide the OptQuest Engine with language bindings for Java, C#, C++, C, and Python. This section describes how to integrate OptQuest with your project.
OptQuest is delivered as a single OptQuest.jar
file to be included in your Java project. Adding a reference to the file as a library in your build system of choice should be sufficient to link to the both the “old” OptQuest 9 API as well as the “new” OptQuest 10 API.
OptQuest is delivered as OptQuestEngine.dll
which contains the optimization engine and OptQuestNet.dll
which contains the C# language bindings. In your C# application, you’ll import OptQuestNet.dll
and at run time, both OptQuestNet.dll
and OptQuestEngine.dll
need to be in the same directory. An Visual Studio solution file is provided with working examples of linking a C# application to OptQuest.
OptQuest is delivered as OptQuestEngine.dll
and OptQuestLib.dll
which contain the optimization engine and OptQuest.h
and OptQuestLib.lib
which contains the C++ language bindings. In your C++ application, OptQuestLib.dll
and at run time OptQuestEnginge.dll
needs to be in the same directory as your application. An Visual Studio solution file is provided with working examples of linking a C++ application to OptQuest.
OptQuest is delivered as OptQuestEngine.dll
and OptQuestLib.dll
which contain the optimization engine and OptQuest.h
and OptQuestLib.lib
which contains the C language bindings. In your C application, OptQuestLib.dll
and at run time OptQuestEnginge.dll
needs to be in the same directory as your application. An Visual Studio solution file is provided with working examples of linking a C application to OptQuest.
OptQuest is delivered as OptQuestEngine.dll
and OptQuestLib.dll
which contain the optimization engine and OptQuest.py
which contains the Python language bindings. By default, OptQuest.py will look for OptQuestLib.dll
in the current working directory. After importing optquest.py
the variable dll_path
can be set to the location of OptQuestLib.dll
. OptQuestEngine.dll
needs to be in the same directory as OptQuestLib.dll
. A working example is provided.
For expert use only. The OptQuest engine can be accessed as a standalone application using a standard input/output (STDIO) interface, enabling communication with your application via STDIN and STDOUT. This interface is intended as a last-resort method for integrating optimization capabilities when direct linking to OptQuest libraries (Java, C#, C++, or C) is not feasible. Only manual optimization is supported; managed optimization is not available.
OptQuest.exe
executable, included with the example Visual Studio solution, starts an OptQuest server that listens for commands on STDIN and writes results to STDOUT.OptQuest.jar
file includes a Main()
function with identical behavior. Run java -jar OptQuest.jar
to start the server, which listens on STDIN and writes to STDOUT.\n
), with parameters separated by spaces.END
.OptQuest.exe
(Windows) or java -jar OptQuest.jar
(Java) from the command line.END
.ERROR
.ERROR
prefixes and read subsequent lines until the buffer is empty.The OptQuest STDIO interface supports a subset of functionality for manual optimization workflows, allowing interaction with the optimization engine via STDIN commands and STDOUT responses. Commands facilitate model creation, variable and constraint definition, solution generation, and result retrieval. Below is a detailed list of supported commands, their descriptions, and their equivalents in the OptQuest API.
Command | Description | API Equivalent |
---|---|---|
CREATEMODEL |
Creates a new model object. | new OptQuestModel() |
CREATESOLUTION |
Generates a new solution for evaluation, populated with input variable values. | model.CreateSolution() |
SUBMITSOLUTION |
Submits an evaluated solution to the optimization engine for processing. | solution.Submit() |
REJECTSOLUTION |
Rejects a solution that could not be evaluated. | solution.Reject() |
ADDSOLUTION |
Adds a suggested (input-only) or evaluated (input and output) solution to the model. | solution.AddSuggested() solution.AddEvaluated() |
GETSOLUTION |
Retrieves an evaluated solution’s full state after engine post-processing. | solution.Update() |
GETBESTSOLUTIONS |
Retrieves the best solutions, either the n-best or the Pareto frontier. | model.GetBestSolutions(limit) |
GETALLSOLUTIONS |
Retrieves all evaluated solutions from the model. | model.GetAllSolutions() |
ADDALLSOLUTIONS |
Copies all solutions from a source model to a destination model. | model.AddAllSolutions(srcModel) |
DELETEMODEL |
Deletes a model, freeing associated resources. | OptQuestModel destructor |
QUIT |
Terminates the OptQuest STDIO server, closing the session. |
The CREATEMODEL
command is a multi-line command that defines a new OptQuest model. It begins with CREATEMODEL
, followed by model definition commands, and ends with a single line containing END
. Each model definition command is a single line with space-delimited parameters.
CREATEMODEL
...model definition commands...
END
Each model definition command starts with a string identifier followed by one or more parameters, separated by spaces unless otherwise noted. The table below lists supported commands and their equivalent OptQuest API functions.
Command | Parameters | Equivalent API Function |
---|---|---|
LICENSE |
<license> |
model.SetLicense(license) |
LOGSETUP |
<filespec> |
model.LogSetup(filespec) |
LOGSOLUTIONS |
<filespec> |
model.LogSolutions(filespec) |
CONTINUOUS |
<name> <min> <max> |
model.AddContinuousVariable(name, min, max) |
INTEGER |
<name> <min> <max> |
model.AddIntegerVariable(name, min, max) |
DISCRETE |
<name> <min> <max> <step> |
model.AddDiscreteVariable(name, min, max, step) |
BINARY |
<name> |
model.AddBinaryVariable(name) |
DESIGN |
<name> <num> |
model.AddDesignVariable(name, num) |
ENUMERATION |
<name> <items> <items> : Space-delimited list of doubles |
model.AddEnumerationVariable(name, items) |
PERMUTATION |
<group> <names> <names> : Space-delimited list of strings |
model.AddPermutationVariable(group, names) |
TUPLE |
<name> <tuples> <tuples> : Comma-separated values, semicolon-separated tuples (e.g., a,b,c;d,e,f )¹ |
model.AddTupleVariable(name, tuples) |
GEOLOCATION |
<name> <locations> <locations> : Comma-separated lat/lon pairs, semicolon-separated (e.g., lat1,lon1;lat2,lon2 )¹ |
model.AddGeolocationVariable(name, locations) |
EXCLUSIVE |
<name> <min> <max> |
model.AddVariableExclusiveRange(name, min, max) |
OUTPUT |
<name> |
model.AddOutputVariable(name) |
OUTPUTSTATISTIC |
<name> <statistic> <statisticValue> |
model.SetOutputStatistic(name, statistic, statisticValue) |
OBJECTIVE |
<name> <direction> <expression> <direction> : MIN or MAX |
model.AddMinimizeObjective(name, expression) (if MIN ) model.AddMaximizeObjective(name, expression) (if MAX ) |
OBJECTIVEGOAL |
<name> <min> <max> |
model.SetObjectiveGoal(name, min, max) |
OBJECTIVECONFIDENCE |
<name> <ctype> <clevel> <epct> |
model.SetObjectiveConfidence(name, ctype, clevel, epct) |
OBJECTIVESTATISTIC |
<name> <statistic> <statisticValue> |
model.SetObjectiveStatistic(name, statistic, statisticValue) |
CONSTRAINT |
<name> <expression> |
model.AddConstraint(name, expression) |
REPLICATIONS |
<min> <max> |
model.SetReplications(min, max) |
SERIALREPLICATIONS |
None | model.SetSerialReplications() |
METRIC |
<name> <responseExpression>;<errorExpression> ² |
model.AddSampleMetric(name, responseExpression, errorExpression) |
SAMPLE |
<method> |
model.SetSampleMethod(method) |
¹ Tuple and Geolocation Format: Tuples and geolocations are specified as a single string with comma-separated values for each tuple or coordinate pair, and semicolon-separated groups. For example, four tuples (a,b,c)
, (d,e,f)
, (g,h,i)
, (j,k,l)
are written as a,b,c;d,e,f;g,h,i;j,k,l
. Similarly, geolocations are formatted as lat1,lon1;lat2,lon2
.
² Metric Expressions: The responseExpression
and errorExpression
in the METRIC
command are delimited by a semicolon (;
) to allow spaces within the expressions.
A single integer representing the unique identifier for the newly created model.
If there is an error, the return will begin with ERROR
followed by description of what went wrong.
<modelIdentifier>
A single-line command that takes one parameter: the integer identifier of the model to which the solution belongs.
CREATESOLUTION <modelIdentifier>
A multi-line response defining the created solution:
If there is an error, the return will begin with ERROR
followed by description of what went wrong.
<modelIdentifier> <solutionIdentifier>
<iteration> <replication> <numberOfReplications> <isComplete> <isFeasible> <hasMetConfidence> <isEvaluated>
<inputName1> <inputValue1>
...
<inputNameN> <inputValueN>
A multi-line command to submit an evaluated solution:
SUBMITSOLUTION
followed by two integers: <modelIdentifier>
(model ID) and <solutionIdentifier>
(solution ID).<variableName>
(string) and <variableValue>
(double) for output variables and, optionally, input variables if they were modified during evaluation.END
to terminate the command.SUBMITSOLUTION
<modelIdentifier> <solutionIdentifier>
<variableName1> <variableValue1>
...
<variableNameN> <variableValueN>
END
A single integer representing the total number of evaluated solutions in the model.
If an error occurs (e.g., invalid solution ID), the response begins with ERROR
followed by a description.
<numberCompleted>
A single-line command that takes two integer parameters: <modelIdentifier>
(model ID) and <solutionIdentifier>
(solution ID) to reject a solution that could not be evaluated.
REJECTSOLUTION <modelIdentifier> <solutionIdentifier>
A single integer representing the total number of evaluated solutions in the model.
If an error occurs (e.g., invalid solution ID), the response begins with ERROR
followed by a description.
<numberCompleted>
A multi-line command to add a suggested or evaluated solution to a model:
ADDSOLUTION
followed by two integers: <modelIdentifier>
(model ID) and <isEvaluated>
(flag: 0
for suggested solution with only input values, 1
for evaluated solution with both input and output values).<variableName>
(string) and <variableValue>
(double) for all input variables, and, if <isEvaluated>
is 1
, all output variables.END
to terminate the command.ADDSOLUTION
<modelIdentifier> <isEvaluated>
<variableName1> <variableValue1>
...
<variableNameN> <variableValueN>
END
A single line with OK
on success.
If an error occurs (e.g., invalid model ID or missing required values), the response begins with ERROR
followed by a description.
OK
A single-line command that takes two integer parameters: <modelIdentifier>
(model ID) and <solutionIdentifier>
(solution ID) to retrieve all information about a specific solution.
GETSOLUTION <modelIdentifier> <solutionIdentifier>
A multi-line response containing comprehensive details about the solution, including all evaluated replications:
First Line: Two integers: <modelIdentifier>
(model ID) and <solutionIdentifier>
(solution ID).
Second Line: Seven integers:
<iteration>
: Iteration number assigned to the solution.<replication>
: Replication number for this solution instance.<numberOfReplications>
: Total number of replications for the solution.<isComplete>
: 1
if all replications are complete, 0
otherwise.<isFeasible>
: 1
if the solution satisfies all constraints, 0
otherwise.<hasMetConfidence>
: 1
if confidence requirements are met (in variable replication mode), 0
otherwise.<isEvaluated>
: 1
if the solution has been evaluated, 0
otherwise.Subsequent Lines: Space-delimited pairs of keys (string) and values (double) for:
<inputName>
and <inputValue>
.<outputName>
and <outputValue>
, plus per-replication values as <outputName;R>
for replication R
.<objectiveName>
and <objectiveValue>
, confidence width as <objectiveName;cw>
, and per-replication values as <objectiveName;R>
for replication R
.<constraintName>
(1.0
for feasible, 0.0
for infeasible), and per-clause left-hand side (<constraintName;LHS;C>
) and right-hand side (<constraintName;RHS;C>
) for clause C
.If an error occurs (e.g., invalid solution ID), the response begins with ERROR
followed by a description.
<modelIdentifier> <solutionIdentifier>
<iteration> <replication> <numberOfReplications> <isComplete> <isFeasible> <hasMetConfidence> <isEvaluated>
<inputName1> <inputValue1>
...
<inputNameN> <inputValueN>
<outputName1> <outputValue1>
<outputName1;1> <outputValue1Replication1>
...
<outputName1;R> <outputValue1ReplicationR>
...
<outputNameN> <outputValueN>
<outputNameN;1> <outputValueNReplication1>
...
<outputNameN;R> <outputValueNReplicationR>
<objectiveName1> <objectiveValue1>
<objectiveName1;cw> <objectiveConfidenceWidth1>
<objectiveName1;1> <objectiveValue1Replication1>
...
<objectiveName1;R> <objectiveValue1ReplicationR>
...
<objectiveNameN> <objectiveValueN>
<objectiveNameN;cw> <objectiveConfidenceWidthN>
<objectiveNameN;1> <objectiveValueNReplication1>
...
<objectiveNameN;R> <objectiveValueNReplicationR>
<constraintName1> <constraintFeasibility1>
<constraintName1;LHS;1> <constraintLeftHandSideValue1Clause1>
<constraintName1;RHS;1> <constraintRightHandSideValue1Clause1>
...
<constraintName1;LHS;C> <constraintLeftHandSideValue1ClauseC>
<constraintName1;RHS;C> <constraintRightHandSideValue1ClauseC>
...
<constraintNameN> <constraintFeasibilityN>
<constraintNameN;LHS;1> <constraintLeftHandSideValueNClause1>
<constraintNameN;RHS;1> <constraintRightHandSideValueNClause1>
...
<constraintNameN;LHS;C> <constraintLeftHandSideValueNClauseC>
<constraintNameN;RHS;C> <constraintRightHandSideValueNClauseC>
A single-line command that takes two integer parameters: <modelIdentifier>
(model ID) and <limit>
(number of best solutions to return; ignored for multi-objective optimizations, where the entire Pareto frontier is returned).
GETBESTSOLUTIONS <modelIdentifier> <limit>
A multi-line response containing a concatenated list of the best solutions in the format of GETSOLUTION
. Each solution, including the first, is preceded by a line with three dashes and a 0-based counter value.
If an error occurs (e.g., invalid model ID), the response begins with ERROR
followed by a description.
--- 0
<solution 1 output>
--- 1
<solution 2 output>
...
--- <n-1>
<solution N output>
A single-line command that takes one parameter: <modelIdentifier>
(model ID).
GETALLSOLUTIONS <modelIdentifier>
A multi-line response containing a concatenated list of all evaluated solutions in the format of GETSOLUTION
. Each solution, including the first, is preceded by a line with three dashes and a 0-based counter value.
If an error occurs (e.g., invalid model ID), the response begins with ERROR
followed by a description.
--- 0
<solution 1 output>
--- 1
<solution 2 output>
...
--- <n-1>
<solution N output>
A single-line command that takes two integer parameters: <destinationModelIdentifier>
(destination model ID) and <sourceModelIdentifier>
(source model ID).
ADDALLSOLUTIONS <destinationModelIdentifier> <sourceModelIdentifier>
A single line with OK
on success.
If an error occurs (e.g., invalid model IDs), the response begins with ERROR
followed by a description.
OK
A single-line command that takes one parameter: <modelIdentifier>
(model ID).
DELETEMODEL <modelIdentifier>
A single line with OK
, regardless of whether the model existed.
OK
A single-line command with no parameters.
QUIT
Here’s an example of how to define a model, request a few solutions, evaluate them, and print out the best. Lines beginning with >
are inputs from STDIN from the client, and lines beginning with <
are responses that are sent to STDOUT by the server.
> CREATEMODEL
> CONTINUOUS X -10 10
> CONTINUOUS Y -15 15
> OUTPUT Z
> CONSTRAINT C1 X<Y
> CONSTRAINT C2 X+Y>1
> CONSTRAINT C3 X+Y<10
> OBJECTIVE O1 MAX X+Y-Z
> END
< 0
> CREATESOLUTION 0
< 0 0
< 1 1 1 0 0 1 0
< X -2.5
< Y 7.75
> SUBMITSOLUTION
> 0 0
> Z 66
> END
< 1
> CREATESOLUTION 0
< 0 1
< 2 1 1 0 0 1 0
< X 0.5
< Y 0.5
> SUBMITSOLUTION
> 0 1
> Z .5
> END
< 2
> CREATESOLUTION 0
< 0 2
< 3 1 1 0 0 1 0
< X -5.0
< Y 15.0
> SUBMITSOLUTION
> 0 2
> Z 250
> END
< 3
> GETBESTSOLUTIONS 0 1
< --- 0
< 2 1 1 1 1 1 0
< X 0.5
< Y 0.5
< Z 0.5
< O1 0.5
< C3 1.0
< C3;LHS;1 1.0
< C3;RHS;1 10.0
< C1 1.0
< C1;LHS;1 0.5
< C1;RHS;1 0.5
< C2 1.0
< C2;LHS;1 1.0
< C2;RHS;1 1.0
> GETALLSOLUTIONS 0
< --- 0
< 2 1 1 1 1 1 0
< X 0.5
< Y 0.5
< Z 0.5
< O1 0.5
< C3 1.0
< C3;LHS;1 1.0
< C3;RHS;1 10.0
< C1 1.0
< C1;LHS;1 0.5
< C1;RHS;1 0.5
< C2 1.0
< C2;LHS;1 1.0
< C2;RHS;1 1.0
< --- 1
< 1 1 1 1 1 1 0
< X -2.5
< Y 7.75
< Z 66.0
< O1 -60.75
< C3 1.0
< C3;LHS;1 5.25
< C3;RHS;1 10.0
< C1 1.0
< C1;LHS;1 -2.5
< C1;RHS;1 7.75
< C2 1.0
< C2;LHS;1 5.25
< C2;RHS;1 1.0
< --- 2
< 3 1 1 1 1 1 0
< X -5.0
< Y 15.0
< Z 250.0
< O1 -240.0
< C3 1.0
< C3;LHS;1 10.0
< C3;RHS;1 10.0
< C1 1.0
< C1;LHS;1 -5.0
< C1;RHS;1 15.0
< C2 1.0
< C2;LHS;1 10.0
< C2;RHS;1 1.0
> DELETEMODEL 0
< OK
> QUIT