Self-Hosted Service Client API Reference#
Client#
Service Client#
- class cuopt_sh_client.CuOptServiceSelfHostClient(
- ip: str = '0.0.0.0',
- port: str = '5000',
- use_https: bool = False,
- self_signed_cert='',
- polling_interval=1,
- request_excess_timeout=None,
- only_validate=False,
- polling_timeout=600,
- timeout_exception=True,
This version of the CuOptServiceClient is an interface with a self hosted version of the cuOpt core service. This client allows users to make calls to a self hosted instance of the cuOpt service at a specific ip and port.
It closely emulates the interface of the managed service client, however it does not implement most of the managed service-specific features required for interaction with NVIDIA Cloud Functions.
- Parameters:
ip (str) – The IP address of the cuOpt service. Defaults to 0.0.0.0
port (str) – The port of the cuOpt service. Defaults to 5000.
use_https (boolean) – Use HTTPS to communicate with server in secured way.
self_signed_cert (str) – A complete path to self signed certificate. If it’s a standard certificate, then no need to provide anything.
polling_interval (int) – The duration in seconds between consecutive polling attempts. Defaults to 1.
request_excess_timeout (int) – Note: Deprecated, Use polling_timeout instead
only_validate (boolean) – Only validates input. Defaults to False.
polling_timeout (int) – The time in seconds that the client will poll for a result before exiting and returning a request id. The request id may be polled again in a call to repoll(). If set to None, the client will never timeout and will poll indefinitely. Defaults to 600.
timeout_exception (boolean) – If True, the client returns a TimeoutError exception if polling_timeout seconds passes before a solution is returned. The value of the exception contains JSON giving the request id so that repoll() may be called to poll again for a result. If False, the client returns a dictionary containing the repoll information with no exception. Defaults to True.
- delete(
- id,
- running=None,
- queued=None,
- cached=None,
Delete a cached entry by id or abort a job by id.
- Parameters:
id (str) – A uuid identifying the cached entry or job to be deleted. The wildcard id ‘*’ will match all uuids (filtered by ‘running’, ‘queued’, and ‘cached’).
running (bool) – If set to True, the request will be aborted if ‘id’ is a currently running job. Defaults to True if ‘id’ is a specific uuid and both ‘queued’ and ‘cached’ are unspecified, otherwise False.
queued (bool) – If set to True, the request will be aborted if ‘id’ is a currently queued job. Defaults to True if ‘id’ is a specific uuid and both ‘running’ and ‘cached’ are unspecified, otherwise False.
cached (bool) – If set to True, the request will be aborted if ‘id’ is a cached data entry. Defaults to True if ‘id’ is a specific uuid and both ‘running’ and ‘queued’ are unspecified, otherwise False.
- get_LP_solve(
- cuopt_data_models,
- solver_config=<solver_settings.solver_settings.SolverSettings object>,
- cache=False,
- response_type='obj',
- filepath=False,
- output='',
Get linear programming solution for a given problem.
- Parameters:
cuopt_data_models –
Note - Batch mode is only supported in LP and not in MILP
File path to mps or json/dict/DataModel returned by cuopt_mps_parser/list[mps file paths]/list[dict]/list[DataModel].
For single problem, input should be either a path to mps/json file, /DataModel returned by cuopt_mps_parser/ path to json file/ dictionary.
For batch problem, input should be either a list of paths to mps files/ a list of DataModel returned by cuopt_mps_parser/ a list of dictionaries.
To use a cached cuopt problem data, input should be a uuid identifying the reqId of the cached data.
solver_config (SolverSettings object or Dict) – Contains solver settings including tolerance values. See the LP documentation for details on solver settings.
response_type (str) – Choose “dict” if response should be returned as a dictionary or “obj” for Solution object. Defaults to “obj”
filepath (boolean) – Indicates that cuopt_problem_json_data is the relative path of a cuopt data file under the server’s data directory. The data directory is specified when the server is started (see the server documentation for more detail). Defaults to False.
output (str) – Optional name of the result file. If the server has been configured to write results to files and the size of the result is greater than the configured limit, the server will write the result to a file with this name under the server’s result directory (see the server documentation for more detail). Defaults to a name based on the path if ‘filepath’ is True, or a uuid if ‘filepath’ is False.
Returns (dict or Solution object.)
- get_optimized_routes(
- cuopt_problem_json_data,
- filepath=False,
- cache=False,
- output='',
Get optimized routing solution for a given problem.
- Parameters:
cuopt_problem_json_data (dict or str) – This is either the problem data as a dictionary or the path of a file containing the problem data as JSON or the reqId of a cached cuopt problem data. Please refer to the server doc for the structure of this dictionary.
filepath (boolean) – Indicates that cuopt_problem_json_data is the relative path of a cuopt data file under the server’s data directory. The data directory is specified when the server is started (see the server documentation for more detail). Defaults to False.
output (str) – Optional name of the result file. If the server has been configured to write results to files and the size of the result is greater than the configured limit, the server will write the result to a file with this name under the server’s result directory (see the server documentation for more detail). Defaults to a name based on the path if ‘filepath’ is True, or a uuid if ‘filepath’ is False.
- repoll(data, response_type='obj')#
Poll for a result when a previous command resulted in a timeout. The request id is returned as JSON in the result of the original call.
- Parameters:
data (str) – A uuid identifying the original request. For backward compatibility, data may also be a dictionary containing the key ‘reqId’ where the value is the uuid.
response_type (str) – For LP problem choose “dict” if response should be returned as a dictionary or “obj” for Solution object. Defaults to “obj”. For VRP problem, response_type is ignored and always returns a dict.
LP Supporting Classes#
- class data_model.DataModel(*args: Any, **kwargs: Any)#
Initialize a DataModel which represents a Linear Program.
Standard form representation follows the description from the wiki article here: https://en.wikipedia.org/wiki/Linear_programming#Standard_form. In other words, this structure stores all information used to represent the following LP equation: Minimize :
dot(c, x)
Subject to :
matmul(A, x) (= or >= or)<= b
Where :
x : Decision Variables
c : Objective Coefficients
A : Constraint Matrix
b : Constraint Bounds
With :
n = number of variables
m = number of constraints
x = n-dim vector
c = n-dim vector
A = mxn-dim sparse matrix
b = m-dim vector
Notes
By default this assumes objective minimization. For now, we don’t support maximization, please open an issue if it is needed.
Objective value can be scaled and offseted accordingly: objective_scaling_factor * (dot(c, x) + objective_offset) please refer to to the set_objective_scaling_factor() and set_objective_offset() method.
Examples
Minimize:
cost = 0.2 * VAR1 + 0.1 * VAR2
Subject to
3 * VAR1 + 4 * VAR2 <= 5.4
2.7 * VAR1 + 10.1 * VAR2 <= 4.9
0 <= VAR1 <= 2
0 <= VAR2 <= inf
>>> from cuopt import linear_programming >>> >>> import numpy as np >>> >>> data_model = linear_programming.DataModel() >>> >>> # Set the CSR matrix representation, for more information about CSR >>> # checkout: >>> # https://docs.nvidia.com/cuda/cusparse/index.html#compressed-sparse-row-csr # noqa >>> >>> # Define the different np.array for the CSR representation >>> # The 4 values of the constraint matrix (A) >>> A_values = np.array([3.0, 4.0, 2.7, 10.1], dtype=np.float64) >>> >>> # The CSR index vector >>> # Here we associate each value in the A_values to its variable index >>> # First value correspond to the first variable >>> # (3.0 -> variable[*0*], constraint[0]) >>> # Second value correspond to the second variable >>> # (4.0 -> variable[*1*], constraint[0]) >>> # Third value correspond to the first variable >>> # (2.7 -> variable[*0*], constraint[1]) >>> # Fourth value correspond to the second variable >>> # (10.1 -> variable[*1*], constraint[1]) >>> A_indices = np.array([0, 1, 0, 1], dtype=np.int32) >>> >>> # The CSR offset vector >>> # Here we specify the range of values for each constraint >>> # [0, 2) corresponds to the range of values for the first constraints, >>> # here [0:3.0, 1:4.0] >>> # [2, 4) corresponds to the range of values for the second constraint, >>> # here [1:2.7, 2:10.1] >>> A_offsets = np.array([0, 2, 4], dtype=np.int32) >>> >>> data_model.set_csr_constraint_matrix(A_values, A_indices, A_offsets) >>> >>> # Set the constraint bounds (b / right-hand side) array >>> b = np.array([5.4, 4.9], dtype=np.float64) >>> data_model.set_constraint_bounds(b) >>> >>> # Set the objective coefficient (c) array. >>> c = np.array([0.2, 0.1], dtype=np.float64) >>> data_model.set_objective_coefficients(c) >>> >>> # Set the constraints/rows equalities, either using the row_type format >>> # or by directly setting the bounds >>> >>> # Method 0: constraints/rows type >>> # Set both constraints/rows to less-than (<=) >>> row_types = np.array(['L', 'L']) >>> data_model.set_row_types(row_types) >>> >>> # Method 1: directly set bounds >>> # Set lower bounds to -infinity and upper bounds to b >>> constraint_lower_bounds = np.array([np.NINF, np.NINF], >>> dtype=np.float64) >>> constraint_upper_bounds = np.array(b, dtype=np.float64) >>> data_model.set_constraint_lower_bounds(constraint_lower_bounds) >>> data_model.set_constraint_upper_bounds(constraint_upper_bounds) >>> >>> >>> # Set variable lower and upper bounds >>> variable_lower_bounds = np.array([0.0, 0.0], dtype=np.float64) >>> variable_upper_bounds = np.array([2.0, np.PINF], dtype=np.float64) >>> data_model.set_variable_lower_bounds(variable_lower_bounds) >>> data_model.set_variable_upper_bounds(variable_upper_bounds)
- get_ascii_row_types()#
Get the type of each row (constraint) converted to a numpy.array with int8 type (ascii value).
- get_constraint_bounds()#
Get the constraint bounds (b / right-hand side) as numpy.array with float64 type.
- get_constraint_lower_bounds()#
Get the constraints lower bounds as numpy.array with float64 type.
- get_constraint_matrix_indices()#
Get the indices of the CSR representation of the constraint matrix as numpy.array with int type.
- get_constraint_matrix_offsets()#
Get the indices of the CSR representation of the constraint matrix as numpy.array with int type.
- get_constraint_matrix_values()#
Get the values of the CSR representation of the constraint matrix as numpy.array with float64 type.
- get_constraint_upper_bounds()#
Get the constraints upper bounds as numpy.array with float64 type.
- get_initial_dual_solution()#
Get the initial dual solution as numpy.array with float64 type.
- get_initial_primal_solution()#
Get the initial primal solution as numpy.array with float64 type.
- get_objective_coefficients()#
Get the objective_coefficients (c) as numpy.array with float64 type.
- get_objective_offset()#
Get the offset of the objective function as a float64.
- get_objective_scaling_factor()#
Get the scaling factor of the objective function as a float64.
- get_row_names()#
Get the row names as numpy.array with string type.
- get_row_types()#
Get the type of each row (constraint) as numpy.array with char8 type.
- get_sense()#
Get the sense of optimization as a bool. True means maximize the objective function, false means minimize.
- get_variable_lower_bounds()#
Get the variables (x) lower bounds as numpy.array with float64 type.
- get_variable_names()#
Get the variable names as numpy.array with string type.
- get_variable_types()#
Get the variable types as numpy.array with char type.
- get_variable_upper_bounds()#
Get the variables (x) upper bounds as numpy.array with float64 type.
- set_constraint_bounds(b)#
Set the constraint bounds (b / right-hand side) array.
- Parameters:
b (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is mandatory.
- set_constraint_lower_bounds(constraint_lower_bounds)#
Set the constraints lower bounds.
- Parameters:
constraint_lower_bounds (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is optional if you set the row type, else it’s mandatory along with the upper bounds.
- set_constraint_upper_bounds(constraint_upper_bounds)#
Set the constraints upper bounds.
- Parameters:
constraint_upper_bounds (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is optional if you set the row type, else it’s mandatory along with the lower bounds.
- set_csr_constraint_matrix(A_values, A_indices, A_offsets)#
Set the constraint matrix (A) in CSR format. For more information about CSR checkout: https://docs.nvidia.com/cuda/cusparse/index.html#compressed-sparse-row-csr # noqa
- Parameters:
A_values (np.array dtype - float64) – Values of the CSR representation of the constraint matrix as a device floating point array.
A_indices (np.array dtype - int32) – Indices of the CSR representation of the constraint matrix as a device integer array.
A_offsets (np.array dtype - int32) – Offsets of the CSR representation of the constraint matrix as a device integer array.
Notes
Setting before calling the solver is mandatory.
- set_initial_dual_solution(initial_dual_solution)#
Set the initial dual solution.
- Parameters:
initial_dual_solution (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is optional.
- set_initial_primal_solution(initial_primal_solution)#
Set the initial primal solution.
- Parameters:
initial_primal_solution (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is optional.
- set_maximize(maximize)#
Set the sense of optimization to maximize.
- Parameters:
maximize (bool) – True means to maximize the objective function, else minimize.
Notes
Setting before calling the solver is optional, default value if false (minimize).
- set_objective_coefficients(c)#
Set the objective coefficients (c) array.
- Parameters:
c (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is mandatory.
- set_objective_offset(objective_offset)#
Set the offset of the objective function (objective_offset + objective_value).
- Parameters:
objective_offset (float64) – The constant objective_offset to add.
Notes
Setting before calling the solver is optional.
- set_objective_scaling_factor(objective_scaling_factor)#
Set the scaling factor of the objective function (scaling_factor * objective_value).
- Parameters:
objective_scaling_factor (float64) – The scaling factor to apply.
Notes
Setting before calling the solver is optional.
- set_row_names(row_names)#
Set the row names.
- Parameters:
row_names (np.array dtype - unicode string) – Host string array.
Notes
Setting before calling the solver is optional. Value is only used for file generation of the solution.
- set_row_types(row_types)#
Set the type of each row (constraint). Possible values are: ‘E’ for equality ( = ): lower & upper constrains bound equal to b ‘L’ for less-than ( <= ): lower constrains bound equal to -infinity, upper constrains bound equal to b ‘G’ for greater-than ( >= ): lower constrains bound equal to b, upper constrains bound equal to +infinity
- Parameters:
row_types (np.array dtype - unicode string (<U1)) – Host character array.
Notes
Setting before calling the solver is optional if you set the constraint lower and upper bounds, else it’s mandatory. If both are set, priority goes to set_constraint_lower/upper_bounds.
Examples
>>> row_types = np.array(['L', 'L']) >>> data_model.set_row_types(row_types)
- set_variable_lower_bounds(variable_lower_bounds)#
Set the variables (x) lower bounds.
- Parameters:
variable_lower_bounds (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is optional, default value for all is 0.
- set_variable_names(variables_names)#
Set the variables names.
- Parameters:
variables_names (np.array dtype - unicode string) – Host string array.
Notes
Setting before calling the solver is optional. Value is only used for file generation of the solution.
- set_variable_types(variable_types)#
Set the variable types.
- Parameters:
variables_types (np.array dtype - unicode string (<U1)) – Host character array.
- set_variable_upper_bounds(variable_upper_bounds)#
Set the variables (x) upper bounds.
- Parameters:
variable_upper_bounds (np.array dtype - float64) – Device floating point array.
Notes
Setting before calling the solver is optional, default value for all is +infinity.
- class solver_settings.SolverSettings#
- get_absolute_dual_tolerance()#
Get the absolute dual tolerance. For more details on tolerance to optimality, see set_optimality_tolerance method.
- Returns:
The absolute dual tolerance.
- Return type:
float64
- get_absolute_gap_tolerance()#
Get the absolute gap tolerance. For more details on tolerance to gap, see set_optimality_tolerance method.
- Returns:
The absolute gap tolerance.
- Return type:
float64
- get_absolute_primal_tolerance()#
Get the absolute primal tolerance. For more details on tolerance to optimality, see set_optimality_tolerance method.
- Returns:
The absolute primal tolerance.
- Return type:
float64
- get_dual_infeasible_tolerance()#
Get the dual infeasible tolerance.
- Returns:
The dual infeasible tolerance.
- Return type:
float64
- get_infeasibility_detection()#
Get the status of detecting infeasibility.
- Returns:
Status of detecting infeasibility.
- Return type:
bool
- get_iteration_limit()#
Get the iteration limit or None if none was set.
- Returns:
The iteration limit.
- Return type:
int or None
- get_primal_infeasible_tolerance()#
Get the primal infeasible tolerance.
- Returns:
The primal infeasible tolerance.
- Return type:
float64
- get_relative_dual_tolerance()#
Get the relative dual tolerance. For more details on tolerance to optimality, see set_optimality_tolerance method.
- Returns:
The relative dual tolerance.
- Return type:
float64
- get_relative_gap_tolerance()#
Get the relative gap tolerance. For more details on tolerance to gap, see set_optimality_tolerance method.
- Returns:
The relative gap tolerance.
- Return type:
float64
- get_relative_primal_tolerance()#
Get the relative primal tolerance. For more details on tolerance to optimality, see set_optimality_tolerance method.
- Returns:
The relative primal tolerance.
- Return type:
float64
- get_solver_mode()#
Get the solver mode. For more details on solver mode, see set_solver_mode method.
- Returns:
The solver mode.
- Return type:
Int
- get_time_limit()#
Get the time limit in seconds or None if none was set.
- Returns:
The time limit.
- Return type:
float or None
- set_absolute_dual_tolerance(absolute_dual_tolerance)#
Set the absolute dual tolerance.
- Parameters:
absolute_dual_tolerance (float64) – Absolute dual tolerance
Notes
For more details on tolerance to optimality, see set_optimality_tolerance method. Default value is 1e-4.
- set_absolute_gap_tolerance(absolute_gap_tolerance)#
Set the absolute gap tolerance.
- Parameters:
absolute_gap_tolerance (float64) – Absolute gap tolerance
Notes
For more details on tolerance to gap, see set_optimality_tolerance method. Default value is 1e-4.
- set_absolute_primal_tolerance(
- absolute_primal_tolerance,
Set the absolute primal tolerance.
- Parameters:
absolute_primal_tolerance (float64) – Absolute primal tolerance
Notes
For more details on tolerance to optimality, see set_optimality_tolerance method. Default value is 1e-4.
- set_dual_infeasible_tolerance(
- dual_infeasible_tolerance,
Set the dual infeasible tolerance.
- Parameters:
dual_infeasible_tolerance (float64) – Dual infeasible tolerance.
Notes
Default value is 1e-8. Higher values will detect infeasibility quicker but may trigger false positive.
- set_infeasibility_detection(detect)#
Solver will detect and leave if the problem is detected as infeasible.
- Parameters:
detect (bool) – True to detect infeasibility, false to ignore it.
Notes
By default, the solver detects infeasibility. Some problems detected as infeasible may converge under a different tolerance factor.
- set_iteration_limit(iteration_limit)#
Set the iteration limit after which the solver will stop and return the current solution.
- Parameters:
iteration_limit (int) – Iteration limit to set.
Notes
By default there is no iteration limit. For performance reasons, cuOpt’s does not constantly checks for iteration limit, thus, the solver might run a few extra iterations over the limit. If set along time limit, the first limit reached will exit.
- set_optimality_tolerance(eps_optimal)#
Set both absolute and relative tolerance on the primal feasibility, dual feasibility, and gap. Changing this value has a significant impact on accuracy and runtime.
Optimality is computed as follows:
- dual_feasibility < absolute_dual_tolerance + relative_dual_tolerance
norm_objective_coefficient (l2_norm(c))
- primal_feasibility < absolute_primal_tolerance
relative_primal_tolerance * norm_constraint_bounds (l2_norm(b))
- duality_gap < absolute_gap_tolerance + relative_gap_tolerance
(abs(primal_objective) + abs(dual_objective))
If all three conditions hold, optimality is reached.
- Parameters:
eps_optimal (float64) – Tolerance to optimality
Notes
Default value is 1e-4. To set each absolute and relative tolerance, use the provided setters.
- set_primal_infeasible_tolerance(
- primal_infeasible_tolerance,
Set the primal infeasible tolerance.
- Parameters:
primal_infeasible_tolerance (float64) – Primal infeasible tolerance.
Notes
Default value is 1e-8. Higher values will detect infeasibility quicker but may trigger false positive.
- set_relative_dual_tolerance(relative_dual_tolerance)#
Set the relative dual tolerance.
- Parameters:
relative_dual_tolerance (float64) – Relative dual tolerance
Notes
For more details on tolerance to optimality, see set_optimality_tolerance method. Default value is 1e-4.
- set_relative_gap_tolerance(relative_gap_tolerance)#
Set the relative gap tolerance.
- Parameters:
relative_gap_tolerance (float64) – Relative gap tolerance
Notes
For more details on tolerance to gap, see set_optimality_tolerance method. Default value is 1e-4.
- set_relative_primal_tolerance(
- relative_primal_tolerance,
Set the relative primal tolerance.
- Parameters:
relative_primal_tolerance (float64) – Relative primal tolerance
Notes
For more details on tolerance to optimality, see set_optimality_tolerance method. Default value is 1e-4.
- set_solver_mode(solver_mode)#
Set the mode under which the solver should operate. The mode will change the way the solver internally optimizes the problem. The mode choice can drastically impact how fast a specific problem will be solved. Users are encouraged to test different modes to see which one fits the best their problem. By default, the solver uses SolverMode.Stable1, the best overall mode from our experiments. For now, only three modes are available : [Stable1, Methodical1, Fast1]
- Parameters:
solver_mode (SolverMode) – Solver mode to set. Only possible values are: - SolverMode.Stable1 - SolverMode.Methodical1 - SolverMode.Fast1
Notes
For now, we don’t offer any mechanism to know upfront which solver mode will be the best for one specific problem. Mode description: Stable1: Best compromise between success at converging and speed (corresponds to the former solver_mode 0) Methodical1: Usually leads to slower individual steps but less are needed to converge (corresponds to the former solver_mode 1). Fast1: Less convergence success but usually yields the highest speed (new mode, replacing former solver_mode 2).
- set_time_limit(time_limit)#
Set the time limit in seconds after which the solver will stop and return the current solution. If set along iteration limit, the first limit reached will exit.
- Parameters:
time_limit (float64) – Time limit to set in seconds.
Notes
By default there is no time limit. For performance reasons, cuOpt’s does not constantly checks for time limit, thus, the solver might run a few milliseconds over the limit.
- class solution.Solution(
- primal_solution,
- dual_solution,
- reduced_cost,
- termination_reason,
- primal_residual,
- dual_residual,
- primal_objective,
- dual_objective,
- gap,
- solve_time,
- vars,
A container of LP solver output
- Parameters:
primal_solution (numpy.array) – Primal solution of the LP problem
dual_solution (numpy.array) – Dual solution of the LP problem
reduced_cost (numpy.array) – The reduced cost. It contains the dual multipliers for the linear constraints.
termination_reason (Integer) – Termination reason value.
primal_residual (Float64) – L2 norm of the primal residual: measurement of the primal infeasibility
dual_residual (Float64) – L2 norm of the dual residual: measurement of the dual infeasibility
primal_objective (Float64) – Value of the primal objective
dual_objective (Float64) – Value of the dual objective
gap (Float64) – Difference between the primal and dual objective
solve_time (Float64) – Solve time in milliseconds
vars (Dict[str, float64]) – Dictionnary mapping each variable (name) to its value.
- get_dual_objective()#
Returns the dual objective as a float64.
- get_dual_solution()#
Returns the dual solution as numpy.array with float64 type.
- get_lp_stats()#
Returns the convergence statistics as a dictionary:
- “primal_residual”: float64
Measurement of the primal infeasibility. This quantity is being reduced until primal tolerance is met (see SolverSettings primal_tolerance).
- “dual_residual”: float64,
Measurement of the dual infeasibility. This quantity is being reduced until dual tolerance is met (see SolverSettings dual_tolerance).
- “gap”: float64
Difference between the primal and dual objective. This quantity is being reduced until gap tolerance is met (see SolverSettings gap_tolerance).
- “reduced_cost”: np.array float64
Reduced cost containing the dual multipliers for the linear constraints.
- get_primal_objective()#
Returns the primal objective as a float64.
- get_primal_solution()#
Returns the primal solution as numpy.array with float64 type.
- get_solve_time()#
Returns the engine solve time in milliseconds as a float64.
- get_termination_reason()#
Returns the termination reason as per TerminationReason.
- get_vars()#
Returns the dictionnary mapping each variable (name) to its value.
Service CLI#
1usage: cuopt_sh [-h] [-ca] [-f] [-d] [-r] [-q] [-t TYPE] [-ss SOLVER_SETTINGS]
2 [-o OUTPUT] [-pt POLL_TIMEOUT] [-i IP] [-p PORT] [-s]
3 [-c SELF_SIGNED_CERT] [-l {critical,error,warning,info,debug}]
4 [-ov] [-v]
5 [data ...]
6
7Solve a cuOpt problem using a self-hosted service client.
8
9positional arguments:
10 data Filename, or JSON string containing a request id. Data
11 may be a cuopt problem or a request id as displayed in
12 the output from a previous request which timed out. A
13 cuopt problem must be in a file, but a request id may
14 be passed in a file or as a JSON string. For VRP:A
15 single problem file is expected or file_name. For LP:
16 A single problem file in mps/json format or
17 file_name.Batch mode is supported in case of mps files
18 only for LP andnot for MILP, where a list of mpsfiles
19 can be shared to be solved in parallel.
20
21options:
22 -h, --help show this help message and exit
23 -ca, --cache Indicates that the DATA needs to be cached. This does
24 not solve the problem but stores the problem data and
25 returns the reqId. The reqId can be used later to
26 solve the problem. This flag also may be used
27 alongside the delete argument to delete a cached
28 entry.(see the server documentation for more detail).
29 -f, --filepath Indicates that the DATA argument is the relative path
30 of a cuopt data file under the server's data
31 directory. The data directory is specified when the
32 server is started (see the server documentation for
33 more detail).
34 -d, --delete Deletes cached data or aborts jobs on the cuOpt
35 server. The DATA argument may be the specific reqId of
36 cached data or a job, or it may be the wildcard '*'
37 which will match any request. If a specific reqId is
38 given and the -r, -q, and -ca flags are all
39 unspecified, the reqId will always be deleted if it
40 exists. If any of the -r, -q, or -ca flags are
41 specified, a specific reqId will only be deleted if it
42 matches the specified flags. If the wildard reqId '*'
43 is given, the -r, -q and/or -ca flags must always be
44 set explicitly. To flush the job queue, give '*' as
45 the reqId and specify the -q flag. To delete all
46 currently running jobs, give '*' as the reqId and
47 specify the -r flag. To clear the job data cache, give
48 '*' as the reqId and specify the -ca flag.
49 -r, --running Aborts a job only if it is running. Should be used
50 alongside delete argument
51 -q, --queued Aborts a job only if it is queued. Should be used
52 alongside delete argument
53 -t TYPE, --type TYPE The type of problem to solve. Supported options are
54 VRP and LP (defaults to VRP)
55 -ss SOLVER_SETTINGS, --solver-settings SOLVER_SETTINGS
56 Filename or JSON string containing solver settings for
57 LP problem type
58 -o OUTPUT, --output OUTPUT
59 Optional name of the result file. If the server has
60 been configured to write results to files and the size
61 of the result is greater than the configured limit,
62 the server will write the result to a file with this
63 name under the server's result directory (see the
64 server documentation for more detail). A default name
65 will be used if this is not specified.
66 -pt POLL_TIMEOUT, --poll-timeout POLL_TIMEOUT
67 Number of seconds to poll for a result before timing
68 out and returning a request id to re-query (defaults
69 to 120)
70 -i IP, --ip IP Host address for the cuOpt server (default 0.0.0.0)
71 -p PORT, --port PORT Port for the cuOpt server (default 5000)
72 -s, --ssl Not currently implemented. Use https scheme (default
73 is http)
74 -c SELF_SIGNED_CERT, --self-signed-cert SELF_SIGNED_CERT
75 Path to self signed certificates only, skip for
76 standard certificates
77 -l {critical,error,warning,info,debug}, --log-level {critical,error,warning,info,debug}
78 Log level
79 -ov, --only-validation
80 If set, only validates input
81 -v, --version Print client version and exit.