Localsolver  5.5
localsolver Namespace Reference

Namespace of LocalSolver. More...

Classes

struct  with_iterator
struct  without_iterator
class  LocalSolver
 LocalSolver environment. More...
class  LSCollection
 Value type for collection expressions (lists). More...
class  LSException
 LocalSolver exception. More...
class  LSExpression
 Mathematical modeling expression. More...
class  LSModel
 Mathematical optimization model. More...
class  LSParam
 Solving parameters. More...
class  LSPhase
 Optimization phase. More...
class  LSSolution
 Solution to the optimization model. More...
class  LSStatistics
 Statistics of the search. More...
class  LSVersion
 Version and copyright info. More...

Typedefs

typedef BSolver lssolver
typedef LSSolutionStatus lssolutionstatus
typedef LSState lsstate
typedef LSOperator lsoperator
typedef LSObjectiveDirection lsobjdirection
typedef LSCallbackType lscallbacktype
typedef LSCallback lscallback
typedef LSErrorCode lserrorcode
typedef void(* lsexceptioncallback )(lserrorcode code, const char *message, const char *filename, const char *funcname, int lineno, void *userdata)
typedef void(* LSCallback )(LSCallbackType type, void *userdata)
 Implementing a LSCallback function allows having user-defined functions called regularly during the search.
typedef long long lsint
 Integer type used in LocalSolver model.
typedef double lsdouble
 Float type used in LocalSolver model.

Enumerations

enum  LSCallbackType {
  CT_PhaseStarted,
  CT_PhaseEnded,
  CT_Ticked
}
 List of types that can be used with callbacks. More...
enum  LSErrorCode {
  EC_Api,
  EC_File,
  EC_Model,
  EC_Callback,
  EC_License,
  EC_Solver,
  EC_Internal,
  EC_Modeler
}
 List of error codes used by LSException. More...
enum  LSObjectiveDirection {
  OD_Minimize,
  OD_Maximize
}
 Objective directions. More...
enum  LSOperator {
  O_Bool,
  O_Float,
  O_Const,
  O_Sum,
  O_Sub,
  O_Prod,
  O_Max,
  O_Min,
  O_Eq,
  O_Neq,
  O_Geq,
  O_Leq,
  O_Gt,
  O_Lt,
  O_If,
  O_Not,
  O_And,
  O_Or,
  O_Xor,
  O_Abs,
  O_Dist,
  O_Div,
  O_Mod,
  O_Array,
  O_At,
  O_Scalar,
  O_Ceil,
  O_Floor,
  O_Round,
  O_Sqrt,
  O_Log,
  O_Exp,
  O_Pow,
  O_Cos,
  O_Sin,
  O_Tan,
  O_Int,
  O_Piecewise,
  O_List,
  O_Count,
  O_IndexOf,
  O_Partition,
  O_Disjoint
}
 Mathematical operators available for modeling. More...
enum  LSSolutionStatus {
  SS_Inconsistent,
  SS_Infeasible,
  SS_Feasible,
  SS_Optimal
}
 Solution status: Optimal, Feasible, Infeasible or Inconsistent. More...
enum  LSState {
  S_Modeling,
  S_Running,
  S_Paused,
  S_Stopped
}
 State of LocalSolver environment. More...

Functions

