Using The Toxeus Cloud Solver
The Toxeus Cloud Solver (TCS) incorporates many optimization problem components and parameters. In addition, there are certain formatting guidelines that must be followed to create a correct TCS problem file. The following sections provide details and example snippet code concerning each component, parameter, as well as required code and formatting guidelines.
Before Starting
Make sure that the current version of the Toxeus Node SDK is installed by running the following command in your terminal:
npm install toxeus-node-sdk@latest
Also, it might be worthwhile to download a working example optimization problem, containing all currently supported parameters accessible through the Toxeus Cloud Solver (TCS).
Header information at the top of TCS problem files.
Each TCS problem file needs to have information at the top of the file. The following example code snippet assumes that the users email address is 'jill@yahoo.com' and TCS password is 'Password1'.
const TOXEUS_EMAIL = "jill@yahoo.com"
const TOXEUS_PASSWORD = "Password1"
const { Client, Model } = require('toxeus-node-sdk');
const toxeus = new Client(TOXEUS_EMAIL, TOXEUS_PASSWORD);
const model = new Model();
Adding Decision Variables
REQUIRED: The addDecisionVariable method will permit the addition of a new decision variable to the problem instantiation. Each decision variable present in the problem must be defined using the addDecisionVariable method. Only the decision variable name
is required.
model.addDecisionVariable({
name: "t"});
A complete list of parameters and their default values is shown in the example code snippet below.
model.addDecisionVariable({
name: "t",
lower_bound: "-inf",
upper_bound: "inf",
initial_region_to_select_starting_points_from: {
lower_bound: 0,
upper_bound: 10
}
});
The parameters lower_bound
and upper_bound
specify the boundaries of the decision variable. By default, they are set to -inf
(negative infinity) and inf
(infinity).
The initial_region_to_select_starting_points_from
parameter specifies the region from which the TCS will select starting points for the defined variable. The default value is 0 for the 'lower_bound' and 10 for the 'upper_bound'. The default values are automatically used if no values are defined (as in the code below). The lower_bound
and upper_bound
of the initial_region_to_select_starting_points_from
parameter must be within the lower_bound
and upper_bound
of the decision variable, and they must be finite in value.
model.addDecisionVariable({
name: "t",
lower_bound: "-inf",
upper_bound: "inf"
});
Note: Defining the lower_bound
, upper_bound
, and initial_region_to_select_starting_points_from
paramenters can be beneficial in terms of solution quality and stability, as well as algorithm efficiency. These bounds help ensure that the TCS selects starting points and searches only within a feasible and meaningful solution space, which can lead to better and more reliable solutions to the problem.
⚠️ Warning: There are certain reserved keywords, that must not be used for variable names. Refer to Supported Operators and Functions for a list of these reserved keywords. MJH NOTE --- ON THIS 'FUNCTIONS' PAGE, ALSO NEED TO DENOTE ANY OTHER RESTRICTED WORDS, LIKE 'CONST', THAT A USER CAN NOT USE FOR A VARIABLE NAME.
Adding Constraints
OPTIONAL: The addConstraint method can be used to add a constraint to the problem definition. Each constraint must be defined using this method. Supported binary relationships include >=
, <=
, and =
. It is important to make sure all decision variables included in a constraint are properly defined, as shown above. Example snippet code showing each binary relationship in the constraint definition are shown below.
model.addConstraint("x + y + z >= 10");
model.addConstraint("x + y + z <= 15");
model.addConstraint("(x + y)^2 = 10");
Adding an Objective Function
OPTIONAL: The setObjective method can be used to define an objective function for the problem definition. The setObjective method takes an object with an expression
defining the objective function, and a type
indicating whether to minimize
or maximize
the objective function defined in the expression
.
Below are two example code snippets, showing how to define an objective fucntion to be maximized, and how to define an objective function to be minimized. Note that all variables used in the objective function must be defined correctly, using the addDecisionVariable code.
model.setObjective({
expression: "x^3 + y + z",
type: "maximize"
});
model.setObjective({
expression: "t1 + 2*t2^4 - 3*t1*sin(t2)",
type: "minimize"
});
NOTE: At this time, the TCS only supports problems with one objective.
Note: As seen above, both the addConstraint and setObjective commands are optional. However, each problem file must have at least one addConstraint command or setObjective command.
Maximum TCS Runtime In Seconds (Integer
)
OPTIONAL: The setMaximumSolverRuntimeInSeconds command Specifies the maximum amount of time to allow the TCS to find solutions to the problem. The maximum value is 900 seconds (15 minutes). MJH NOTE --- IS THERE A DEFAULT VALUE???
model.setMaximumSolverRuntimeInSeconds(60);
Maximum Number Of Solutions To Return from TCS (Integer
)
OPTIONAL: The setMaximumNumberOfSolutionsToReturn command specifies the maximum number of solutions the TCS will return. MJH NOTE -- Q1: IS THERE A DEFAULT VALUE? Q2: IS THERE A MAXIMUM VALUE? Q3: WHY WOULD THE USER EVERY WANT TO NOT USE THE MAXIMUM?
model.setMaximumNumberOfSolutionsToReturn(5);
Maximum Acceptable Error for Constraint Violation (Float
)
OPTIONAL: The setMaximumAcceptableError command specifies the maximum allowable constraint violation for a solution found by the TCS. The default value is set at '0.1', and the minimum alowable value for this parameter is '0'. Note: This command only applies to problems that have included the addConstraint command in their definition.
model.setMaximumAcceptableError(0.1);
Maximum Acceptable Objective Function Value Difference From Best Solution Found (Float
)
OPTIONAL: The setMaximumAcceptableObjectiveFunctionValueDifferenceFromBestSolutionFound command is used to define a tolerance around the objective function value for the best solution found - if another solution found has an objective function value within this threshold, the TCS will also consider this second solution as a solution to the problem. The default value is infinity or how many solution is found in the runtime of the solver. MJH Note - the previous sentence does not read well.... Note This command only applies to problems that have included the setObjective command in their definition.
model.setMaximumAcceptableObjectiveFunctionValueDifferenceFromBestSolutionFound(100);
Minimum Acceptable Distance Between Distinct Solutions (Float
)
OPTIONAL: The setMinimumAcceptableDistanceBetweenDistinctSolutions command defines the minimum acceptable Euclidean distance (L2 norm) for two solutions to be identified as 'distinct'. The default value is 0.01
and the minimum allowable value is 0
.
model.setMinimumAcceptableDistanceBetweenDistinctSolutions(0.1);
Note If the minimum acceptable distance is set to
0
, the TCS will return all solutions found. This may result in a large number of duplicate solutions being returned, due to round-off error and numerical approximations.
Penalized Points (Array of Dictionaries
)
OPTIONAL: The setPenalizedPoints commands defines points that are known before running the TCS (and are known external to the TCS) that the TCS should avoid, in the search for solutions to the problem. Each object in the array of dictionaries specifies a given penalized point as well as the radus around the point for the TCS to inject a penalty. The example code snippet below shows two penalizezd points. The first is x_1 = 0, x_2 = 0, with a radius of 0.2, and the second is x_1 = 3, x_2 = -1.9, with a radius of 0.7. Note: Each variable listed in the 'penalized_point' portion of the array must be defined using the addDecisionVariable command, And all decision variables defined with the addDecisionVariable command must be present in the 'penalized_point'. Note: The minimum 'penalty_radius' is 0.0.
model.setPenalizedPoints([
{
penalized_point:{
x_1: 0,
x_2: 0
},
penalty_radius:0.2
}
]);
model.setPenalizedPoints([
{
penalized_point:{
x_1: 3,
x_2: -1.9
},
penalty_radius:0.7
}
]);
MJH NOTE: FOR THE ABOVE CODE SNIPPET, SHOULD HAVE PLOT OF A 2-D SIMPLE FUNCTION, SHOWING THE ORIGINAL FUNCTION, AND THEN SHOWING THE TWO PENALTIES AS PART OF THE OBJECTIVE FUNCTION SURFACE.
Number of Starting Points (Integer
)
OPTIONAL: The setNumberOfStartingPoints command sets the number of starting points for the TCS to run in parallel, for a given 'run'. The default value is 1
and the maximum value is 100
. An example code snippet below shows setting the number of starting points to run in parallel to be 5.
model.setNumberOfStartingPoints(5);
Number of Runs (Integer
)
OPTIONAL: The setNumberOfRuns command specifies the number of independent times the TCS will solve the input problem, using the setNumberOfStartingPoints PARAMETER value to determine the number of randomly chosen starting points to use (in parallel) to perform the 'run'. The default value is 1, and the maximum allowed value is 10. An example code snippet of setting this parameter to 4 is shown below.
model.setNumberOfRuns(4);
Dynamic Penalty
OPTIONAL: tHE setDynamicPenalty command can be instantiated, in order for the TCS in the current run (performing multiple runs with the setNumberOfRuns commands) to create an artificially high smooth peak around any solutions that have been found in previous runs of the TCS. This is an important feature when there are multiple optimal solutions to the problem, and there is a need to find more than just one optimal solution. Note: When there is an objective function as part of the problem, any solution found bt the TCS is a locally optimal solution, and might possibly also be globally optimal.
There are multiple settings that can be chosen within the setDynamicPenalty command.
The first concerns which solutions to penalize. There are three options. They are:
"penalize_all_local_optima_found"
"penalize_best_local_optima_found"
"penalize_all_local_optima_found_which_satisfy_the_maximum_acceptable_error"
MJH NOTE: THIS THIRD OPTION ABOVE - HOW IS IT RELATED TO 'setMaximumAcceptableError', WHICH IS A COMMAND USED FOR CONSTRAINT VIOLATION? OR IS THE THIRD OPTION RELATED TO 'setMaximumAcceptableObjectiveFunctionValueDifferenceFromBestSolutionFound'? IF SO, WILL NEED TO RENAME THIS THIRD OPTION.
The "penalize_all_local_optima_found"
option puts a penalty region around all locally optimal solutions found so far by the TCS. The "penalize_best_local_optima_found"
option only puts a penalty region around the solution TCS has found that produces the best value when used to evaluate the objective function. The "penalize_all_local_optima_found_which_satisfy_the_maximum_acceptable_error"
option INSERT VERBIAGE AFTER CLARIFICATION TO ABOVE MJH NOTE
The second setting concerns the type of distribution with which to use to modify the objective function surface around the penalized points. There are two current options, a Uniform distribution and a Weibull distribution. The two settings are given as:
"uniform"
"weibull"
The third setting concerns the minimum and maximum values from which to choose the redius for the penalty region around each penalized solution found by the TCS. Given the minimum and maximum radius values, for each solution that will be penalized, the radius is chosen uniformly within the [minimum,maximum] interval.
An example code snippet is shown below, penalizing all locally optimal solutions already found by the TCS, making use of the Uniform distribution around each penalized point, and choosing the radius for the penalty region around each penalized solution in the interval [0.01,0.3].
model.setDynamicPenalty({
dynamic_penalty_mode: "penalize_all_local_optima_found",
dynamic_penalty_radii_probability_distribution: { distribution: "uniform" },
dynamic_penalty_radii_maximum_value: 0.3,
dynamic_penalty_radii_minimum_value: 0.01
});
Problem Name (String
)
OPTIONAL: The setProblemName command allows a descriptive name to be connected to the problem. This is especially useful when multiple problems are being solved by the TCS, each one differing slightly. An example code snippet is below.
model.setProblemName("Example_Problem_for_TCS");
Problem Description (String
)
OPTIONAL: The setProblemDescription command allows a more verbose description of the problem to be saved with the problem. An example code snippet is below.
model.setProblemDescription("An example problem which shows how to use the toxeus-node-sdk to formulate and solve a problem using the TCS");
Problem Tags ( Array of Strings
)
OPTIONAL: The setProblemTags command allows one to include specific problem tags, for categorization, organization, and searchability. One might want to categorize problems by date, or specific type of objective function, or how the dynamic penalty settings were utilized. An example code snippet is below.
model.setProblemTags(["example-tag-1", "example-tag-2"]);
Specifying a Directory to Save Results
OPTIONAL: The setDownloadDirectory method can be used to specify where TCS results will be saved. By default, results are created to a file in the current working directory. The following code snippet example shows how to save the results to the directory C:/SavedResults/Today/.
toxeus.setDownloadDirectory("C:/SavedResults/Today/");
Specifying Whether to Compress the Saved Results File
OPTIONAL: The setCompression command can be used to enable or disable compression of the results file. The first code snippet example enables compression, and the second disables it. When compression is enabled, the results file is compressed using the Brotli compression scheme (need reference for this compression). When compression is disabled, the results file is formatted as a JSON file.
toxeus.setCompression(true);
toxeus.setCompression(false);
Note: The setDownloadDirectory and setCompression methods allow for the customization of how and where the TCS stores the solution to the problem file, balancing between storage efficiency and ease of access.
Final information at the bottom of TCS problem files.
REQUIRED: Each TCS problem file needs to have information at the end of the file. The last line of the TCS problem file is the command to actually solve the problem. If the line at the top of the TCS problem file defined the problem using the line const model = new Model();, then the last line of the TCS problem file should read as follows:
toxeus.Solve(model);
Note: Inbetween the commands const model = new Model(); and toxeus.Solve(model);, the order of the other commands does not matter. In fact, a command could be listed twice, with the second listing replacing the first listing as far as parameter definition values.
ORIGINAL VERBIAGE BELOW.
Using The Toxeus Cloud Solver
The Toxeus Cloud Solver (TCS) incorporates many optimization problem components and parameters. The following sections provide details and examples about each component and parameter.
Michael's first edit
Before Starting
Make sure that you have the latest version of the Toxeus Node SDK by running the following command in your terminal:
npm install toxeus-node-sdk@latest
Also, download a working example optimization problem, which contains all currently supported parameters accessible through the Toxeus Cloud Solver (TCS).
Javascript
const TOXEUS_EMAIL = ""
const TOXEUS_PASSWORD = ""
const { Client, Model } = require('toxeus-node-sdk');
const toxeus = new Client(TOXEUS_EMAIL, TOXEUS_PASSWORD);
// (optional) Set the download directory for the solver results.
// See https://docs.toxeus.org/docs/solver-parameters#specifying-a-directory-to-save-results-to for more information
// toxeus.setDownloadDirectory("C:/Users/Jill/Desktop/Toxeus");
const model = new Model();
// Beginning of Solver Parameters:
// (optional) Set compression to false to disable compression (default is false).
// See https://docs.toxeus.org/docs/solver-parameters#specifying-a-directory-to-save-results-to for more information
model.setCompression(false);
// (optional) Set a problem name, description, and one or more tags
model.setProblemName("Example Problem For The Toxeus Cloud Solver");
model.setProblemDescription("An example problem which shows how to use the toxeus-node-sdk to formulate and solve a problem using the Toxeus Cloud Solver");
model.setProblemTags(["example-tag-1", "example-tag-2"]);
// (optional) Set the number of starting points the solver should search from in parallel (default: 6, max: 600)
// See https://docs.toxeus.org/docs/solver-parameters#number-of-starting-points for more information
model.setNumberOfStartingPoints(6);
// (optional) Set the number of runs the solver should perform. Each run will be performed by a different instance of the solver running in parallel from a different starting point. (default: 1, max: 10).
// See https://docs.toxeus.org/docs/solver-parameters#number-of-runs for more information
model.setNumberOfRuns(1);
// (optional) Set the maximum acceptable error of solutions that the solver will return (default: 10)
// See https://docs.toxeus.org/docs/solver-parameters#maximum-acceptable-error for more information
model.setMaximumAcceptableError(10);
// (optional) Set the maximum number of solutions that the solver will return (default: infinity)
// See https://docs.toxeus.org/docs/solver-parameters#maximum-number-of-solutions-to-return for more information
model.setMaximumNumberOfSolutionsToReturn(1000);
// (optional) Set the maximum acceptable objective function value difference from best solutions found (default: infinity)
// See https://docs.toxeus.org/docs/solver-parameters#maximum-acceptable-objective-function-value-difference-from-best-solutions-found for more information
model.setMaximumAcceptableObjectiveFunctionValueDifferenceFromBestSolutionFound(1000000);
// (optional) Set the maximum solver runtime in seconds (default: 900)
// See https://docs.toxeus.org/docs/solver-parameters#maximum-solver-runtime-in-seconds for more information
model.setMaximumSolverRuntimeInSeconds(60);
// (required) Define a new decision variable with a name, lower bound, upper bound, and initial region to select starting points from
// See https://docs.toxeus.org/docs/solver-parameters#decision-variables for more information
model.addDecisionVariable({
name: "x",
lower_bound: 10,
upper_bound: "inf",
initial_region_to_select_starting_points_from: {
lower_bound: 11,
upper_bound: 14
}
});
model.addDecisionVariable({
name: "y",
lower_bound: -20,
upper_bound: 24,
initial_region_to_select_starting_points_from: {
lower_bound: -10,
upper_bound: 12
}
});
model.addDecisionVariable({
name: "z",
lower_bound: -20,
upper_bound: 24,
initial_region_to_select_starting_points_from: {
lower_bound: 0.1,
upper_bound: 10
}
});
// (required if no objective is set) Define a new constraint with an expression and optionally, a name
// See https://docs.toxeus.org/docs/solver-parameters#constraints for more information
model.addConstraint("x + y + z <= 10");
// (required if no constraints are set) Define a new objective function with an expression and type
// See https://docs.toxeus.org/docs/solver-parameters#objective-functions for more information
model.setObjective({
expression: "(1/x+y+z-3)^2+(x+1/y+z-3)^2+(x+y+1/z-3)^2",
type: "minimize"
});
// (optional) Set the algorithm parameters for the solver.
model.setAlgorithmParameters({
"algorithm": "Nelder-Mead",
})
// (optional) Set the penalized points for the solver. These are points that the solver should avoid, such as local optima. The penalty radius is the distance from the point that the solver should avoid.
model.setPenalizedPoints([
{
penalized_point:{
x: 0,
y: 0,
z: 0
},
penalty_radius: 0.01
}
])
// (optional) Set the dynamic penalty for the solver.
model.setDynamicPenalty()
// End of Solver Parameters
// Solve the model and save the results to a JSON file
toxeus.Solve(model);
Adding Decision Variables
Use the addDecisionVariable method to add a decision variable to your problem. Each decision variable present in your problem must be defined using the addDecisionVariable method.Only the decision variable name
is required. A complete list of parameters and their default values is shown in the example below.
model.addDecisionVariable({
name: "x",
lower_bound: "-inf",
upper_bound: "inf",
initial_region_to_select_starting_points_from: {
lower_bound: 0,
upper_bound: 10
}
});
The parameters lower_bound
and upper_bound
specify the boundaries of the decision variable. By default, they are set to -inf
(negative infinity) and inf
(infinity).
Defining the lower_bound
, upper_bound
, and initial_region_to_select_starting_points_from
paramenters can be beneficial in terms of solution quality, efficiency, and stability. These bounds help ensure that the solver selects starting points and searches only within a feasible and meaningful solution space, which can lead to better and more reliable results.
The initial_region_to_select_starting_points_from
parameter specifies the region from which Toxeus Cloud Solver (TCS) will select starting points. The default value is between 0 and 10 for each decision variable. The lower_bound
and upper_bound
of the initial_region_to_select_starting_points_from
parameter must be within the lower_bound
and upper_bound
of the decision variable, and they must be finite.
⚠️ Warning: Avoid using reserved keywords for variable names. Refer to Supported Operators and Functions for a list of reserved keywords.
Adding Constraints
Use the addConstraint method to add a constraint to your problem. Each constraint must be defined using this method. Supported relationships include >=
, <=
, and =
.
const TOXEUS_EMAIL = ""
const TOXEUS_PASSWORD = ""
const { Client, Model } = require('toxeus-node-sdk');
const toxeus = new Client(TOXEUS_EMAIL, TOXEUS_PASSWORD);
const model = new Model();
model.addDecisionVariable({name: "x"});
model.addDecisionVariable({name: "y"});
model.addDecisionVariable({name: "z"});
model.addConstraint("x + y + z >= 10");
model.addConstraint("x + y + z <= 15");
model.addConstraint("(x + y)^2 = 10");
toxeus.Solve(model);
The example above shows how to formulate and solve a nonlinear system of equations and inequalities using the Toxeus Cloud Solver.
To solve an optimization problem with an objective function, see the Adding an Objective Function section for more information.
Adding an Objective Function
Use the setObjective method to define an objective function. The setObjective method takes an object with an expression
defining the objective function, and a type
indicating whether to minimize
or maximize
the objective function defined in the expression
.
const TOXEUS_EMAIL = ""
const TOXEUS_PASSWORD = ""
const { Client, Model } = require('toxeus-node-sdk');
const toxeus = new Client(TOXEUS_EMAIL, TOXEUS_PASSWORD);
const model = new Model();
model.addDecisionVariable({name: "x"});
model.addDecisionVariable({name: "y"});
model.addDecisionVariable({name: "z"});
model.addConstraint("x + y + z >= 10");
model.addConstraint("x + y + z <= 15");
model.addConstraint("(x + y)^2 = 10");
model.setObjective({
expression: "x^3+y+z",
type: "maximize"
});
toxeus.Solve(model);
The example above shows how to formulate and solve a nonlinear optimization problem using the Toxeus Cloud Solver.
The Toxeus Cloud Solver (TCS) only supports problems with one objective.
Optional Solver Parameters
Here are additional optional parameters that you can set in the solver.
Specifying a Directory to Save Results
Use the setDownloadDirectory method to specify where results will be saved, and setCompression to enable or disable compression.
-
Result Storage Location:
- By default, results are saved to the current working directory.
- To specify a custom directory, use the
setDownloadDirectory
method:toxeus.setDownloadDirectory("path/to/your/directory");
-
Result Compression:
- Use the
setCompression
method to enable or disable result compression:model.setCompression(true); // Enable compression
model.setCompression(false); // Disable compression (default) - When enabled, results are compressed using Brotli compression.
- When disabled (default), results are saved as uncompressed JSON files.
- Use the
These methods allow you to customize how and where the Toxeus Cloud Solver stores your optimization results, balancing between storage efficiency and ease of access.
Algorithm Parameters (Dictionary
)
Specify the optimization algorithm used by the model. The Toxeus Cloud Solver supports the following local search algorithms:
Local Search Algorithms
Powell
Nelder-Mead
Sbplx
Crs
Bobyqa
newuoa
newuoa-bound
praxis
mma
ccsaq
slsqp
lbfgs
tnewton-precond-restart
tnewton-precond
tnewton-restart
tnewton
var1
var2
auglag
auglag-eq
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setAlgorithmParameters({
"algorithm": "Nelder-Mead",
});
Number of Starting Points (Integer
)
Set the number of parallel starting points for the solver. The default value is 1
and the maximum value is 100
.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setNumberOfStartingPoints(5);
Number of Runs (Integer
)
Specifies the number of times the algorithm will execute. Each execution performs a run
, which is a parallel local search from all starting points. The number of starting points is determined by the setNumberOfStartingPoints()
method. This parameter allows for multiple independent optimization attempts, potentially increasing the chances of finding the global optimum. The default value is 1
, meaning a single execution, and the maximum allowed value is 10
. Increasing this value can be beneficial for complex problems with multiple local optima.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setNumberOfRuns(2);
Penalized Points (Array of Dictionaries
)
Specify points that the solver should avoid. This feature is useful for excluding known suboptimal regions or infeasible solutions, improving the efficiency of the search process. Each object in the array specifies a point and the radius around it to be penalized.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setPenalizedPoints([
{
penalized_point:{
x_1: 0,
x_2: 0
},
penalty_radius:0
}
]);
Dynamic Penalty
Dynamically penalize solutions during the optimization process to avoid known local optima. This is useful when exploring large, complex solution spaces.
Use the setDynamicPenalty method to set the dynamic penalty parameters. Supported modes are:
"penalize_all_local_optima_found"
"penalize_best_local_optima_found"
"penalize_all_local_optima_found_which_satisfy_the_maximum_acceptable_error"
Supported probability distributions are:
"uniform"
"weibull"
model.setDynamicPenalty({
dynamic_penalty_mode: "penalize_all_local_optima_found",
dynamic_penalty_radii_probability_distribution: { distribution: "uniform" },
dynamic_penalty_radii_maximum_value: 0.1,
dynamic_penalty_radii_minimum_value: 0.01
});
The radius of the dynamic penalty is sampled from the specified probability distribution between dynamic_penalty_radii_minimum_value
and dynamic_penalty_radii_maximum_value
. Each starting point from which local search is performed will be penalized by an independent and identically distributed random radius sampled from the specified probability distribution.
Maximum Acceptable Error (Float
)
Defines the upper limit of permissible error in the solutions found by the solver. The default setting stands at 0.1
, while the floor value is set at 0
, signifying that no degree of constraint violation is tolerable.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setMaximumAcceptableError(0.1);
Minimum Acceptable Distance Between Distinct Solutions (Float
)
Sets the minimum acceptable Euclidean distance between distinct solutions. This distance is calculated as the square root of the sum of squared differences between corresponding variables in two solutions. The default value is 0.01
and the minimum value is 0
.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setMinimumAcceptableDistanceBetweenDistinctSolutions(0.1);
Note If the minimum acceptable distance is set to
0
, the solver will return all solutions found. This may result in a large number of duplicate solutions being returned.
Maximum Number Of Solutions To Return (Integer
)
Limits the number of solutions the solver will return.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setMaximumNumberOfSolutionsToReturn(5);
Maximum Acceptable Objective Function Value Difference From Best Solution Found (Float
)
Set a maximum acceptable objective function value difference from the best solution found. The solver will only return solutions which have an objective function value difference less than this from the best solution found. The default value is infinity or how many solution is found in the runtime of the solver. Change the run time with the parameter setMaximumSolverRuntimeInSeconds
.
For example:
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setMaximumAcceptableObjectiveFunctionValueDifferenceFromBestSolutionFound(100);
Note This parameter is only valid for problems with an objective function.
Maximum Solver Runtime In Seconds (Integer
)
Specifies the solver's maximum runtime in seconds. The maximum value is 900 seconds (15 minutes).
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setMaximumSolverRuntimeInSeconds(60);
Problem Name (String
)
Add a descriptive name to the problem.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setProblemName("Example Problem For The Toxeus Cloud Solver");
Problem Description (String
)
Provide a detailed description of the problem.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setProblemDescription("An example problem which shows how to use the toxeus-node-sdk to formulate and solve a problem using the Toxeus Cloud Solver");
Problem Tags ( Array of Strings
)
Adding a problem tag can help you quickly categorize and find your problems.
const { Model } = require('toxeus-node-sdk');
const model = new Model();
model.setProblemTags(["example-tag-1", "example-tag-2"]);