template<typename T >
with_iterator is_iterator (typename T::iterator_category *)
template<typename T >
without_iterator is_iterator (...)
LIB_PUBLIC lssolverls_create_solver_fail_safe (lsexceptioncallback cb, void *userdata)
LIB_PUBLIC lssolverls_create_solver ()
LIB_PUBLIC void ls_delete_solver (lssolver *solver)
LIB_PUBLIC lsstate ls_get_state (lssolver *solver)
LIB_PUBLIC void ls_solve (lssolver *solver)
LIB_PUBLIC void ls_stop (lssolver *solver)
LIB_PUBLIC int ls_add_phase (lssolver *solver)
LIB_PUBLIC int ls_nb_phases (lssolver *solver)
LIB_PUBLIC int ls_solver_to_string (lssolver *solver, char *buffer, int bufferSize)
LIB_PUBLIC int ls_param_to_string (lssolver *solver, char *buffer, int bufferSize)
LIB_PUBLIC int ls_solver_info (lssolver *solver, char *buffer, int bufferSize)
LIB_PUBLIC bool ls_check_paused_or_stopped (lssolver *solver)
LIB_PUBLIC bool ls_check_not_running (lssolver *solver)
LIB_PUBLIC void ls_save_environment (lssolver *solver, const char *filename)
LIB_PUBLIC void ls_load_environment (lssolver *solver, const char *filename)
LIB_PUBLIC void ls_add_callback (lssolver *solver, lscallbacktype type, lscallback callback, void *userdata)
LIB_PUBLIC bool ls_remove_callback (lssolver *solver, lscallbacktype type, lscallback callback)
LIB_PUBLIC bool ls_remove_callback_2 (lssolver *solver, lscallbacktype type, lscallback callback, void *userdata)
LIB_PUBLIC void ls_set_seed (lssolver *solver, int seed)
LIB_PUBLIC int ls_get_seed (lssolver *solver)
LIB_PUBLIC void ls_set_nb_threads (lssolver *solver, int nbThreads)
LIB_PUBLIC int ls_get_nb_threads (lssolver *solver)
LIB_PUBLIC void ls_set_annealing_level (lssolver *solver, int annealingLevel)
LIB_PUBLIC int ls_get_annealing_level (lssolver *solver)
LIB_PUBLIC void ls_set_verbosity (lssolver *solver, int verbosity)
LIB_PUBLIC int ls_get_verbosity (lssolver *solver)
LIB_PUBLIC void ls_set_time_between_displays (lssolver *solver, int timeBetweenDisplays)
LIB_PUBLIC int ls_get_time_between_displays (lssolver *solver)
LIB_PUBLIC void ls_set_log_file (lssolver *solver, const char *path)
LIB_PUBLIC int ls_get_log_file (lssolver *solver, char *buffer, int bufferSize)
LIB_PUBLIC bool ls_advanced_param_is_set (lssolver *solver, const char *param)
LIB_PUBLIC int ls_get_advanced_param (lssolver *solver, const char *param, int defaultValue)
LIB_PUBLIC void ls_set_advanced_param (lssolver *solver, const char *param, int value)
LIB_PUBLIC int ls_get_advanced_str_param (lssolver *solver, const char *param, const char *defaultValue, char *buffer, int bufferSize)
LIB_PUBLIC void ls_set_advanced_str_param (lssolver *solver, const char *param, const char *value)
LIB_PUBLIC void ls_set_int_objective_bound (lssolver *solver, int objPos, lsint bound)
LIB_PUBLIC void ls_set_double_objective_bound (lssolver *solver, int objPos, lsdouble bound)
LIB_PUBLIC lsint ls_get_int_objective_bound (lssolver *solver, int objPos)
LIB_PUBLIC lsdouble ls_get_double_objective_bound (lssolver *solver, int objPos)
LIB_PUBLIC int ls_create_int_constant (lssolver *solver, lsint value)
LIB_PUBLIC int ls_create_double_constant (lssolver *solver, lsdouble value)
LIB_PUBLIC int ls_create_expression (lssolver *solver, lsoperator op)
LIB_PUBLIC int ls_nb_expressions (lssolver *solver)
LIB_PUBLIC int ls_nb_decisions (lssolver *solver)
LIB_PUBLIC int ls_get_decision (lssolver *solver, int decisionPos)
LIB_PUBLIC int ls_get_expression_with_name (lssolver *solver, const char *name)
LIB_PUBLIC void ls_add_constraint (lssolver *solver, int exprId)
LIB_PUBLIC void ls_remove_constraint (lssolver *solver, int constraintPos)
LIB_PUBLIC void ls_remove_constraint_with_expr (lssolver *solver, int exprId)
LIB_PUBLIC int ls_nb_constraints (lssolver *solver)
LIB_PUBLIC int ls_get_constraint (lssolver *solver, int constraintPos)
LIB_PUBLIC void ls_add_objective (lssolver *solver, int exprId, lsobjdirection direction)
LIB_PUBLIC void ls_remove_objective (lssolver *solver, int objectivePos)
LIB_PUBLIC int ls_nb_objectives (lssolver *solver)
LIB_PUBLIC int ls_get_objective (lssolver *solver, int objectiveIndex)
LIB_PUBLIC lsobjdirection ls_get_objective_direction (lssolver *solver, int objectivePos)
LIB_PUBLIC int ls_nb_operands (lssolver *solver)
LIB_PUBLIC void ls_close (lssolver *solver)
LIB_PUBLIC void ls_open (lssolver *solver)
LIB_PUBLIC bool ls_is_closed (lssolver *solver)
LIB_PUBLIC int ls_model_to_string (lssolver *solver, char *buffer, int bufferSize)
LIB_PUBLIC bool ls_expr_check_index (lssolver *solver, int exprIndex)
LIB_PUBLIC lsint ls_expr_get_int_value (lssolver *solver, int exprId)
LIB_PUBLIC lsdouble ls_expr_get_double_value (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_violated (lssolver *solver, int exprId)
LIB_PUBLIC void ls_expr_set_int_value (lssolver *solver, int exprId, lsint value)
LIB_PUBLIC void ls_expr_set_double_value (lssolver *solver, int exprId, lsdouble value)
LIB_PUBLIC bool ls_expr_is_named (lssolver *solver, int exprId)
LIB_PUBLIC int ls_expr_get_name (lssolver *solver, int exprId, char *buffer, int bufferSize)
LIB_PUBLIC void ls_expr_set_name (lssolver *solver, int exprId, const char *name)
LIB_PUBLIC int ls_expr_info (lssolver *solver, int exprId, char *buffer, int bufferSize)
LIB_PUBLIC int ls_expr_to_string (lssolver *solver, int exprId, char *buffer, int bufferSize)
LIB_PUBLIC int ls_expr_nb_operands (lssolver *solver, int exprId)
LIB_PUBLIC void ls_expr_set_operand (lssolver *solver, int exprId, int operandPos, int operandId)
LIB_PUBLIC void ls_expr_add_operand (lssolver *solver, int exprId, int operandId)
LIB_PUBLIC int ls_expr_get_operand (lssolver *solver, int exprId, int operandPos)
LIB_PUBLIC bool ls_expr_is_array (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_collection (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_bool (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_int (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_double (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_objective (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_decision (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_constraint (lssolver *solver, int exprId)
LIB_PUBLIC bool ls_expr_is_constant (lssolver *solver, int exprId)
LIB_PUBLIC lsoperator ls_expr_get_operator (lssolver *solver, int exprId)
LIB_PUBLIC lssolutionstatus ls_get_solution_status (lssolver *solver)
LIB_PUBLIC void ls_clear_solution (lssolver *solver)
LIB_PUBLIC void ls_collection_clear (lssolver *solver, int exprId)
LIB_PUBLIC void ls_collection_add (lssolver *solver, int exprId, lsint val)
LIB_PUBLIC lsint ls_collection_count (lssolver *solver, int exprId)
LIB_PUBLIC lsint ls_collection_get (lssolver *solver, int exprId, int pos)
LIB_PUBLIC int ls_collection_to_string (lssolver *solver, int exprId, char *buffer, int bufferSize)
LIB_PUBLIC bool ls_phase_check_index (lssolver *solver, int phaseIndex)
LIB_PUBLIC void ls_phase_set_optimized_objective (lssolver *solver, int phaseIndex, int optimizedObjective)
LIB_PUBLIC int ls_phase_get_optimized_objective (lssolver *solver, int phaseIndex)
LIB_PUBLIC void ls_phase_set_iteration_limit (lssolver *solver, int phaseIndex, long long iterationLimit)
LIB_PUBLIC long long ls_phase_get_iteration_limit (lssolver *solver, int phaseIndex)
LIB_PUBLIC void ls_phase_set_time_limit (lssolver *solver, int phaseIndex, int timeLimit)
LIB_PUBLIC int ls_phase_get_time_limit (lssolver *solver, int phaseIndex)
LIB_PUBLIC void ls_phase_set_enabled (lssolver *solver, int phaseIndex, bool enabled)
LIB_PUBLIC bool ls_phase_is_enabled (lssolver *solver, int phaseIndex)
LIB_PUBLIC int ls_phase_to_string (lssolver *solver, int phaseIndex, char *buffer, int bufferSize)
LIB_PUBLIC int ls_stats_get_running_time (lssolver *solver, int phaseIndex)
LIB_PUBLIC long long ls_stats_get_nb_iterations (lssolver *solver, int phaseIndex)
LIB_PUBLIC long long ls_stats_get_nb_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC long long ls_stats_get_nb_accepted_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC long long ls_stats_get_nb_improving_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC long long ls_stats_get_nb_rejected_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC long long ls_stats_get_nb_infeasible_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC double ls_stats_get_percent_accepted_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC double ls_stats_get_percent_improving_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC double ls_stats_get_percent_rejected_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC double ls_stats_get_percent_infeasible_moves (lssolver *solver, int phaseIndex)
LIB_PUBLIC int ls_stats_to_string (lssolver *solver, int phaseIndex, char *buffer, int bufferSize)
LIB_PUBLIC int ls_stats_info (lssolver *solver, int phaseIndex, char *buffer, int bufferSize)
LIB_PUBLIC void ls_add_exception_callback (lssolver *solver, lsexceptioncallback callback, void *userdata)
LIB_PUBLIC bool ls_remove_exception_callback (lssolver *solver, lsexceptioncallback callback)
LIB_PUBLIC bool ls_remove_exception_callback_2 (lssolver *solver, lsexceptioncallback callback, void *userdata)
LIB_PUBLIC int ls_major_version ()
LIB_PUBLIC int ls_minor_version ()
LIB_PUBLIC int ls_build_date ()
LIB_PUBLIC int ls_version_code ()
LIB_PUBLIC int ls_info (char *buffer, int bufferSize)
LIB_PUBLIC int ls_version (char *buffer, int bufferSize)
LIB_PUBLIC int ls_platform (char *buffer, int bufferSize)
LIB_PUBLIC int ls_copyright (char *buffer, int bufferSize)
LIB_PUBLIC int ls_license_path (char *buffer, int bufferSize)
LIB_PUBLIC void ls_set_license_path (const char *path)
LIB_PUBLIC int ls_license_content (char *buffer, int bufferSize)
LIB_PUBLIC void ls_set_license_content (const char *content)
LSExpression operator+ (lsint expr0, LSExpression expr1)
LSExpression operator+ (lsdouble expr0, LSExpression expr1)
LSExpression operator+ (int expr0, LSExpression expr1)
LSExpression operator- (lsint expr0, LSExpression expr1)
LSExpression operator- (lsdouble expr0, LSExpression expr1)
LSExpression operator- (int expr0, LSExpression expr1)
LSExpression operator* (lsint expr0, LSExpression expr1)
LSExpression operator* (lsdouble expr0, LSExpression expr1)
LSExpression operator* (int expr0, LSExpression expr1)
LSExpression operator/ (lsint expr0, LSExpression expr1)
LSExpression operator/ (lsdouble expr0, LSExpression expr1)
LSExpression operator/ (int expr0, LSExpression expr1)
LSExpression operator% (lsint expr0, LSExpression expr1)
LSExpression operator% (int expr0, LSExpression expr1)
LSExpression operator== (lsint expr0, LSExpression expr1)
LSExpression operator== (lsdouble expr0, LSExpression expr1)
LSExpression operator== (int expr0, LSExpression expr1)
LSExpression operator!= (lsint expr0, LSExpression expr1)
LSExpression operator!= (lsdouble expr0, LSExpression expr1)
LSExpression operator!= (int expr0, LSExpression expr1)
LSExpression operator>= (lsint expr0, LSExpression expr1)
LSExpression operator>= (lsdouble expr0, LSExpression expr1)
LSExpression operator>= (int expr0, LSExpression expr1)
LSExpression operator<= (lsint expr0, LSExpression expr1)
LSExpression operator<= (lsdouble expr0, LSExpression expr1)
LSExpression operator<= (int expr0, LSExpression expr1)
LSExpression operator> (lsint expr0, LSExpression expr1)
LSExpression operator> (lsdouble expr0, LSExpression expr1)
LSExpression operator> (int expr0, LSExpression expr1)
LSExpression operator< (lsint expr0, LSExpression expr1)
LSExpression operator< (lsdouble expr0, LSExpression expr1)
LSExpression operator< (int expr0, LSExpression expr1)

Detailed Description

Namespace of LocalSolver.

Typedef Documentation

typedef BSolver localsolver::lssolver
typedef void(* localsolver::lsexceptioncallback)(lserrorcode code, const char *message, const char *filename, const char *funcname, int lineno, void *userdata)
typedef void(* localsolver::LSCallback)(LSCallbackType type, void *userdata)

Implementing a LSCallback function allows having user-defined functions called regularly during the search.

It can be used for example to control when to stop the search or to display some specific information during the search.

Parameters
solverThe solver calling the function.
typeThe type of event that triggered the call.
typedef long long localsolver::lsint

Integer type used in LocalSolver model.

The range of all integer numbers manipulated in LocalSolver model is limited to {-2^63, ..., 2^63-1}. Note that 2^63 = 9,223,372,036,854,775,808 > 10^18.

typedef double localsolver::lsdouble

Float type used in LocalSolver model.

The precision of all float numbers manipulated in LocalSolver model is limited to 64 bits.

Since
3.0

Enumeration Type Documentation

List of types that can be used with callbacks.

Each type corresponds to a specific event that can occur during the resolution.

Since
4.0
Enumerator:
CT_PhaseStarted 

Event that occurs when a phase is started.

CT_PhaseEnded 

Event that occurs when a phase ends.

CT_Ticked 

Event that occurs regularly during the resolution.

The time between two such ticks can be tuned with the timeBetweenDisplay parameter.

See Also
LSParam::setTimeBetweenDisplays(int)

List of error codes used by LSException.

Enumerator:
EC_Api 

Code used for errors related to API functions.

Used when you call a function in a wrong way or with inappropriate parameters.

Examples of error messages:

  • Argument 'argName' cannot be null.
  • Argument 'argName' does not belong to this instance of LocalSolver.
  • Argument 'argName' must be positive.
  • Argument 'argName' cannot be an empty string.
  • This method is only allowed in state Modeling (the model must not be closed).
EC_File 

Code used when an error related to input/output operations occurs.

Examples of error messages:

  • File doesn't exist.
  • File is corrupted.
  • Cannot open file.
  • File format is not recognized.
EC_Model 

Code used when a problem related to the structure of the model occurs.

Examples of error messages:

  • At least one objective is required in the model.
  • A cycle of length 'n' was detected in the model.
  • Number of operands ('n') is too small: at least 'm' operands are expected for 'operator'.
  • Operand 'n' of 'operator' must be 'type'. Type provided: 'otherType'.
EC_Callback 

Code used when an error is encountered in a user callback.

EC_License 

Code used when a problem related to licensing occurs.

That could be a problem with the license itself (expiration, hardware signature, ...), or a problem related to input/output or networking operations.

Examples of error messages:

  • Incorrect license number.
  • This license key is not compatible with the current hardware. Please contact your reseller.
  • Property prop is missing in file [file]
  • Fail to contact the token server. Check your connection.
  • This license is not compatible with the current hardware.
  • No token available. All tokens are currently in use.
EC_Solver 

Code used when a problem occurs during the resolution such a division by zero or an index out of bounds.

Keep in mind that, during the search variables are likely to take values that do not satisfy the constraints (for instance in the feasibility stage). Consequently when an division by zero or array overflow occurs in your model, it probably means that the denominator of a modulo or the index of a array can take invalid values. You can fix this using min and max expressions for instance: z <- x % y can be replaced by z<-x % max(1,y).

Examples of error messages:

  • Division by zero.
  • Index out of bounds for 'at' operator (index: 'indexId', array size: 'n')
EC_Internal 

Internal LocalSolver error.

EC_Modeler 

Code used when an error is encountered in the modeler.

Objective directions.

See Also
LSModel::addObjective(LSExpression*, LSObjectiveDirection)
Enumerator:
OD_Minimize 

Minimization.

OD_Maximize 

Maximization.

Mathematical operators available for modeling.

These operators are used to type the expressions created in LocalSolver mathematical optimization model.

See Also
LSModel
LSExpression
Enumerator:
O_Bool 

Boolean decision.

Decisional operator with no operand. Decision variable with domain {0,1}.

O_Float 

Float decision.

Decisional operator with two operands min and max. Decision variable with domain [min,max].

Since
4.0
O_Const 

Constant.

Unary operator. Can be equal to any integer. Note that constants 0 or 1 are considered as boolean. Constants are implicitly created when passing integer arguments to LSModel#createExpression(LSOperator, lsint) or LSExpression#addOperand(lsint).

O_Sum 

Sum.

N-ary arithmetic operator. SUM(e1,e2,...,eN) is equal to the sum of all operands e1,e2,...,eN. This operator returns an integer or a double according to the type of its operands.

O_Sub 

Substraction.

Binary arithmetic operator. SUB(x, y) is equal to the value of x - y. This operator returns an integer or a double according to the type of its operands.

Since
4.0
O_Prod 

Product.

N-ary arithmetic operator. PROD(e1,e2,...,eN) is equal to the product of all operands e1,e2,...,eN. This operator returns an integer or a double according to the type of its operands.

O_Max 

Maximum.

N-ary arithmetic operator. MAX(e1,e2,...,eN) is equal to the maximum value among all operands e1,e2,...,eN. This operator returns an integer or a double according to the type of its operands.

O_Min 

Minimum.

N-ary arithmetic operator. MIN(e1,e2,...,eN) is equal to the minimum value among all operands e1,e2,...,eN. This operator returns an integer or a double according to the type of its operands.

O_Eq 

Equal.

Binary relational operator. EQ(a,b) = 1 if a == b, and 0 otherwise. This operator returns a boolean.

O_Neq 

Not equal to.

Binary relational operator. NEQ(a,b) = 1 if a != b, and 0 otherwise. This operator returns a boolean.

O_Geq 

Greater than or equal to.

Binary relational operator. GEQ(a,b) = 1 if a >= b, and 0 otherwise. This operator returns a boolean.

O_Leq 

Lower than or equal to.

Binary relational operator. LEQ(a,b) = 1 if a <= b, and 0 otherwise. This operator returns a boolean.

O_Gt 

Strictly greater than.

Binary relational operator. GT(a,b) = 1 if a > b, and 0 otherwise. This operator returns a boolean.

O_Lt 

Strictly lower than.

Binary relational operator. LQ(a, b) = 1 if a < b, and 0 otherwise. This operator returns a boolean.

O_If 

If-Then-Else.

Ternary conditional operator. IF(a,b,c) is equal to b if a is true, and c otherwise. Note that the first operand must be a boolean (that is, equal to 0 or 1). This operator returns a boolean, an integer or a double according to the type of the second and third operands.

O_Not 

Not.

Unary logical operator. NOT(a) = 1 - a. Note that the operand must be boolean (that is, equal to 0 or 1). This operator returns a boolean.

O_And 

And.

N-ary logical operator. AND(e1,e2,...,eN) is equal to 1 (true) if all operands e1,e2,...,eN are 1, and 0 otherwise. Note that all operands must be boolean (that is, equal to 0 or 1). This operator returns a boolean.

O_Or 

Or.

N-ary logical operator. OR(e1,e2,...,eN) is equal to 0 if all operands e1,e2,...,eN are 0, and 1 otherwise. Note that all operands must be boolean (that is, equal to 0 or 1). This operator returns a boolean.

O_Xor 

Exclusive or (also called "xor").

N-ary logical operator. XOR(e1,e2,...,eN) is equal to 0 if the number of operands with value 1 among e1,e2,...,eN is even, and 1 otherwise. Remarkable case: XOR(a,b) = 1 if a == b, and 0 otherwise. Note that all operands must be boolean (that is, equal to 0 or 1). This operator returns a boolean.

O_Abs 

Absolute value.

Unary arithmetic operator. ABS(e) = e >= 0 ? e : -e. This operator returns an integer or a double according to the type of its operand.

O_Dist 

Distance between two numbers.

Binary arithmetic operator. DIST(a,b) = ABS(a-b). This operator returns an integer or a double according to the type of its operands.

O_Div 

Division.

Binary arithmetic operator. This operator always returns a double. Note that until version 4.0, the division was an integer division if both operands were integers.

O_Mod 

Modulo (remainder of the integer division).

Binary arithmetic operator. MOD(a,b) = r such that a = q * b + r with q, r integers and |r| < b. An error will be thrown if b equals 0 at an iteration of the search. Note that the operands must be integers. This operator returns an integer.

O_Array 

Array.

An array is a collection of elements. Indexes begin at 0. It could be used with operators like at or scalar. An array can contain operands of type double, integer or boolean. Note that an array cannot contain another array.

Since
2.1
O_At 

Returns the element of an array.

MyArray[i] returns the i element of the array MyArray. An error will be thrown if i is out of range. This operator returns a boolean, an integer or a double according to the type of the operands in the array.

Since
2.1
O_Scalar 

Scalar product.

SCALAR(a, x) = sum(a[i]*x[i]) with a and x two arrays. This operator returns an integer or a double according to the type of the operands in the arrays.

Since
2.1
O_Ceil 

Ceil.

Unary arithmetic operator. Returns a value rounded to the next highest integer. This operator returns an integer.

Since
3.0
O_Floor 

Floor.

Unary arithmetic operator. Returns a value rounded to the next lowest integer. This operator returns an integer.

Since
3.0
O_Round 

Round.

Unary arithmetic operator. Returns a value rounded to the nearest integer. This operator returns an integer.

Since
3.0
O_Sqrt 

Square root.

Unary arithmetic operator. This operator returns a double.

Since
3.0
O_Log 

Natural logarithm (base-e).

Unary arithmetic operator. This operator returns a double.

Since
3.0
O_Exp 

Base-e exponential.

Unary arithmetic operator. This operator returns a double.

Since
3.0
O_Pow 

Power operator.

POW(x, y) is equals to the value of x to the power of y. This operator returns a double.

Since
3.0
O_Cos 

Cosine.

Unary arithmetic operator. This operator returns a double.

Since
3.0
O_Sin 

Sine.

Unary arithmetic operator. This operator returns a double.

Since
3.0
O_Tan 

Tangent.

Unary arithmetic operator. This operator returns a double.

Since
3.0
O_Int 

Integer decision variable.

Decisional operator with two operands min and max. Decision variable with domain [min,max].

Since
5.0
O_Piecewise 

Piecewise-linear function operator.

The piecewise linear function is defined by two arrays of numbers giving the breakpoints of the function. This operator has exactly 3 operands: The first two operands must be two arrays of equal lengths (necessarily larger or equal to 2). These arrays must contain constant numbers (int or double). The first array must contain numbers in ascending order. The third operand must be an integer or double expression. An exception will be thrown if its value is strictly smaller that the first element of the first array, or strictly larger than the last element of the first array. This operator returns a double.

piecewise(x,y,z) returns the image of z by the function defined by geometric points (x[0],y[0]), (x[1],y[1]), ..... (x[n-1],y[n-1]), For instance piecewise({0,50,100},{0,10,100},75) returns 55.

Discontinuities are allowed in the definition of the function, that is to say that two geometric points can share the same x-coordinate. By convention the value taken by the function at such a discontinuous point is the one associated to the last occurrence of this x-coordinate in array x. For instance piecewise({0,50,50,100},{0,0.1,0.9,1},50) returns 0.9;

Since
5.0
O_List 

A list is an collection of integers within a range [0,n-1] where n is the unique argument of this operator.

Mathematically a list is a permutation of a subset of [0,n-1]. This operator takes exactly one parameter: a constant strictly positive integer. All values in the list will be pairwise different, non negative and strictly smaller that this number. The elements of the list can be accessed with the at operator (-1 will be returned for indices beyond the number of elements in the list and for negative indices).

Since
5.5
O_Count 

The number of elements in a collection.

This operator takes exactly one argument of type list.

Since
5.5
O_IndexOf 

The index of a value in a list (-1 if the value is not in the list).

This operator takes exactly two arguments: the first one is a list, the second one is an integer expression.

Since
5.5
O_Partition 

Partition.

N-ary logical operator. Partition(l1,l2,...,lN) is true if all lists l1,l2..lN form a partition of their common range. All parameters of this operator must be lists on the same range.

Since
5.5
O_Disjoint 

Disjoint.

N-ary logical operator. Disjoint(l1,l2,...,lN) is true if all lists l1,l2..lN are pairwise disjoint. All parameters of this operator must be lists on the same range.

Since
5.5

Solution status: Optimal, Feasible, Infeasible or Inconsistent.

See Also
LSSolution
Enumerator:
SS_Inconsistent 

Solution and model are inconsistent.

The solver was able to prove that the model admits no feasible solution. Note that even a model without any constraint can be infeasible because some expressions induce implicit constraints: for instance defining sqrt(x) implicitly constrains x to be non-negative.

SS_Infeasible 

Solution is infeasible (some constraints are violated).

SS_Feasible 

Solution is feasible but optimality was not proven.

SS_Optimal 

Solution is optimal (all objective bounds are reached).

State of LocalSolver environment.

See Also
LocalSolver::getState()
Enumerator:
S_Modeling 

Model is being built.

S_Running 

Solver is running.

S_Paused 

Solver is paused.

S_Stopped 

Solver is stopped.

Function Documentation

template<typename T >
with_iterator localsolver::is_iterator ( typename T::iterator_category *  )
template<typename T >
without_iterator localsolver::is_iterator (   ...)
LIB_PUBLIC lssolver* localsolver::ls_create_solver_fail_safe ( lsexceptioncallback  cb,
void *  userdata 
)
LIB_PUBLIC lssolver* localsolver::ls_create_solver ( )
LIB_PUBLIC void localsolver::ls_delete_solver ( lssolver *  solver)
LIB_PUBLIC lsstate localsolver::ls_get_state ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_solve ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_stop ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_add_phase ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_nb_phases ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_solver_to_string ( lssolver *  solver,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_param_to_string ( lssolver *  solver,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_solver_info ( lssolver *  solver,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC bool localsolver::ls_check_paused_or_stopped ( lssolver *  solver)
LIB_PUBLIC bool localsolver::ls_check_not_running ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_save_environment ( lssolver *  solver,
const char *  filename 
)
LIB_PUBLIC void localsolver::ls_load_environment ( lssolver *  solver,
const char *  filename 
)
LIB_PUBLIC void localsolver::ls_add_callback ( lssolver *  solver,
lscallbacktype  type,
lscallback  callback,
void *  userdata 
)
LIB_PUBLIC bool localsolver::ls_remove_callback ( lssolver *  solver,
lscallbacktype  type,
lscallback  callback 
)
LIB_PUBLIC bool localsolver::ls_remove_callback_2 ( lssolver *  solver,
lscallbacktype  type,
lscallback  callback,
void *  userdata 
)
LIB_PUBLIC void localsolver::ls_set_seed ( lssolver *  solver,
int  seed 
)
LIB_PUBLIC int localsolver::ls_get_seed ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_set_nb_threads ( lssolver *  solver,
int  nbThreads 
)
LIB_PUBLIC int localsolver::ls_get_nb_threads ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_set_annealing_level ( lssolver *  solver,
int  annealingLevel 
)
LIB_PUBLIC int localsolver::ls_get_annealing_level ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_set_verbosity ( lssolver *  solver,
int  verbosity 
)
LIB_PUBLIC int localsolver::ls_get_verbosity ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_set_time_between_displays ( lssolver *  solver,
int  timeBetweenDisplays 
)
LIB_PUBLIC int localsolver::ls_get_time_between_displays ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_set_log_file ( lssolver *  solver,
const char *  path 
)
LIB_PUBLIC int localsolver::ls_get_log_file ( lssolver *  solver,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC bool localsolver::ls_advanced_param_is_set ( lssolver *  solver,
const char *  param 
)
LIB_PUBLIC int localsolver::ls_get_advanced_param ( lssolver *  solver,
const char *  param,
int  defaultValue 
)
LIB_PUBLIC void localsolver::ls_set_advanced_param ( lssolver *  solver,
const char *  param,
int  value 
)
LIB_PUBLIC int localsolver::ls_get_advanced_str_param ( lssolver *  solver,
const char *  param,
const char *  defaultValue,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC void localsolver::ls_set_advanced_str_param ( lssolver *  solver,
const char *  param,
const char *  value 
)
LIB_PUBLIC void localsolver::ls_set_int_objective_bound ( lssolver *  solver,
int  objPos,
lsint  bound 
)
LIB_PUBLIC void localsolver::ls_set_double_objective_bound ( lssolver *  solver,
int  objPos,
lsdouble  bound 
)
LIB_PUBLIC lsint localsolver::ls_get_int_objective_bound ( lssolver *  solver,
int  objPos 
)
LIB_PUBLIC lsdouble localsolver::ls_get_double_objective_bound ( lssolver *  solver,
int  objPos 
)
LIB_PUBLIC int localsolver::ls_create_int_constant ( lssolver *  solver,
lsint  value 
)
LIB_PUBLIC int localsolver::ls_create_double_constant ( lssolver *  solver,
lsdouble  value 
)
LIB_PUBLIC int localsolver::ls_create_expression ( lssolver *  solver,
lsoperator  op 
)
LIB_PUBLIC int localsolver::ls_nb_expressions ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_nb_decisions ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_get_decision ( lssolver *  solver,
int  decisionPos 
)
LIB_PUBLIC int localsolver::ls_get_expression_with_name ( lssolver *  solver,
const char *  name 
)
LIB_PUBLIC void localsolver::ls_add_constraint ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC void localsolver::ls_remove_constraint ( lssolver *  solver,
int  constraintPos 
)
LIB_PUBLIC void localsolver::ls_remove_constraint_with_expr ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC int localsolver::ls_nb_constraints ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_get_constraint ( lssolver *  solver,
int  constraintPos 
)
LIB_PUBLIC void localsolver::ls_add_objective ( lssolver *  solver,
int  exprId,
lsobjdirection  direction 
)
LIB_PUBLIC void localsolver::ls_remove_objective ( lssolver *  solver,
int  objectivePos 
)
LIB_PUBLIC int localsolver::ls_nb_objectives ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_get_objective ( lssolver *  solver,
int  objectiveIndex 
)
LIB_PUBLIC lsobjdirection localsolver::ls_get_objective_direction ( lssolver *  solver,
int  objectivePos 
)
LIB_PUBLIC int localsolver::ls_nb_operands ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_close ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_open ( lssolver *  solver)
LIB_PUBLIC bool localsolver::ls_is_closed ( lssolver *  solver)
LIB_PUBLIC int localsolver::ls_model_to_string ( lssolver *  solver,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC bool localsolver::ls_expr_check_index ( lssolver *  solver,
int  exprIndex 
)
LIB_PUBLIC lsint localsolver::ls_expr_get_int_value ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC lsdouble localsolver::ls_expr_get_double_value ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_violated ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC void localsolver::ls_expr_set_int_value ( lssolver *  solver,
int  exprId,
lsint  value 
)
LIB_PUBLIC void localsolver::ls_expr_set_double_value ( lssolver *  solver,
int  exprId,
lsdouble  value 
)
LIB_PUBLIC bool localsolver::ls_expr_is_named ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC int localsolver::ls_expr_get_name ( lssolver *  solver,
int  exprId,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC void localsolver::ls_expr_set_name ( lssolver *  solver,
int  exprId,
const char *  name 
)
LIB_PUBLIC int localsolver::ls_expr_info ( lssolver *  solver,
int  exprId,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_expr_to_string ( lssolver *  solver,
int  exprId,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_expr_nb_operands ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC void localsolver::ls_expr_set_operand ( lssolver *  solver,
int  exprId,
int  operandPos,
int  operandId 
)
LIB_PUBLIC void localsolver::ls_expr_add_operand ( lssolver *  solver,
int  exprId,
int  operandId 
)
LIB_PUBLIC int localsolver::ls_expr_get_operand ( lssolver *  solver,
int  exprId,
int  operandPos 
)
LIB_PUBLIC bool localsolver::ls_expr_is_array ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_collection ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_bool ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_int ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_double ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_objective ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_decision ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_constraint ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC bool localsolver::ls_expr_is_constant ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC lsoperator localsolver::ls_expr_get_operator ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC lssolutionstatus localsolver::ls_get_solution_status ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_clear_solution ( lssolver *  solver)
LIB_PUBLIC void localsolver::ls_collection_clear ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC void localsolver::ls_collection_add ( lssolver *  solver,
int  exprId,
lsint  val 
)
LIB_PUBLIC lsint localsolver::ls_collection_count ( lssolver *  solver,
int  exprId 
)
LIB_PUBLIC lsint localsolver::ls_collection_get ( lssolver *  solver,
int  exprId,
int  pos 
)
LIB_PUBLIC int localsolver::ls_collection_to_string ( lssolver *  solver,
int  exprId,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC bool localsolver::ls_phase_check_index ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC void localsolver::ls_phase_set_optimized_objective ( lssolver *  solver,
int  phaseIndex,
int  optimizedObjective 
)
LIB_PUBLIC int localsolver::ls_phase_get_optimized_objective ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC void localsolver::ls_phase_set_iteration_limit ( lssolver *  solver,
int  phaseIndex,
long long  iterationLimit 
)
LIB_PUBLIC long long localsolver::ls_phase_get_iteration_limit ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC void localsolver::ls_phase_set_time_limit ( lssolver *  solver,
int  phaseIndex,
int  timeLimit 
)
LIB_PUBLIC int localsolver::ls_phase_get_time_limit ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC void localsolver::ls_phase_set_enabled ( lssolver *  solver,
int  phaseIndex,
bool  enabled 
)
LIB_PUBLIC bool localsolver::ls_phase_is_enabled ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC int localsolver::ls_phase_to_string ( lssolver *  solver,
int  phaseIndex,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_stats_get_running_time ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC long long localsolver::ls_stats_get_nb_iterations ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC long long localsolver::ls_stats_get_nb_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC long long localsolver::ls_stats_get_nb_accepted_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC long long localsolver::ls_stats_get_nb_improving_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC long long localsolver::ls_stats_get_nb_rejected_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC long long localsolver::ls_stats_get_nb_infeasible_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC double localsolver::ls_stats_get_percent_accepted_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC double localsolver::ls_stats_get_percent_improving_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC double localsolver::ls_stats_get_percent_rejected_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC double localsolver::ls_stats_get_percent_infeasible_moves ( lssolver *  solver,
int  phaseIndex 
)
LIB_PUBLIC int localsolver::ls_stats_to_string ( lssolver *  solver,
int  phaseIndex,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_stats_info ( lssolver *  solver,
int  phaseIndex,
char *  buffer,
int  bufferSize 
)
LIB_PUBLIC void localsolver::ls_add_exception_callback ( lssolver *  solver,
lsexceptioncallback  callback,
void *  userdata 
)
LIB_PUBLIC bool localsolver::ls_remove_exception_callback ( lssolver *  solver,
lsexceptioncallback  callback 
)
LIB_PUBLIC bool localsolver::ls_remove_exception_callback_2 ( lssolver *  solver,
lsexceptioncallback  callback,
void *  userdata 
)
LIB_PUBLIC int localsolver::ls_major_version ( )
LIB_PUBLIC int localsolver::ls_minor_version ( )
LIB_PUBLIC int localsolver::ls_build_date ( )
LIB_PUBLIC int localsolver::ls_version_code ( )
LIB_PUBLIC int localsolver::ls_info ( char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_version ( char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_platform ( char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_copyright ( char *  buffer,
int  bufferSize 
)
LIB_PUBLIC int localsolver::ls_license_path ( char *  buffer,
int  bufferSize 
)
LIB_PUBLIC void localsolver::ls_set_license_path ( const char *  path)
LIB_PUBLIC int localsolver::ls_license_content ( char *  buffer,
int  bufferSize 
)
LIB_PUBLIC void localsolver::ls_set_license_content ( const char *  content)
LSExpression localsolver::operator+ ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator+ ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator+ ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator- ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator- ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator- ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator* ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator* ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator* ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator/ ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator/ ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator/ ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator% ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator% ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator== ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator== ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator== ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator!= ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator!= ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator!= ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator>= ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator>= ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator>= ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator<= ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator<= ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator<= ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator> ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator> ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator> ( int  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator< ( lsint  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator< ( lsdouble  expr0,
LSExpression  expr1 
)
inline
LSExpression localsolver::operator< ( int  expr0,
LSExpression  expr1 
)
inline