siconos.numerics#
Module documentation
A collection of low-level algorithms for solving basic algebra and optimization problem arising in the simulation of nonsmooth dynamical systems.
Example of usage:
>>> import siconos.numerics as sn
>>> help(sn.LCP)
- siconos.numerics.linearComplementarity_driver(problem, z, w, options)[source]#
General interface to solvers for Linear Complementarity Problems
- Parameters:
problem (
LinearComplementarityProblem
, in) – the LinearComplementarityProblem structure which handles the problem (M,q)z (float, in/out) – a n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
info termination value - 0 : successful - >0 : otherwise see each solver for more information about the log info
- siconos.numerics.mlcp_driver(problem, z, w, options)[source]#
General interface to solver for MLCP problems
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – the MixedLinearComplementarityProblem structure which handles the problem (M,q)z (float, in/out) – a m+n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
info termination value,
0 : successful
>0 : otherwise see each solver for more information about the log info
TODO: Sizing the regularization parameter and apply it only on null diagnal term
- siconos.numerics.fc2d_driver(problem, reaction, velocity, options)[source]#
General interface to solvers for friction-contact 2D problem
- Parameters:
problem (
FrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.fc3d_driver(problem, reaction, velocity, options)[source]#
General interface to solvers for friction-contact 3D problem
- Parameters:
problem (
FrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.rolling_fc3d_driver(problem, reaction, velocity, options)[source]#
General interface to solvers for rolling friction-contact 3D problem
- Parameters:
problem (
RollingFrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.rolling_fc2d_driver(problem, reaction, velocity, options)[source]#
General interface to solvers for rolling friction-contact 2D problem
- Parameters:
problem (
RollingFrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.gfc2d_driver(problem, reaction, velocity, globalVelocity, options)[source]#
General interface to solvers for global friction-contact 2D problem
- Parameters:
problem (
GlobalFrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
globalVelocity (float, in/out) – global vector
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.gfc3d_driver(problem, reaction, velocity, globalVelocity, options)[source]#
General interface to solvers for global friction-contact 3D problem
- Parameters:
problem (
GlobalFrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
globalVelocity (float, in/out) – global vector
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.g_rolling_fc3d_driver(problem, reaction, velocity, globalVelocity, options)[source]#
General interface to solvers for global rolling friction-contact 3D problem
- Parameters:
problem (
GlobalRollingFrictionContactProblem
, in) – the structure which handles the Friction-Contact problemreaction (float, in/out) – global vector (n)
velocity (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.variationalInequality_driver(problem, x, w, options)[source]#
General interface to solvers for friction-contact 3D problem
- Parameters:
problem (
VariationalInequality
, in) – the structure which handles the Friction-Contact problemx (float, in/out) – global vector (n)
w (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.avi_driver(problem, z, w, options)[source]#
General interface to solvers for Affine Variational Inequalities (AVI)
- Parameters:
problem (
AffineVariationalInequalities
, in) – the AffineVariationalInequalities structure which handles the problem (M,q)z (float, in/out) – a n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
info termination value - 0 : successful - >0 : otherwise see each solver for more information about the log info
- siconos.numerics.mcp_old_driver(problem, z, w, options)[source]#
General interface to solver for MCP problems
- Parameters:
problem (
MixedComplementarityProblem_old
, in) – the MixedComplementarityProblem_old structure which handles the problemz (float, in/out) – a m+n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and its(their) parameters
- Return type:
- Returns:
info termination value 0 : successful, else error.
- siconos.numerics.mcp_driver(problem, z, w, options)[source]#
General interface to solver for MCP problems – new version
- Parameters:
problem (
MixedComplementarityProblem
, in) – the MixedComplementarityProblem structure which handles the problemz (float, in/out) – a m+n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and its(their) parameters
- Return type:
- Returns:
info termination value 0 : successful, else error.
- siconos.numerics.ncp_driver(problem, z, F, options)[source]#
General interface to solver for NCP problems
- Parameters:
problem (
NonlinearComplementarityProblem
, in) – the NonlinearComplementarityProblem structure which handles the problemz (float, in/out) – a n-vector of doubles which contains the solution of the problem.
F (float, in/out) – a n-vector of doubles which contains value of the function evaluated at the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and its(their) parameters
- Return type:
- Returns:
info termination value 0 : successful, else error
- siconos.numerics.soclcp_driver(problem, r, v, options)[source]#
General interface to solvers for SOCLCP problem
- Parameters:
problem (
SecondOrderConeLinearComplementarityProblem
, in) – the structure which handles the Friction-Contact problemr (float, in/out) – global vector (n)
v (float, in/out) – global vector (n)
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.fc3d_LmgcDriver(reaction, velocity, q, mu, W, row, column, nc, nb, solver_id, tolerance, itermax, verbose, outputFile, freq_output, ndof)[source]#
LMGC interface to solvers for friction-contact 3D problem
- Parameters:
reaction (float, in/out) – global vector (nc*3)
velocity (float, in/out) – global vector (nc*3)
q (float, in) – global vector (nc*3)
mu (float, in) – global vector (nc)
W (float, in) – the block matrix in coordinate format
row (int, in) – block row indices
column (int, in) – block column indices
nc (int, in) – number of contacts
nb (int, in) – number of blocks
solver_id (int, in) – id an int to be mapped to actual solver in Numerics
tolerance (float, in) – threshold used to validate the solution: if the error is less than this value, the solution is accepted
itermax (int, in) – the maximum number of iteration
verbose (int, in) – level 0 : nothing, 1: mid level 2: high level
outputFile (int, in) – outputFile option 0 : nothing 1 : dat file 2: FCLIB HDF5 file if FCLIB is found
freq_output (int, in) –
ndof (int, in) – the numbe of dof in the dynamical systems involved in contact (for output in file.)
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.gfc3d_LmgcDriver(reaction, velocity, globalVelocity, q, b, mu, Mdata, nzM, rowM, colM, Hdata, nzH, rowH, colH, n, nc, solver_id, isize, iparam, dsize, dparam, verbose, outputFile, freq_output)[source]#
LMGC interface to solvers for global friction-contact 3D problem
- Parameters:
reaction (float, in/out) – global vector (nc*3)
velocity (float, in/out) – global vector (nc*3)
globalVelocity (float, in/out) – global velocity vector (n)
q (float, in) – global vector (n)
b (float, in) – global vector (nc*3)
mu (float, in) – global vector (nc)
Mdata (float, in) – the sparse matrix in coordinate format
nzM (int, in) – number of non zeros in Mdata
rowM (int, in) – row indices of M
colM (int, in) – column indices of M
Hdata (float, in) – the sparse matrix in coordinate format
nzH (int, in) – number of non zeros in Hdata
rowH (int, in) – row indices of H
colH (int, in) – column indices of H
n (int, in) – size of global velocity
nc (int, in) – number of contacts
solver_id (int, in) – id an int to be mapped to actual solver in Numerics
isize (int, in) – sive of integer parameters array
iparam (int, in) – integer parameters array
dsize (int, in) – sive of double parameters array
dparam (float, in) – double parameters array
verbose (int, in) – level 0 : nothing, 1: mid level 2: high level
outputFile (int, in) – outputFile option 0 : nothing 1 : C file , 1 : dat file 3: FCLIB HDF5 file if FCLIB is found
freq_output (int, in) –
- Return type:
- Returns:
result (0 if successful otherwise 1).
- siconos.numerics.relay_driver(problem, z, w, options)[source]#
General interface to solver for relay problems
- Parameters:
problem (RelayProblem, in) – the RelayProblem structure which handles the problem (M,q)
z (float, in/out) – a n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and its (their) parameters
- Return type:
- Returns:
info termination value
0 : successful
>0 : otherwise see each solver for more information about the log info
- class siconos.numerics.Callback[source]#
Bases:
object
Structure used to store user callbacks inside solvers
- property env#
general user environment
- property collectStatsIteration#
pointer on a function Its signature is: user env, problem size, reaction, velocity, error at end of solver iteration (when this makes sense) and an extra data structure
- class siconos.numerics.SolverOptions(*args)[source]#
Bases:
object
Structure used to send options (name, parameters and so on) to a specific solver (mainly from Kernel to Numerics).
Creation, update and destruction:
solver_options_create()
solver_options_update_internal()
solver_options_delete()
Details in users’guide.
- property solverId#
id number of the solver.
- property isSet#
true(1) if the structure is ready to be used by a numerics driver.
- property iSize#
iSize size of vector iparam
- property iparam#
list of solver parameters (integer type); Check solvers doc for details.
- property dSize#
size of vector dparam
- property dparam#
list of solver parameters (double type); Check solvers doc for details.
- property filterOn#
if true (1), check solution validity after the driver call. Default = 1. For example if filterOn = 1 for a LCP, lcp_compute_error() will be called at the end of the process).
- property dWorkSize#
size of double type internal work array.
- property dWork#
internal (double type) work array.
- property iWorkSize#
size of integer type internal work array.
- property iWork#
internal (integer type) work array.
- property numberOfInternalSolvers#
the number of internal or local ‘sub-solvers’ used by the solver (size of internalSolvers) .
- property internalSolvers#
list of internal solver options
- property callback#
pointer to user-defined callback
- property solverParameters#
additional parameters specific to the solver (GAMS and NewtonMethod only)
- property solverData#
additional data specific to the solver
- siconos.numerics.SICONOS_ERROR_FULL_EVALUATION = 0#
Complete error computation, including v computation
- siconos.numerics.SICONOS_ERROR_LIGHT_EVALUATION = 1#
Light error computation with incremental values on r verification of absolute error at the end
- siconos.numerics.SICONOS_ERROR_LIGHT_EVALUATION_NO_UPDATE = 2#
only light error computation, do not update v unknown)
- siconos.numerics.solver_options_print(options)[source]#
screen display of solver parameters
- Parameters:
options (
SolverOptions
) – the structure to be displayed
- siconos.numerics.solver_options_delete(options)[source]#
Clear and free all pointer members of the structure, then release memory
- Parameters:
options (
SolverOptions
) – the structure to be cleared.
- siconos.numerics.solver_options_create(solverId)[source]#
Create and initialize a SolverOptions struct: allocate internal memories, set default values depending on the id.
- Parameters:
id – solver id number It must belong to one of the available ids defined for each formulation, see users’guide for details
- Return type:
- Returns:
a pointer to options set, ready to use by a driver.
- siconos.numerics.solver_options_copy(source)[source]#
Copy an existing set of options, to create a new one. Warning : callback, solverData and solverParameters of the new structure are pointer links to those of the original one!
- Parameters:
source (
SolverOptions
) – an existing solver options structure- Return type:
- Returns:
a pointer to options set, ready to use by a driver.
- siconos.numerics.solver_options_update_internal(parent, internal_solver_number, solver_id)[source]#
Change one of the internal solver of a previously defined SolverOptions set. Allocate internal memories and set default values for the internal solver. Warning : the actual internal solver in position internal_solver_number and all its content will be destroyed and replaced by a new one.
- Parameters:
parent (
SolverOptions
) – the top-level SolverOptions which contains the internal solver to be updatedinternal_solver_number (int) – number of the internal solver to be update (warning : this is the position in the list of internal solvers, not the id!)
solver_id (int) – id number of the new internal solver to be created/updated
- siconos.numerics.solver_options_name_to_id(pName)[source]#
return the id of a solver based on its name
- Parameters:
pName (string) – the name of the solver
- Return type:
- Returns:
the id of the solver or 0 if it failed
- siconos.numerics.solver_options_id_to_name(Id)[source]#
return the name of a solver given its id
- Parameters:
Id (int) – the id of the solver
- Return type:
string
- Returns:
the name of the solver
- siconos.numerics.solver_options_get_internal_solver(options, n)[source]#
return the internal solver options set
- Parameters:
options (
SolverOptions
) – parent optionsnumber – of the targeted solver
- Return type:
- Returns:
a pointer to the internal solver options set
- siconos.numerics.solver_options_set_internal_solver(options, n, NSO)[source]#
set internal solver
- Parameters:
options (
SolverOptions
) – parent optionsnumber – of the targeted solver
the – solver options to be used as internal solver number n
- siconos.numerics.numerics_error(*args)[source]#
- check IO
msg output and exit with error
- Parameters:
fn_name (string) – name of the function where error occurs
msg (string) – formatted output msg
- siconos.numerics.numerics_error_nonfatal(*args)[source]#
log error message without exit
- Parameters:
fn_name (string) – name of the function where the error occurs
msg (string) – formatted output message
- siconos.numerics.numerics_warning(*args)[source]#
log warning
- Parameters:
fn_name (string) – name of the function where warning occurs
msg (string) – formatted output message
- siconos.numerics.numerics_printf(*args)[source]#
log message (if verbosity is on)
- Parameters:
fmt (string) – formatted output message
- siconos.numerics.numerics_printf_verbose(*args)[source]#
log message if verbose is non null
- Parameters:
verbose (int) – log message is non null
fmt (string) – formatted output message
- class siconos.numerics.CSparseMatrix_factors[source]#
Bases:
object
Information used and produced by CSparse for an LU factorization
- property n#
size of linear system
- property S#
symbolic analysis
- property N#
numerics factorization
- siconos.numerics.CSparseMatrix_lu_factorization(order, A, tol, cs_lu_A)[source]#
compute a LU factorization of A and store it in a workspace
- Parameters:
order (int) – control if ordering is used
A (CSparseMatrix) – the sparse matrix
tol (float) – the tolerance
cs_lu_A (
CSparseMatrix_factors
) – the parameter structure that eventually holds the factors
- Return type:
- Returns:
1 if the factorization was successful, 1 otherwise
- siconos.numerics.CSparseMatrix_chol_factorization(order, A, cs_chol_A)[source]#
compute a Cholesky factorization of A and store it in a workspace
- Parameters:
order (int) – control if ordering is used
A (CSparseMatrix) – the sparse matrix
cs_chol_A (
CSparseMatrix_factors
) – the parameter structure that eventually holds the factors
- Return type:
- Returns:
1 if the factorization was successful, 1 otherwise
- siconos.numerics.CSparseMatrix_ldlt_factorization(order, A, cs_ldlt_A)[source]#
compute a LDLT factorization of A and store it in a workspace
- Parameters:
order (int) – control if ordering is used
A (CSparseMatrix) – the sparse matrix
cs_ldlt_A (
CSparseMatrix_factors
) – the parameter structure that eventually holds the factors
- Return type:
- Returns:
1 if the factorization was successful, 1 otherwise
- siconos.numerics.CSparseMatrix_solve(cs_lu_A, x, b)[source]#
reuse a LU factorization (stored in the cs_lu_A) to solve a linear system Ax = b
- Parameters:
cs_lu_A (
CSparseMatrix_factors
) – contains the LU factors of A, permutation informationx (float) – workspace
b (float, in/out) – on input RHS of the linear system; on output the solution
- Return type:
- Returns:
0 if failed, 1 otherwise
- siconos.numerics.CSparseMatrix_spsolve(cs_lu_A, X, B)[source]#
reuse a LU factorization (stored in the cs_lu_A) to solve a linear system Ax = B with a sparse r.h.s
- Parameters:
cs_lu_A (
CSparseMatrix_factors
) – contains the LU factors of A, permutation informationX (CSparseMatrix) – a csc sparse matrix workspace
B (CSparseMatrix, in/out) – on input sparse RHS of the linear system; on output the solution
- Return type:
- Returns:
0 if failed, 1 otherwise
- siconos.numerics.CSparseMatrix_chol_solve(cs_chol_A, x, b)[source]#
reuse a Cholesky factorization (stored in the cs_chol_A) to solve a linear system Ax = b
- Parameters:
cs_chol_A (
CSparseMatrix_factors
) – contains the Cholesky factors of A, permutation informationx (float) – workspace
b (float, in/out) – on input RHS of the linear system; on output the solution
- Return type:
- Returns:
0 if failed, 1 otherwise
- siconos.numerics.CSparseMatrix_chol_spsolve(cs_chol_A, X, B)[source]#
reuse a Cholesky factorization (stored in the cs_chol_A) to solve a linear system Ax = B with a sparse r.h.s
- Parameters:
cs_chol_A (
CSparseMatrix_factors
) – contains the Cholesky factors of A, permutation informationX (CSparseMatrix) – a csc sparse matrix workspace
b – on input sparse RHS of the linear system; on output the solution
- Return type:
- Returns:
0 if failed, 1 otherwise
- siconos.numerics.CSparseMatrix_ldlt_solve(cs_ldlt_A, x, b)[source]#
reuse a LDLT factorization (stored in the cs_ldlt_A) to solve a linear system Ax = b
- Parameters:
cs_ldlt_A (
CSparseMatrix_factors
) – contains the LDLT factors of A, permutation informationx (float) – workspace
b (float, in/out) – on input RHS of the linear system; on output the solution
- Return type:
- Returns:
0 if failed, 1 otherwise
- siconos.numerics.CSparseMatrix_free_lu_factors(cs_lu_A)[source]#
Free a workspace related to a LU factorization
- Parameters:
cs_lu_A (
CSparseMatrix_factors
) – the structure to free
- siconos.numerics.CSparseMatrix_aaxpby(alpha, A, x, beta, y)[source]#
Matrix vector multiplication : y = alpha*A*x+beta*y
- siconos.numerics.CSparseMatrix_alloc_for_copy(m)[source]#
Allocate a CSparse matrix for future copy (as in NSM_copy)
- Parameters:
m (CSparseMatrix) – the matrix used as model
- Return type:
CSparseMatrix
- Returns:
an newly allocated matrix
- siconos.numerics.CSparseMatrix_print(A, brief)[source]#
print a matrix to std output
- Parameters:
A (CSparseMatrix) – matrix to print
brief (int) – if positive, print only a portion of the matrix
- siconos.numerics.CSparseMatrix_print_in_file(A, brief, file)[source]#
print a matrix to a text file
- Parameters:
A (CSparseMatrix) – matrix to print
brief (int) – if positive, print only a portion of the matrix
file (FILE) – file descriptor
- siconos.numerics.CSparseMatrix_zentry(T, i, j, x, threshold)[source]#
Add an entry to a triplet matrix only if the absolute value is greater than threshold
- siconos.numerics.CSparseMatrix_symmetric_zentry(T, i, j, x, threshold)[source]#
Add an entry to a symmetric triplet matrix only if the absolute value is greater than threshold
- siconos.numerics.CSparseMatrix_symmetric_entry(T, i, j, x)[source]#
Add an entry to a symmetric triplet matrix
- siconos.numerics.CSparseMatrix_check_triplet(T)[source]#
Check if the given triplet matrix is properly constructed (col and row indices are correct)
- Parameters:
T (CSparseMatrix) – the sparse matrix to check
- Return type:
- Returns:
0 if the matrix is fine, 1 otherwise
- siconos.numerics.CSparseMatrix_check_csc(T)[source]#
Check if the given triplet matrix is properly constructed (col and row indices are correct)
- Parameters:
T (CSparseMatrix) – the sparse matrix to check
- Return type:
- Returns:
0 if the matrix is fine, 1 otherwise
- siconos.numerics.CSparseMatrix_spfree_on_stack(A)[source]#
Free space allocated for a SparseMatrix. note : cs_spfree also free the cs_struct this fails when the struct is allocated on the stack.
- Parameters:
A (CSparseMatrix) – the sparse matrix
- Return type:
CSparseMatrix
- Returns:
NULL on success
- siconos.numerics.CSparseMatrix_copy(A, B)[source]#
Copy a CSparseMatrix inside another CSparseMatrix. Reallocations are performed if B cannot hold a copy of A
- Parameters:
A (CSparseMatrix, in) – a CSparseMatrix
B (CSparseMatrix, in/out) – a CSparseMatrix
- siconos.numerics.CSparseMatrix_scal(alpha, A)[source]#
Multiply a matrix with a double alpha*A –> A
- Parameters:
alpha (float) – the coefficient
A (CSparseMatrix) – the matrix
- siconos.numerics.CSparseMatrix_write_in_file_python(m, file)[source]#
print a matrix to a text file in pyhton format
- Parameters:
m (CSparseMatrix) – matrix to print
file (FILE) – file descriptor
- siconos.numerics.CSparseMatrix_max_by_columns(A, max)[source]#
Compute the max by columns of a sparse matrix
- Parameters:
A (CSparseMatrix) – the sparse matrix
max (float) – the vector of maximum by columns
j – the column index
- siconos.numerics.CSparseMatrix_max_abs_by_columns(A, max)[source]#
Compute the max in absolute value by columns of a sparse matrix
- Parameters:
A (CSparseMatrix) – the sparse matrix
max (float) – the vector of maximum by columns
j – the column index
- class siconos.numerics.SparseBlockStructuredMatrix[source]#
Bases:
object
Structure to store sparse block matrices with square diagonal blocks.
- Parameters:
nbblocks – the total number of non null blocks
**block –
: *block contains the double values of one block in Fortran storage (column by column) **block is the list of non null blocks
blocknumber0 – the first dimension of the block matrix (number of block rows)
blocknumber1 – the second dimension of the block matrix (number of block columns)
*blocksize0 –
the list of sums of the number of rows of the first column of blocks of M: blocksize0[i] = blocksize0[i-1] + ni, ni being the number of rows of the block at row i
*blocksize1 –
the list of sums of the number of columns of the first row of blocks of M: blocksize1[i] = blocksize1[i-1] + ni, ni being the number of columns of the block at column i
filled1 – index of the last non empty line + 1
filled2 – number of non null blocks
index1_data – index1_data is of size equal to number of non empty lines + 1. A block with number blockNumber inside a row numbered rowNumber verify index1_data[rowNumber]<= blockNumber <index1_data[rowNumber+1]`
index2_data – index2_data is of size filled2 index2_data[blockNumber] -> columnNumber.
Related functions: SBM_gemv(), SBM_row_prod(), SBM_clear(), SBM_print, SBM_diagonal_block_index()
Note: the sparse format is the same as the one used by Boost C++ library to store compressed sparse row matrices. The same member names have been adopted in order to simplify usage from Siconos Kernel : filled1, filled2, index1_data, index2_data. Reference : http://ublas.sourceforge.net/refdoc/classboost_1_1numeric_1_1ublas_1_1compressed__matrix.html
If we consider the matrix M and the right-hand-side q defined as
\[\begin{split}M=\left[\begin{array}{cccc|cc|cc} 1 & 2 & 0 & 4 & 3 &-1 & 0 & 0 \\ 2 & 1 & 0 & 0 & 4 & 1 & 0 & 0 \\ 0 & 0 & 1 &-1 & 0 & 0 & 0 & 0 \\ 5 & 0 &-1 & 6 & 0 & 6 & 0 & 0 \\ \hline 0 & 0 & 0 & 0 & 1 & 0 & 0 & 5 \\ 0 & 0 & 0 & 0 & 0 & 2 & 0 & 2 \\ \hline 0 & 0 & 2 & 1 & 0 & 0 & 2 & 2 \\ 0 & 0 & 2 & 2 & 0 & 0 & -1 & 2 \\ \end{array}\right] \quad, q=\left[\begin{array}{c}-1 \\ -1 \\ 0 \\ -1 \\ \hline 1 \\ 0 \\ \hline -1 \\ 2 \end{array}\right].\end{split}\]then
the number of non null blocks is 6 (nbblocks=6)
the number of rows of blocks is 3 (blocknumber0 =3) and the
number of columns of blocks is 3 (blocknumber1 =3) - the vector blocksize0 is equal to {4,6,8} and the vector blocksize1 is equal to {4,6,8} - the integer filled1 is equal to 4 - the integer filled2 is equal to 6 - the vector index1_data is equal to {0,2,4,6} - the vector index2_data is equal to {0,1,1,2,0,2} - the block contains all non null block matrices stored in Fortran order (column by column) as block[0] = {1,2,0,5,2,1,0,0,0,0,1,-1,4,0,-1,6} block[1] = {3,4,0,0,-1,1,0,6} … block[5] = {2,-1,2,2}
- property version#
version of storage
- siconos.numerics.SBM_new()[source]#
Creation of an empty Sparse Block Matrix.
- Return type:
- Returns:
a pointer on allocated and initialized space
- siconos.numerics.SBM_null(sbm)[source]#
set Sparse Block Matrix. fields to NULL
- Parameters:
sbm (
SparseBlockStructuredMatrix
) – a matrix
- siconos.numerics.SBM_gemv(sizeX, sizeY, alpha, A, x, beta, y)[source]#
SparseMatrix - vector product y = alpha*A*x + beta*y
- Parameters:
- siconos.numerics.SBM_gemv_3x3(sizeX, sizeY, A, x, y)[source]#
SparseMatrix - vector product y = A*x + y for block of size 3x3
- Parameters:
sizeX (int, in) – dim of the vectors x
sizeY (int, in) – dim of the vectors y
A (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedx (double, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
- siconos.numerics.SBM_gemm_without_allocation(alpha, A, B, beta, C)[source]#
SparseBlockStructuredMatrix - SparseBlockStructuredMatrix product C = alpha*A*B + beta*C The routine has to be used with precaution. The allocation of C is not done since we want to add beta*C. We assume that the structure and the allocation of the matrix C are right. Especially:
the blocks C(i,j) must exists
the sizes of blocks must be consistent
no extra block must be present in C
- Parameters:
alpha (float, in) – coefficient
A (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedB (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedbeta (float, in) – coefficient
C (
SparseBlockStructuredMatrix
, in/out) – the resulting matrix
- siconos.numerics.SBM_multiply(A, B)[source]#
SparseBlockStructuredMatrix - SparseBlockStructuredMatrix multiplication C = A *B Correct allocation is performed
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedB (
SparseBlockStructuredMatrix
, in) – the matrix to be multiplied
- Return type:
- Returns:
C the resulting matrix
- siconos.numerics.SBM_zero_matrix_for_multiply(A, B)[source]#
Perform the allocation of a zero matrix that is compatible qith multiplication
- siconos.numerics.SBM_add(A, B, alpha, beta)[source]#
SparseBlockStructuredMatrix - SparseBlockStructuredMatrix addition C = alpha*A + beta*B
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the matrix to be addedB (
SparseBlockStructuredMatrix
, in) – the matrix to be addedalpha (float, in) – coefficient
beta (float, in) – coefficient
- Return type:
- Returns:
C the resulting matrix
- siconos.numerics.SBM_add_without_allocation(A, B, alpha, beta, C, gamma)[source]#
SparseBlockStructuredMatrix - SparseBlockStructuredMatrix addition C = alpha*A + beta*B + gamma*C without allocation. We assume that C has the correct structure
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the matrix to be addedB (
SparseBlockStructuredMatrix
, in) – the matrix to be addedalpha (float, in) – coefficient
beta (float, in) – coefficient
gamma (float, in) – coefficient
C (
SparseBlockStructuredMatrix
, in/out) – the resulting matrix
- siconos.numerics.SBM_scal(alpha, A)[source]#
Multiply a matrix with a double alpha*A –> A
- Parameters:
alpha (float) – the coefficient
A (
SparseBlockStructuredMatrix
) – the matrix
- siconos.numerics.SBM_row_prod(sizeX, sizeY, currentRowNumber, A, x, y, init)[source]#
Row of a SparseMatrix - vector product y = rowA*x or y += rowA*x, rowA being a row of blocks of A
- Parameters:
sizeX (int, in) – dim of the vector x
sizeY (int, in) – dim of the vector y
currentRowNumber (int, in) – number of the required row of blocks
A (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedx (double, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
init (int, in) – = 0 for y += Ax, =1 for y = Ax
- siconos.numerics.SBM_row_prod_no_diag(sizeX, sizeY, currentRowNumber, A, x, y, init)[source]#
Row of a SparseMatrix - vector product y = rowA*x or y += rowA*x, rowA being a row of blocks of A
- Parameters:
sizeX (int, in) – dim of the vector x
sizeY (int, in) – dim of the vector y
currentRowNumber (int, in) – number of the required row of blocks
A (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedx (double, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
init (int, in) – = 0 for y += Ax, =1 for y = Ax
- siconos.numerics.SBM_row_prod_no_diag_3x3(sizeX, sizeY, currentRowNumber, A, x, y)[source]#
Row of a SparseMatrix - vector product y = rowA*x or y += rowA*x, rowA being a row of blocks of A of size 3x3
- Parameters:
sizeX (int, in) – dim of the vector x
sizeY (int, in) – dim of the vector y
currentRowNumber (int, in) – number of the required row of blocks
A (
SparseBlockStructuredMatrix
, in) – the matrix to be multipliedx (double, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
- siconos.numerics.SBM_clear(blmat)[source]#
Destructor for SparseBlockStructuredMatrix objects
- Parameters:
blmat (
SparseBlockStructuredMatrix
) – SparseBlockStructuredMatrix the matrix to be destroyed.
- siconos.numerics.SBMfree(A, level)[source]#
To free a SBM matrix (for example allocated by NM_new_from_file).
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix that mus be de-allocated.level (int, in) – use NUMERICS_SBM_FREE_BLOCK | NUMERICS_SBM_FREE_SBM
- siconos.numerics.SBM_print(m)[source]#
Screen display of the matrix content
- Parameters:
m (
SparseBlockStructuredMatrix
) – the matrix to be displayed
- siconos.numerics.SBM_write_in_file(m, file)[source]#
print in file of the matrix content
- Parameters:
m (
SparseBlockStructuredMatrix
) – the matrix to be displayedfile (FILE) – the corresponding file
- siconos.numerics.SBM_read_in_file(M, file)[source]#
read in file of the matrix content without performing memory allocation
- Parameters:
M (
SparseBlockStructuredMatrix
) – the matrix to be displayedfile (FILE) – the corresponding name of the file
- siconos.numerics.SBM_new_from_file(file)[source]#
Create from file a SparseBlockStructuredMatrix with memory allocation
- Parameters:
file (FILE) – the corresponding name of the file
- Return type:
- Returns:
the matrix to be displayed
- siconos.numerics.SBM_write_in_fileForScilab(M, file)[source]#
print in file of the matrix content in Scilab format for each block
- Parameters:
M (
SparseBlockStructuredMatrix
) – the matrix to be displayedfile (FILE) – the corresponding file
- siconos.numerics.SBM_write_in_filename(M, filename)[source]#
print in file of the matrix content
- Parameters:
M (
SparseBlockStructuredMatrix
) – the matrix to be displayedfilename (string) – the corresponding file
- siconos.numerics.SBM_read_in_filename(M, filename)[source]#
read in file of the matrix content
- Parameters:
M (
SparseBlockStructuredMatrix
) – the matrix to be displayedfilename (string) – the corresponding name of the file
- siconos.numerics.SBM_clear_pred(blmatpred)[source]#
Destructor for SparseBlockStructuredMatrixPred objects
- Parameters:
blmatpred (
SparseBlockStructuredMatrixPred
) – SparseBlockStructuredMatrix, the matrix to be destroyed.
- siconos.numerics.SBM_diagonal_block_indices(M)[source]#
Compute the indices of blocks of the diagonal block
- Parameters:
M (
SparseBlockStructuredMatrix
) – the SparseBlockStructuredMatrix matrix- Return type:
- Returns:
the indices for all the rows
- siconos.numerics.SBM_diagonal_block_index(M, row)[source]#
Find index of the diagonal block in a row
- Parameters:
M (
SparseBlockStructuredMatrix
) – the SparseBlockStructuredMatrix matrixrow (int) – the row of the required block
- Return type:
- Returns:
pos the position of the block
- siconos.numerics.SBM_entry(M, row, col, val)[source]#
insert an entry into a SparseBlockStructuredMatrix. This method is expensive in terms of memory management. For a lot of entries, use an alternative
- Parameters:
M (
SparseBlockStructuredMatrix
) – the SparseBlockStructuredMatrixi – row index
j – column index
val (float) – the value to be inserted.
- siconos.numerics.SBM_get_value(M, row, col)[source]#
get the element of row i and column j of the matrix M
- Parameters:
M (
SparseBlockStructuredMatrix
) – the SparseBlockStructuredMatrix matrixrow (int) – the row index
col (int) – the column index
- Return type:
- Returns:
the value
- siconos.numerics.SBM_copy(A, B, copyBlock)[source]#
Copy of a SBM A into B
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix matrix to be copiedB (
SparseBlockStructuredMatrix
, out) – the SparseBlockStructuredMatrix matrix copy of AcopyBlock (int, in) – if copyBlock then the content of block are copied, else only the pointers are copied.
- Return type:
- Returns:
0 if ok
- siconos.numerics.SBM_transpose(A, B)[source]#
Transpose by copy of a SBM A into B
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix matrix to be copiedB (
SparseBlockStructuredMatrix
, out) – the SparseBlockStructuredMatrix matrix copy of transpose A
- Return type:
- Returns:
0 if ok
- siconos.numerics.SBM_inverse_diagonal_block_matrix_in_place(M, ipiv)[source]#
Inverse (in place) a square diagonal block matrix
- Parameters:
M (
SparseBlockStructuredMatrix
, in/out) – the SparseBlockStructuredMatrix matrix to be inversedipiv (int) – worksapce for storign ipiv
- Return type:
- Returns:
0 ik ok
- siconos.numerics.SBM_to_dense(A)[source]#
Copy a SBM into a Dense Matrix
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix matrixdenseMat (float, in) – pointer on the filled dense Matrix
- siconos.numerics.SBM_to_sparse(A)[source]#
Copy a SBM into a Sparse (CSR) Matrix
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix matrixoutSparseMat (CSparseMatrix, in) – pointer on the filled sparse Matrix
- Return type:
- Returns:
0 if ok
- siconos.numerics.SBM_to_sparse_init_memory(A, sparseMat)[source]#
initMemory of a Sparse (CSR) Matrix form a SBM matrix
- Parameters:
A (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix matrixsparseMat (CSparseMatrix, in) – pointer on the initialized sparse Matrix
- Return type:
- Returns:
0 if ok
- siconos.numerics.SBM_row_permutation(rowIndex, A, C)[source]#
- Parameters:
[in] – rowIndex: permutation: the row numC of C is the row rowIndex[numC] of A.
[in] – A The source SBM.
[out] – C The target SBM. It assumes the structure SBM has been allocated. The memory allocation for its menber is done inside. NB : The blocks are not copied.
- siconos.numerics.SBM_column_permutation(colIndex, A, C)[source]#
- Parameters:
[in] – colIndex: permutation: the col numC of C is the col colIndex[numC] of A.
[in] – A The source SBM.
[out] – C The target SBM. It assumes the structure SBM has been allocated. The memory allocation for its menber is done inside. NB : The blocks are not copied.
- siconos.numerics.SBCM_new_3x3(m, n, nbblocks, row, column, block)[source]#
allocate a SparseBlockCoordinateMatrix from a list of 3x3 blocks
- Parameters:
- Return type:
SparseBlockCoordinateMatrix
- Returns:
a pointer to a SparseBlockCoordinateMatrix structure
- siconos.numerics.SBCM_free_3x3(MC)[source]#
free allocated memory in newSparseBlockCoordinateMatrix functions
- Parameters:
MC (
SparseBlockCoordinateMatrix
, in) – matrix pointer
- siconos.numerics.SBCM_to_SBM(MC)[source]#
copy a SparseBlockCoordinateMatrix to a SparseBlockStructuredMatrix
- Parameters:
MC (
SparseBlockCoordinateMatrix
, in) – the SparseBlockCoordinateMatrix matrix- Return type:
- Returns:
a pointer to a SparseBlockCoordinateMatrix structure
- siconos.numerics.SBM_free_from_SBCM(M)[source]#
free a SparseBlockStructuredMatrix created with SBCM_to_SBM
- Parameters:
M (
SparseBlockStructuredMatrix
, in/out) – a SparseBlockStructuredMatrix to free
- siconos.numerics.SBM_from_csparse(blocksize, sparseMat)[source]#
Copy a Sparse Matrix into a SBM, with fixed blocksize
- Parameters:
blocksize (int, in) – the blocksize
sparseMat (CSparseMatrix, in) – pointer on the Sparse Matrix
outSBM (
SparseBlockStructuredMatrix
, in/out) – pointer on an empty SparseBlockStructuredMatrix
- Return type:
- Returns:
0 in ok
- class siconos.numerics.NumericsMatrixInternalData[source]#
Bases:
object
Structure for simple workspaces
- property iWorkSize#
size of iWork
- property iWork#
integer workspace
- property sizeof_elt#
sizeof_elt of an element in bytes (result of sizeof for instance)
- property dWorkSize#
size of dWork
- property dWork#
double workspace
- property isLUfactorized#
true if the matrix has already been LU-factorized
- property isCholeskyfactorized#
true if the matrix has already been Cholesky factorized
- property isLDLTfactorized#
true if the matrix has already been LDLT factorized
- property isInversed#
true if the matrix contains its inverse (in place inversion)
- siconos.numerics.NM_DENSE = 0#
dense format
- siconos.numerics.NM_SPARSE_BLOCK = 1#
sparse block format
- siconos.numerics.NM_SPARSE = 2#
compressed column format
- siconos.numerics.NM_UNKNOWN = 3#
unset. Used in NM_null
- class siconos.numerics.NumericsMatrix(o)[source]#
Bases:
object
Interface to different type of matrices in numerics component.
See NM_* functions for linear algebra operations on dense, sparse block and sparse storage.
- property storageType#
the type of storage: 0: dense (double*), 1: SparseBlockStructuredMatrix, 2: classical sparse (csc, csr or triplet) via CSparse (from T. Davis)
- property size0#
number of rows
- property size1#
number of columns
- property matrix0#
dense storage
- property matrix1#
sparse block storage
- property matrix2#
csc, csr or triplet storage
- property internalData#
internal storage, used for workspace among other things
- property destructible#
pointer on the destructible matrix, by default points toward the matrix itself
- siconos.numerics.NM_NONE = 0#
keep nothing
- siconos.numerics.NM_KEEP_FACTORS = 1#
keep all the factorization data (useful to reuse the factorization)
- siconos.numerics.NM_PRESERVE = 2#
keep the matrix as-is (useful for the dense case)
- siconos.numerics.NM_new()[source]#
Constructors and destructors *********** Creation of an empty NumericsMatrix.
- Return type:
RawNumericsMatrix
- Returns:
a pointer to allocated space
- siconos.numerics.NM_create(storageType, size0, size1)[source]#
create a NumericsMatrix and allocate the memory according to the matrix type
- siconos.numerics.NM_create_from_data(storageType, size0, size1, data)[source]#
create a NumericsMatrix and possibly set the data
- siconos.numerics.NM_version_copy(A, B)[source]#
Copy NumericsMatrix version.
- Parameters:
A (
NumericsMatrix
, in) – a NumericsMatrixB (
NumericsMatrix
, in/out) – a NumericsMatrix
- siconos.numerics.NM_copy(A, B)[source]#
Copy a NumericsMatrix inside another NumericsMatrix (deep). Reallocations are performed if B cannot hold a copy of A
- Parameters:
A (
NumericsMatrix
, in) – a NumericsMatrixB (
NumericsMatrix
, in/out) – a NumericsMatrix
- siconos.numerics.NM_copy_to_sparse(A, B, threshold)[source]#
Copy a NumericsMatrix to s sparse one. Allocation or reallocation are performed on B Warning: It is assumed that B has been properly initialized: its storageType must be set to NM_SPARSE.
- Parameters:
A (
NumericsMatrix
, in) – a NumericsMatrixB (
NumericsMatrix
, in/out) – a NumericsMatrixthreshold (float) – if the original matrix is dense, a threshold can be applied on the absolute value of the entries
- siconos.numerics.NM_duplicate(mat)[source]#
create a NumericsMatrix similar to the another one. The structure is the same
- Parameters:
mat (
NumericsMatrix
) – the model matrix- Return type:
RawNumericsMatrix
- Returns:
a pointer to a NumericsMatrix
- siconos.numerics.numericsSparseMatrix(A)[source]#
Creation, if needed, of sparse matrix storage.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix- Return type:
- Returns:
a pointer on the sparse matrix storage
- siconos.numerics.NM_triplet(A)[source]#
Creation, if needed, of triplet storage from sparse block storage.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix initialized with sparsed block storage.- Return type:
CSparseMatrix
- Returns:
the triplet sparse Matrix created in A.
- siconos.numerics.NM_half_triplet(A)[source]#
Creation, if needed, of half triplet storage from sparse block storage.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix initialized with sparsed block storage.- Return type:
CSparseMatrix
- Returns:
the triplet sparse Matrix created in A.
- siconos.numerics.NM_csc(A)[source]#
Creation, if needed, of compress column storage of a NumericsMatrix.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix with sparse block storage initialized- Return type:
CSparseMatrix
- Returns:
the compressed column CSparseMatrix created in A.
- siconos.numerics.NM_csc_trans(A)[source]#
Creation, if needed, of the transposed compress column storage from compress column storage.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix with sparse block storage.- Return type:
CSparseMatrix
- Returns:
the transposed compressed column matrix created in A.
- siconos.numerics.NM_csr(A)[source]#
Creation, if needed, of compress row storage of a NumericsMatrix Warning: This rely on the MKL
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix with sparse block storage initialized- Return type:
CSparseMatrix
- Returns:
the compressed row CSparseMatrix created in A.
- siconos.numerics.NM_fill(M, storageType, size0, size1, data)[source]#
fill an existing NumericsMatrix struct
- Parameters:
M (
NumericsMatrix
, in/out) – the struct to fillstorageType (int) – the type of storage
size0 (int) – number of rows
size1 (int) – number of columns
data (void) – pointer to the matrix data. If NULL, all matrixX fields are set to NULL
- siconos.numerics.NM_new_SBM(size0, size1, m1)[source]#
new NumericsMatrix with sparse storage from minimal set of data
- Parameters:
size0 (int, in) – number of rows
size1 (int, in) – number of columns
m1 (
SparseBlockStructuredMatrix
, in) – the SparseBlockStructuredMatrix
- Return type:
RawNumericsMatrix
- Returns:
a pointer to a NumericsMatrix
- siconos.numerics.NM_transpose(A)[source]#
new NumericsMatrix equal to the transpose of a given matrix
- Parameters:
A (
NumericsMatrix
, in) –- Return type:
RawNumericsMatrix
- Returns:
a pointer to a NumericsMatrix
- siconos.numerics.NM_null(A)[source]#
set NumericsMatrix fields to NULL
- Parameters:
A (
NumericsMatrix
) – a matrix
- siconos.numerics.NM_destructible(A)[source]#
Check if a matrix is destructible.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
boolean
- Returns:
true if the matrix is destructible
- siconos.numerics.NM_preserve(A)[source]#
Preservation of a matrix before in-place transformations such as factorizations.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
RawNumericsMatrix
- Returns:
a pointer on the preserved Matrix;
- siconos.numerics.NM_unpreserve(A)[source]#
Set the matrix as destructible, clear the preserved data.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
RawNumericsMatrix
- Returns:
a pointer on the Matrix;
- siconos.numerics.NM_LU_factorized(A)[source]#
Check for a previous LU factorization.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
boolean
- Returns:
true if the matrix has been LU factorized.
- siconos.numerics.NM_Cholesky_factorized(A)[source]#
Check for a previous Cholesky factorization.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
boolean
- Returns:
true if the matrix has been Cholesky factorized.
- siconos.numerics.NM_LDLT_factorized(A)[source]#
Check for a previous LDLT factorization.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
boolean
- Returns:
true if the matrix has been Cholesky factorized.
- siconos.numerics.NM_set_LU_factorized(A, flag)[source]#
Set the factorization flag.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix,flag (boolean, in) – a boolean.
- siconos.numerics.NM_update_size(A)[source]#
update the size of the matrix based on the matrix data
- Parameters:
A (
NumericsMatrix
, in/out) – the matrix which size is updated
- siconos.numerics.NM_csc_alloc(A, nzmax)[source]#
Allocate a csc matrix in A
- Parameters:
A (
NumericsMatrix
) – the matrixnzmax (int) – number of non-zero elements
- siconos.numerics.NM_csc_empty_alloc(A, nzmax)[source]#
Allocate a csc matrix in A and set the vector of column pointers to 0 such that the matrix is empty.
- Parameters:
A (
NumericsMatrix
) – the matrixnzmax (int) – number of non-zero elements
- siconos.numerics.NM_triplet_alloc(A, nzmax)[source]#
Allocate a triplet matrix in A
- Parameters:
A (
NumericsMatrix
) – the matrixnzmax (int) – maximum number of non-zero elements
- siconos.numerics.NM_clear(m)[source]#
Free memory for a NumericsMatrix. Warning: call this function only if you are sure that memory has been allocated for the structure in Numerics. This function is assumed that the memory is “owned” by this structure. Note that this function does not free m.
- Parameters:
m (
NumericsMatrix
) – the matrix to be deleted.
- siconos.numerics.NM_clear_not_dense(m)[source]#
Free memory for a NumericsMatrix except the dense matrix that is assumed not to be owned.
- Parameters:
m (
NumericsMatrix
) – the matrix to be cleared.
- siconos.numerics.NM_clear_not_SBM(m)[source]#
Free memory for a NumericsMatrix except the SBM matrix that is assumed not to be owned. Note that this function does not free m.
- Parameters:
m (
NumericsMatrix
) – the matrix to be cleared.
- siconos.numerics.NM_clear_other_storages(M, storageType)[source]#
- Free memory for a NumericsMatrix except for a given storage. Warning: call this function only if you are sure that
memory has been allocated for the structure in Numerics. This function is assumed that the memory is “owned” by this structure. Note that this function does not free m.
- param m:
the matrix to be deleted.
- type storageType:
int
- param storageType:
to be kept.
- siconos.numerics.NM_zentry(M, i, j, val, threshold)[source]#
insert an non zero entry into a NumericsMatrix. for storageType = NM_SPARSE, a conversion to triplet is done for performing the entry in the matrix. This method is expensive in terms of memory management. For a lot of entries, use preferably a triplet matrix.
- Parameters:
M (
NumericsMatrix
) – the NumericsMatrixi (int) – row index
j (int) – column index
val (float) – the value to be inserted.
threshold (float) – a threshold to filter the small value in magnitude (useful for dense to sparse conversion)
- siconos.numerics.NM_entry(M, i, j, val)[source]#
insert an entry into a NumericsMatrix. for storageType = NM_SPARSE, a conversion to triplet is done for performing the entry in the matrix. This method is expensive in terms of memory management. For a lot of entries, use preferably a triplet matrix.
- Parameters:
M (
NumericsMatrix
) – the NumericsMatrixi (int) – row index
j (int) – column index
val (float) – the value to be inserted.
- siconos.numerics.NM_get_value(M, i, j)[source]#
get the value of a NumericsMatrix.
- Parameters:
M (
NumericsMatrix
) – the NumericsMatrixi (int) – row index
j (int) – column index
- Return type:
- Returns:
the value to be inserted.
- siconos.numerics.NM_equal(A, B)[source]#
compare to NumericsMatrix up to machine accuracy (DBL_EPSILON)
- Parameters:
A (
NumericsMatrix
) – the NumericsMatrixB (
NumericsMatrix
) – the NumericsMatrix
- siconos.numerics.NM_compare(A, B, tol)[source]#
compare to NumericsMatrix up to a given tolerance
- Parameters:
A (
NumericsMatrix
) – the NumericsMatrixB (
NumericsMatrix
) – the NumericsMatrixtol (float) – the tolerance
- siconos.numerics.NM_nnz(M)[source]#
return the number of non-zero element. For a dense matrix, it is the product of the dimensions (e.g. an upper bound). For a sparse matrix, it is the true number
- Parameters:
M (
NumericsMatrix
) – the matrix- Return type:
- Returns:
the number (or an upper bound) of non-zero elements in the matrix
- siconos.numerics.NM_extract_diag_block(M, block_row_nb, start_row, size, Block)[source]#
get the (square) diagonal block of a NumericsMatrix. No allocation is done.
- Parameters:
M (
NumericsMatrix
, in) – a NumericsMatrixblock_row_nb (int, in) – the number of the block Row. Useful only in sparse case
start_row (int, in) – the starting row. Useful only in dense case.
size (int, in) – of the diag block. Only useful in dense case.
Block (float, out) – the target. In the dense and sparse case (*Block) must be allocated by caller. In case of SBM case **Bout contains the resulting block (from the SBM).
- siconos.numerics.NM_extract_diag_block3(M, block_row_nb, Block)[source]#
get a 3x3 diagonal block of a NumericsMatrix. No allocation is done.
- Parameters:
M (
NumericsMatrix
, in) – a NumericsMatrixblock_row_nb (int, in) – the number of the block row
Block (float, out) – the target. In the dense and sparse case (*Block) must be allocated by caller. In case of SBM case **Bout contains the resulting block (from the SBM).
- siconos.numerics.NM_extract_diag_block2(M, block_row_nb, Block)[source]#
get a 2x2 diagonal block of a NumericsMatrix. No allocation is done.
- Parameters:
M (
NumericsMatrix
, in) – a NumericsMatrixblock_row_nb (int, in) – the number of the block row
Block (float, out) – the target. In the dense and sparse case (*Block) must be allocated by caller. In case of SBM case **Bout contains the resulting block (from the SBM).
- siconos.numerics.NM_extract_diag_block5(M, block_row_nb, Block)[source]#
get a 5x5 diagonal block of a NumericsMatrix. No allocation is done.
- Parameters:
M (
NumericsMatrix
, in) – a NumericsMatrixblock_row_nb (int, in) – the number of the block row
Block (float, out) – the target. In the dense and sparse case (*Block) must be allocated by caller. In case of SBM case **Bout contains the resulting block (from the SBM).
- siconos.numerics.NM_copy_diag_block3(M, block_row_nb, Block)[source]#
get a 3x3 diagonal block of a NumericsMatrix. No allocation is done.
- Parameters:
M (
NumericsMatrix
, in) – a NumericsMatrixblock_row_nb (int, in) – the number of the block row
Block (float, out) – the target. In all cases (dense, sbm, and sparse) (*Block) must be allocated by caller. A copy is always performed
- siconos.numerics.NM_insert(A, B, start_i, start_j)[source]#
Set the submatrix B into the matrix A on the position defined in (start_i, start_j) position.
- Parameters:
A (
NumericsMatrix
, in) – a pointer to NumerixMatrixB (
NumericsMatrix
, in) – a pointer toNumericsMatrixstart_i (int, in) – a start row index
start_j (int, in) – a start column index
- siconos.numerics.NM_prod_mv_3x3(sizeX, sizeY, A, x, y)[source]#
Matrix - vector product y = A*x + y
- Parameters:
sizeX (int, in) – dim of the vector x
sizeY (int, in) – dim of the vector y
A (
NumericsMatrix
, in) – the matrix to be multipliedx (double, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
- siconos.numerics.NM_row_prod(sizeX, sizeY, currentRowNumber, A, x, y, init)[source]#
Row of a Matrix - vector product y = rowA*x or y += rowA*x, rowA being a submatrix of A (sizeY rows and sizeX columns)
- Parameters:
sizeX (int, in) – dim of the vector x
sizeY (int, in) – dim of the vector y
currentRowNumber (int, in) – position of the first row of rowA in A (warning: real row if A is a double*, block-row if A is a SparseBlockStructuredMatrix)
A (
NumericsMatrix
, in) – the matrix to be multipliedx (double, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
init (int, in) – = 0 for y += Ax, =1 for y = Ax
- siconos.numerics.NM_row_prod_no_diag(sizeX, sizeY, block_start, row_start, A, x, y, xsave, init)[source]#
Row of a Matrix - vector product y = rowA*x or y += rowA*x, rowA being a submatrix of A (sizeY rows and sizeX columns)
- Parameters:
sizeX (int, in) – dim of the vector x
sizeY (int, in) – dim of the vector y
block_start (int, in) – block number (only used for SBM)
row_start (int, in) – position of the first row of A (unused if A is SBM)
A (
NumericsMatrix
, in) – the matrix to be multipliedx (float, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
xsave (float, in) – storage for saving the part of x set to 0
init (boolean, in) – if True y = Ax, else y += Ax
- siconos.numerics.NM_row_prod_no_diag3(sizeX, block_start, row_start, A, x, y, init)[source]#
Row of a Matrix - vector product y = rowA*x or y += rowA*x, rowA being a submatrix of A (3 rows and sizeX columns)
- Parameters:
sizeX (int, in) – dim of the vector x
block_start (int, in) – block number (only used for SBM)
row_start (int, in) – position of the first row of A (unused if A is SBM)
A (
NumericsMatrix
, in) – the matrix to be multipliedx (float, in) – the vector to be multiplied
y (float, in/out) – the resulting vector
init (boolean, in) – if True y = Ax, else y += Ax
- siconos.numerics.NM_row_prod_no_diag2(sizeX, block_start, row_start, A, x, y, init)[source]#
- Row of a Matrix - vector product y = rowA*x or y += rowA*x, rowA being a submatrix of A (2 rows and sizeX columns)
- type sizeX:
int, in
- param sizeX:
dim of the vector x
- type block_start:
int, in
- param block_start:
block number (only used for SBM)
- type row_start:
int, in
- param row_start:
position of the first row of A (unused if A is SBM)
- type A:
NumericsMatrix
, in- param A:
the matrix to be multiplied
- type x:
float, in
- param x:
the vector to be multiplied
- type y:
float, in/out
- param y:
the resulting vector
- type init:
boolean, in
- param init:
if True y = Ax, else y += Ax
- siconos.numerics.NM_gemv(alpha, A, x, beta, y)[source]#
Matrix vector multiplication : y = alpha A x + beta y
- Parameters:
alpha (float, in) – scalar
A (
NumericsMatrix
, in) – a NumericsMatrixx (float, in) – pointer on a dense vector of size A->size1
beta (float, in) – scalar
y (float, in/out) – pointer on a dense vector of size A->size1
- siconos.numerics.NM_gemm(alpha, A, B, beta, C)[source]#
Matrix matrix multiplication : C = alpha A B + beta C
- Parameters:
alpha (float, in) – scalar
A (
NumericsMatrix
, in) – a NumericsMatrixB (
NumericsMatrix
, in) – a NumericsMatrixbeta (float, in) – scalar
C (
NumericsMatrix
, in/out) – a NumericsMatrix
- siconos.numerics.NM_multiply(A, B)[source]#
Matrix matrix multiplication : C = A B
- Parameters:
A (
NumericsMatrix
, in) – a NumericsMatrixB (
NumericsMatrix
, in) – a NumericsMatrixC – a NumericsMatrix
- siconos.numerics.NM_tgemv(alpha, A, x, beta, y)[source]#
Transposed matrix multiplication : y += alpha transpose(A) x + y
- Parameters:
alpha (float, in) – scalar
A (
NumericsMatrix
, in) – a NumericsMatrixx (float, in) – pointer on a dense vector of size A->size1
beta (float, in) – scalar
y (float, in/out) – pointer on a dense vector of size A->size1
- siconos.numerics.NM_to_dense(A, B)[source]#
Copy a NumericsMatrix into another with dense storage.
- Parameters:
A (
NumericsMatrix
) – source matrix (any kind of storage)B (
NumericsMatrix
) – targeted matrix, must be dense with the same dimension as A
- siconos.numerics.NM_dense_display_matlab(m, nRow, nCol, lDim)[source]#
Screen display of the matrix content stored as a double * array in Fortran style
- siconos.numerics.NM_dense_display(m, nRow, nCol, lDim)[source]#
Screen display of the matrix content stored as a double * array in Fortran style
- siconos.numerics.NM_vector_display(m, nRow)[source]#
Screen display of the vector content stored as a double * array
- siconos.numerics.NM_display(M)[source]#
Screen display of the matrix content
- Parameters:
M (
NumericsMatrix
) – the matrix to be displayed
- siconos.numerics.NM_display_storageType(M)[source]#
Screen display of the matrix storage
- Parameters:
M (
NumericsMatrix
) – the matrix to be displayed
- siconos.numerics.NM_display_row_by_row(m)[source]#
Screen display raw by raw of the matrix content
- Parameters:
m (
NumericsMatrix
) – the matrix to be displayed
- siconos.numerics.NM_write_in_filename(M, filename)[source]#
- matrix I/O ****************
PrintInFile of the matrix content
- type M:
- param M:
the matrix to be printed
- type filename:
string
- param filename:
the corresponding name of the file
- siconos.numerics.NM_read_in_filename(M, filename)[source]#
Read in file of the matrix content
- Parameters:
M (
NumericsMatrix
) – the matrix to be readfilename (string) – the corresponding name of the file
- siconos.numerics.NM_write_in_file(M, file)[source]#
PrintInFile of the matrix content
- Parameters:
M (
NumericsMatrix
) – the matrix to be printedfile (FILE) – filename the corresponding file
- siconos.numerics.NM_read_in_file(M, file)[source]#
Read in file of the matrix content without performing memory allocation
- Parameters:
M (
NumericsMatrix
) – the matrix to be readfile (FILE) – the corresponding file
- siconos.numerics.NM_new_from_file(file)[source]#
Create from file a NumericsMatrix with memory allocation
- Parameters:
file (FILE) – the corresponding file
- Return type:
RawNumericsMatrix
- Returns:
0 if the matrix
- siconos.numerics.NM_write_in_file_scilab(M, file)[source]#
NM_write_in_file_scilab of the matrix content
- Parameters:
M (
NumericsMatrix
) – the matrix to be printedfile (FILE) – the corresponding file
- siconos.numerics.NM_write_in_file_python(M, file)[source]#
NM_write_in_file_python of the matrix content
- Parameters:
M (
NumericsMatrix
) – the matrix to be printedfile (FILE) – the corresponding file
- siconos.numerics.NM_read_in_file_scilab(M, file)[source]#
Read in file for scilab of the matrix content
- Parameters:
M (
NumericsMatrix
) – the matrix to be readfile (FILE) – the corresponding file
- siconos.numerics.NM_clearDense(A)[source]#
Clear dense storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearSparseBlock(A)[source]#
Clear sparse block storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearSparse(A)[source]#
Clear sparse data, if it is existent. The linear solver parameters are also cleared.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearTriplet(A)[source]#
Clear triplet storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearHalfTriplet(A)[source]#
Clear half triplet storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearCSC(A)[source]#
Clear compressed column storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearCSCTranspose(A)[source]#
Clear transposed compressed column storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearCSR(A)[source]#
Clear compressed row storage, if it is existent.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_clearSparseStorage(A)[source]#
Clear triplet, csc, csc transposed storage, if they are existent. Linear solver parameters are preserved.
- Parameters:
A (
NumericsMatrix
, in/out) – a Numericsmatrix
- siconos.numerics.NM_LU_factorize(A)[source]#
LU factorization of the matrix. If the matrix has already been factorized (i.e if NM_LU_factorized(A) return true), nothing is done. To force a new factorization one has to set factorization flag to false : NM_set_LU_factorized(A, false) before the call to NM_LU_factorize. If the matrix is preserved, that means that a call to NM_preserve(A) has been done before the call to NM_LU_factorize, it is not destroyed, but the factorized part remains accessible for subsequent calls to NM_LU_solve. If the matrix is not preserved, then it is replaced by the factorized part.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix- Return type:
- Returns:
an int, 0 means the matrix has been factorized.
- siconos.numerics.NM_LU_solve(A, b, nrhs)[source]#
Solve linear system with multiple right hand size. A call to NM_LU_factorize is done at the beginning.
- Parameters:
A (
NumericsMatrix
, in) – the NumericsMatrix. A is not destroyed if it has been preserved by a call to NM_preserve(A).b (float, in/out) – the right hand size which is a pointer on a matrix of double. It is replaced by the solutions
nrhs (int, in) – the number of right hand side.
- Return type:
- Returns:
0 if the solve succeeded.
- siconos.numerics.NM_LU_inv(A)[source]#
Computation of the inverse of a NumericsMatrix A usinf NM_gesv_expert
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix.- Return type:
- Returns:
the matrix inverse.
- siconos.numerics.NM_inverse_diagonal_block_matrix(A, block_number, blocksizes)[source]#
Computation of the inverse of a NumericsMatrix A composed of diagonal blocks
for each block a dense inverse is performed and then inserted into the global inverse :type A:
NumericsMatrix
, in :param A: a NumericsMatrix. :type block_number: int, in :param block_number: the number of blocks :param blocksize: the sizes of diagonal blocks :rtype:NumericsMatrix
:return: the matrix inverse.
- siconos.numerics.NM_gesv(A, b, preserve)[source]#
Direct computation of the solution of a real system of linear equations: A x = b.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix. On a dense factorisation A.iWork is initialized.b (float, in/out) – pointer on a dense vector of size A->size1
preserve (boolean) – preserve the original matrix data. Only useful in the dense case, where the LU factorization is done in-place.
- Return type:
- Returns:
0 if successful, else the error is specific to the backend solver used
- siconos.numerics.NM_gesv_inv(A)[source]#
Computation of the inverse of a NumericsMatrix A usinf NM_gesv_expert
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix.- Return type:
- Returns:
the matrix inverse.
- siconos.numerics.NM_setSparseSolver(A, solver_id)[source]#
Set the linear solver
- Parameters:
A (
NumericsMatrix
) – the matrixsolver_id (int) – id of the solver
- siconos.numerics.NM_internalData(A)[source]#
Get Matrix internal data with initialization if needed.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix.- Return type:
- Returns:
a pointer on internal data.
- siconos.numerics.NM_internalData_new(M)[source]#
Allocate the internalData structure (but not its content!)
- Parameters:
M (
NumericsMatrix
) – the matrix to modify
- siconos.numerics.NM_internalData_copy(A, B)[source]#
Copy the internalData structure
- Parameters:
M – the matrix to modify
- siconos.numerics.NM_iWork(A, size, sizeof_elt)[source]#
Integer work vector initialization, if needed.
- Parameters:
A (
NumericsMatrix
, in/out) – pointer on a NumericsMatrix.size (int, in) – number of element to allocate
sizeof_elt (int, in) – of an element in bytes (result of sizeof for instance)
- Return type:
void
- Returns:
pointer on A->iWork allocated space of with the right size
- siconos.numerics.NM_dWork(A, size)[source]#
Double workspace initialization, if needed.
- Parameters:
A (
NumericsMatrix
, in/out) – pointer on a NumericsMatrix.size (int, in) – the size of needed space.
- Return type:
- Returns:
pointer on A->dWork allocated space of with the right size
- siconos.numerics.NM_add_to_diag3(M, alpha)[source]#
Add a constant term to the diagonal elements, when the block of the SBM are 3x3
- Parameters:
M (
NumericsMatrix
) – the matrixalpha (float) – the term to add
- siconos.numerics.NM_add_to_diag5(M, alpha)[source]#
Add a constant term to the diagonal elements, when the block of the SBM are 5x5
- Parameters:
M (
NumericsMatrix
) – the matrixalpha (float) – the term to add
- siconos.numerics.NM_add(alpha, A, beta, B)[source]#
Add two matrices with coefficients C = alpha*A + beta*B
- Parameters:
alpha (float) – the first coefficient
A (
NumericsMatrix
) – the first matrixbeta (float) – the second coefficient
B (
NumericsMatrix
) – the second matrix
- Return type:
RawNumericsMatrix
- Returns:
C a new NumericsMatrix
- siconos.numerics.NM_scal(alpha, A)[source]#
Multiply a matrix with a double alpha*A –> A
- Parameters:
alpha (float) – the coefficient
A (
NumericsMatrix
) – the matrix
- siconos.numerics.NM_assert(type, M)[source]#
assert that a NumericsMatrix has the right structure given its type
- Parameters:
type (int) – expected type
M (
NumericsMatrix
) – the matrix to check
- siconos.numerics.NM_check(A)[source]#
Check the matrix (the sparse format for now)
- Parameters:
A (
NumericsMatrix
) – the matrix to check- Return type:
- Returns:
0 if the matrix storage is fine, 1 if not
- siconos.numerics.NM_norm_1(A)[source]#
Compute the 1-norm of a sparse matrix = max (sum (abs (A))), largest column sum of a matrix (the sparse format for now)
- Parameters:
A (
NumericsMatrix
) – the matrix- Return type:
- Returns:
the norm
- siconos.numerics.NM_norm_inf(A)[source]#
Compute the inf-norm of a sparse matrix = max (sum (abs (A^T))), largest row sum of a matrix (the sparse format for now)
- Parameters:
A (
NumericsMatrix
) – the matrix- Return type:
- Returns:
the norm
- siconos.numerics.NM_convert(A)[source]#
Pass a NumericsMatrix through swig typemaps. This is only useful in python.
- Parameters:
A (
NumericsMatrix
) – the matrix- Return type:
- Returns:
a NumericsMatrix
- siconos.numerics.NM_iterated_power_method(A, tol, itermax)[source]#
Compute the maximum eigenvalue with the iterated power method
- Parameters:
A (
NumericsMatrix
) – the matrix- Return type:
- Returns:
the maximum eigenvalue
- siconos.numerics.NM_max_by_columns(A, max)[source]#
Compute the maximum values by columns
- Parameters:
A (
NumericsMatrix
) – the matrixmax (float) – the vector of max that must be preallocated
- Return type:
- Returns:
info
- siconos.numerics.NM_max_by_rows(A, max)[source]#
Compute the maximum values by rows
- Parameters:
A (
NumericsMatrix
) – the matrixmax (float) – the vector of max that must be preallocated
- Return type:
- Returns:
info
- siconos.numerics.NM_max_abs_by_columns(A, max)[source]#
Compute the maximum absolute values by columns
- Parameters:
A (
NumericsMatrix
) – the matrixmax (float) – the vector of max that must be preallocated
- Return type:
- Returns:
info
- siconos.numerics.NM_max_abs_by_rows(A, max)[source]#
Compute the maximum absolute values by rows
- Parameters:
A (
NumericsMatrix
) – the matrixmax (float) – the vector of max that must be preallocated
- Return type:
- Returns:
info
- siconos.numerics.NM_compute_balancing_matrices(A, tol, itermax, B)[source]#
Compute the balancing matrices for a given matrix by iteration
- Parameters:
A (
NumericsMatrix
) – the matrixtol (float) – tolerance on the balanced matrix
itermax (int) – max number of iterations
alloated – structure for the balancing matrices and the balanced matrix
- Return type:
- Returns:
0 if succeed.
- siconos.numerics.NM_BalancingMatrices_new(A)[source]#
Create a Balancing Matrices structure
- Parameters:
A (
NumericsMatrix
) – the matrix to be balanced
- siconos.numerics.NM_reset_version(M, id)[source]#
Reset the version of a NM_types storage.
- Parameters:
M (
NumericsMatrix
) – the NumericsMatrix,id (int) – the NM_types storage
- siconos.numerics.NM_reset_versions(M)[source]#
Reset versions of all storages.
- Parameters:
M (
NumericsMatrix
) – the NumericsMatrix
- class siconos.numerics.linalg_data_t[source]#
Bases:
object
generic data struct for linear algebra operations
- class siconos.numerics.NSM_linear_solver_params[source]#
Bases:
object
solver-specific parameters
- property linear_solver_data#
solver-specific data (or workspace)
- property solver_free_hook#
solver-specific hook to free linear_solver_data
- property iWork#
integer work vector array (internal)
- property iWorkSize#
size of integer work vector array
- property linalg_data#
data for the linear algebra
- class siconos.numerics.NumericsSparseMatrix[source]#
Bases:
object
Sparse matrix representation in Numerics. The supported format are: triplet (aka coordinate, COO), CSC (via CSparse) and CSR if MKL is used
- property triplet#
triplet format, aka coordinate
- property half_triplet#
half triplet format for symmetric matrices
- property csc#
csc matrix
- property trans_csc#
transpose of a csc matrix (used by CSparse)
- property csr#
csr matrix, only supported with mkl
- property diag_indx#
indices for the diagonal terms. Very useful for the proximal perturbation
- property origin#
original format of the matrix
- property linearSolverParams#
solver-specific parameters
- siconos.numerics.NSM_null(A)[source]#
Initialize the fields of a NumericsSparseMatrix
- Parameters:
A (
NumericsSparseMatrix
) – the sparse matrix
- siconos.numerics.NSM_new()[source]#
New and empty NumericsSparseMatrix with correctly initialized fields.
- Return type:
- Returns:
a pointer on the allocated space.
- siconos.numerics.NSM_clear(A)[source]#
Free allocated space for a NumericsSparseMatrix.
- Parameters:
A (
NumericsSparseMatrix
) – a NumericsSparseMatrix- Return type:
- Returns:
NULL on success
- siconos.numerics.NSM_version_copy(A, B)[source]#
Copy NumericsSparseMatrix version.
- Parameters:
A (
NumericsSparseMatrix
) – a NumericsSparseMatrixB (
NumericsSparseMatrix
) – a NumericsSparseMatrix
- siconos.numerics.NSM_copy(A, B)[source]#
Copy a NumericsSparseMatrix.
- Parameters:
A (
NumericsSparseMatrix
) – a NumericsSparseMatrixB (
NumericsSparseMatrix
) – a NumericsSparseMatrix
- siconos.numerics.NSM_clear_p(p)[source]#
Free a workspace related to a LU factorization
- Parameters:
p (void) – the structure to free
- siconos.numerics.NSM_data(A)[source]#
Get the data part of sparse matrix
- Parameters:
A (
NumericsSparseMatrix
) – the sparse matrix- Return type:
- Returns:
a pointer to the data array
- siconos.numerics.NSM_linear_solver_data(p)[source]#
Get the LU factors for cs_lusol
- Parameters:
p (
NSM_linear_solver_params
) – the structure holding the data for the solver
- siconos.numerics.NSM_workspace(p)[source]#
Get the workspace for the sparse solver
- Parameters:
p (
NSM_linear_solver_params
) – the structure holding the data for the solver- Return type:
- Returns:
the (double) workspace
- siconos.numerics.NSM_nnz(A)[source]#
get the number of non-zero (nnz) in a sparse matrix
- Parameters:
A (CSparseMatrix) – the matrix
- Return type:
- Returns:
the number of non-zero elements in the matrix
- siconos.numerics.NSM_diag_indices(M)[source]#
return the set of indices corresponding to the diagonal elements of the matrix Warning: should be better tested
- Parameters:
M (
NumericsMatrix
) – the matrix- Return type:
- Returns:
the list of indices for the diagonal elements
- siconos.numerics.NSM_extract_block(M, blockM, pos_row, pos_col, block_row_size, block_col_size)[source]#
Extract a block from a sparse matrix
- siconos.numerics.NSM_linearSolverParams_free(p)[source]#
Free allocated space for NSM_linear_solver_params.
- Parameters:
p (
NSM_linear_solver_params
) – a NSM_linear_solver_params- Return type:
- Returns:
NULL on success
- siconos.numerics.NSM_linearSolverParams_new()[source]#
New and empty NSM_linear_solver_params.
- Return type:
- Returns:
a pointer on the allocated space.
- siconos.numerics.NSM_linearSolverParams(A)[source]#
Get linear solver parameters with initialization if needed.
- Parameters:
A (
NumericsMatrix
, in/out) – a NumericsMatrix.- Return type:
- Returns:
a pointer on parameters.
- siconos.numerics.NSM_fix_csc(A)[source]#
Check and fix a matrix, if needed
- Parameters:
A (CSparseMatrix) – the matrix to check, modified if necessary to have ordered indices
- siconos.numerics.NSM_origin(M)[source]#
return the origin of a sparse part of a matrix
- Parameters:
M (
NumericsSparseMatrix
) – the matrix- Return type:
- Returns:
-1 if the matrix has no sparse representation, the origin otherwise
- siconos.numerics.NSM_get_origin(M)[source]#
return the sparse matrix that has the original label
- Parameters:
M (
NumericsSparseMatrix
) – the matrix- Return type:
CSparseMatrix
- Returns:
the sparse matrix that is at the origin, or NULL if an error occur
- siconos.numerics.NSM_new_from_file(file)[source]#
New and empty NumericsSparseMatrix with correctly initialized fields.
- Return type:
- Returns:
a pointer on the allocated space.
- siconos.numerics.NSM_version(M, type)[source]#
Get current version of a type of csparse matrix.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix,type (int) – the type of sparse storage from NumericsSparseOrigin
- Return type:
version_t
- Returns:
a comparable version.
- siconos.numerics.NSM_max_version(M)[source]#
Get the maximum of versions of csparse matrices.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix,- Return type:
version_t
- Returns:
a comparable version.
- siconos.numerics.NSM_set_version(M, type, value)[source]#
Set the version of a NumericsSparseMatrix.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix,type (int) – the NumericsSparseOrigin of storage,
value (version_t) – the new version.
- siconos.numerics.NSM_reset_versions(M)[source]#
Reset all versions of a NumericsSparseMatrix.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix.
- siconos.numerics.NSM_reset_version(M, type)[source]#
Reset version of a sparse storage.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix,type (int) – the NumericsSparseOrigin of storage.
- siconos.numerics.NSM_inc_version(M, type)[source]#
Increment the version of a NumericsSparseMatrix.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix,type (int) – the NumericsSparseOrigin of storage
- siconos.numerics.NSM_latest_id(M)[source]#
Get the NumericsSparseOrigin with the latest version.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix- Return type:
- Returns:
the NumericsSparseOrigin.
- siconos.numerics.NSM_latest(M)[source]#
Get most recent CSparseMatrix.
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix- Return type:
CSparseMatrix
- Returns:
a pointer on a CSparseMatrix.
- siconos.numerics.NSM_version_sync(M)[source]#
Sync matrix origin and version
- Parameters:
M (
NumericsSparseMatrix
) – the NumericsSparseMatrix
- siconos.numerics.NM_MUMPS_copy(A, B)[source]#
copy MUMPS id if compiled WITH_MUMPS, otherwise do nothing.
- Parameters:
A (
NumericsMatrix
) – the source NumericsMatrixB (
NumericsMatrix
) – the destination NumericsMatrix
- class siconos.numerics.MLCP(*args)[source]#
Bases:
object
The Structure that contains and defines MLCProblem. Find \((z,w)\) such that:
\[\begin{split}\left\{ \begin{array}{l} M \ z + q = w \\ w_1=0 \\ 0 \le w_{2} \perp v \ge 0 \end{array} \right. \text{ with } z= \left[ \begin{array}{c} u\\ v\\ \end{array} \right] \text{ and } w= \left[ \begin{array}{c} w_{1}\\ w_{2}\\ \end{array} \right]\end{split}\]\(u, w_{1}\) are vectors of size n. \(v, w_{2}\) are vectors of size m.
ABCD format (see “R. W. {Cottle} and J. {Pang} and R. E. {Stone}”, “The Linear Complementarity Problem, Academic Press, Inc., 1992, Section 1.5 )
f[ left[ begin{array}{cc} A & C \ D & B \ end{array} right] f]
- property isStorageType1#
boolean for storageType1 1 if the problem is saved using (M,q), 0 otherwise
- property isStorageType2#
boolean for storageType2 1 if the problem is saved using (A,B,C,D,a,b), 0 otherwise
- property n#
number of equality constraints
- property m#
number of complementarity constraints
- property blocksRows#
The rows from blocksRows[i] to blocksRows[i+1]-1 forms a block of equalities iif bloksIsComp[i]=0, else the block is a complementarity block. The number of total blocks is given by NbBlocks such that blocksRows[NbBlocks] = n+m
- property blocksIsComp#
if bloksIsComp[i]=0, then block i formed by the rows from blocksRows[i] to blocksRows[i+1]-1 is an equality block else the block is a complementarity block.
- property M#
M matrix of the MLCP
- property q#
q vector of the MLCP
- property A#
A matrix of the MLCP
- property B#
B matrix of the MLCP
- property C#
C matrix of the MLCP
- property D#
D matrix of the MLCP
- property a#
a vector of the MLCP
- property b#
b vector of the MLCP
- siconos.numerics.mixedLinearComplementarity_free(problem)[source]#
function to delete a MixedLinearComplementarityProblem
- Parameters:
problem (
MixedLinearComplementarityProblem
) – pointer to a MixedLinearComplementarityProblem to delete
- siconos.numerics.mixedLinearComplementarity_new()[source]#
create empty MLCP
- Return type:
MixedLinearComplementarityProblem
- Returns:
empy MLCP
- siconos.numerics.mixedLinearComplementarity_printInFile(problem, file)[source]#
function to write in a file a MixedLinearComplementarityProblem
- Parameters:
problem (
MixedLinearComplementarityProblem
) – pointer to a MixedLinearComplementarityProblem to printfile (FILE) – pointer to a FILE
- Return type:
- Returns:
0 if ok
- siconos.numerics.mixedLinearComplementarity_newFromFile(problem, file)[source]#
Function to read and create a MixedLinearComplementarityProblem from a file
- Parameters:
problem (
MixedLinearComplementarityProblem
) – pointer to a MixedLinearComplementarityProblem to createfile (FILE) – pointer to a FILE
- Return type:
- Returns:
0 if ok
- siconos.numerics.mixedLinearComplementarity_newFromFileOld(problem, file)[source]#
Function to read and create a MixedLinearComplementarityProblem from a file
- Parameters:
problem (
MixedLinearComplementarityProblem
) – pointer to a MixedLinearComplementarityProblem to createfile (FILE) – pointer to a FILE
- Return type:
- Returns:
0 if ok
- siconos.numerics.mixedLinearComplementarity_newFromFilename(problem, filename)[source]#
Function to read and create a MixedLinearComplementarityProblem from a file
- Parameters:
problem (
MixedLinearComplementarityProblem
) – pointer to a MixedLinearComplementarityProblem to createfilename (string) – that contains the mlcp
- Return type:
- Returns:
0 if ok
- siconos.numerics.mixedLinearComplementarity_fromMtoABCD(problem)[source]#
Function to create a MLCP with ABCD format from M formatted MLCP
- siconos.numerics.mlcp_driver_init(problem, options)[source]#
General interface to initialize a solver.
Must be call for the following solvers:
mlcp_enum
mlcp_path
mlcp_simplex
mlcp_direct_enum
mlcp_direct_path
mlcp_direct_simplex
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – the MixedLinearComplementarityProblem structure which handles the problem (M,q)options (
SolverOptions
, in) – structure used to define the solver(s) and their parameters
- siconos.numerics.mlcp_driver_reset(problem, options)[source]#
General interface to reset a solver.
Must be call for the following solvers:
mlcp_enum
mlcp_path
mlcp_simplex
mlcp_direct_enum
mlcp_direct_path
mlcp_direct_simplex
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – the MixedLinearComplementarityProblem structure which handles the problem (M,q)options (
SolverOptions
, in) – structure used to define the solver(s) and their parameters
- siconos.numerics.mlcp_pgs(problem, z, w, options)[source]#
mlcp_pgs (Projected Gauss-Seidel) is a basic Projected Gauss-Seidel solver for MLCP.
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,m,M, q…)z (float, in/out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_rpgs(problem, z, w, options)[source]#
mlcp_rpgs (Projected Gauss-Seidel) is a basic Projected Gauss-Seidel solver for MLCP.
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,m,M, q…)z (float, in/out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_psor(problem, z, w, options)[source]#
mlcp_psor (projected successive overrelaxation method) is a solver for MLCP.
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,m,M, q…)z (float, in/out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_rpsor(problem, z, w, options)[source]#
mlcp_rpsor (regularized projected successive overrelaxation method) is a solver for MLCP.
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,m,M, q…)z (float, in/out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_path(problem, z, w, options)[source]#
path solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,m,M, q…)z (float, in/out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_enum(problem, z, w, options)[source]#
enum solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success,it found a solution 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_direct(problem, z, w, options)[source]#
direct solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – MixedLinearComplementarityProblem* problem structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success,it found a solution 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_direct_enum(problem, z, w, options)[source]#
direct-enum solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success,it found a solution 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_direct_simplex(problem, z, w, options)[source]#
direct-simplex solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success,it found a solution 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_direct_path(problem, z, w, options)[source]#
direct-path solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success, solution found 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_simplex(problem, z, w, options)[source]#
simplex solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success,it found a solution 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_FB(problem, z, w, options)[source]#
Fischer Burmeister solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success,it found a solution 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_direct_FB(problem, z, w, options)[source]#
Direct Fischer Burmeister solver
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,mM, q…)z (float, out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, out) – a m+n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success, solution found 1 : failure,it did not find any solution
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_pgs_SBM(problem, z, w, options)[source]#
generic interface used to call any MLCP solver applied on a Sparse-Block structured matrix M, with a Gauss-Seidel process to solve the global problem (formulation/solving of local problems for each row of blocks)
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the LCP (M, q…). M must be a SparseBlockStructuredMatrixz (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int) – an integer which returns the termination value: 0 : convergence >0 : failed, depends on local solver
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mlcp_compute_error(problem, z, w, tolerance)[source]#
This function checks the validity of the vector z as a solution of the MLCP.
- Parameters:
problem (
MixedLinearComplementarityProblem
, in) – structure that represents the MLCP (n,m,M, q… or (A,B,C…))z (float, in/out) – a m+n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a m+n-vector of doubles which returns the solution of the problem.
tolerance (float, in) – threshold used to validate the solution: if the error is less than this value, the solution is accepted
error (float, in/out) –
- Return type:
- Returns:
status: 0 : convergence, 1: error > tolerance
- class siconos.numerics.LCP(M, q)[source]#
Bases:
object
Structure that contains and defines a LCP Problem.
- property size#
size of the problem
- property M#
M matrix of the LCP (see the mathematical description)
- property q#
vector of the LCP (see the mathematical description)
- siconos.numerics.linearComplementarity_display(problem)[source]#
display a LinearComplementarityProblem
- Parameters:
problem (
LinearComplementarityProblem
) – pointer to a LinearComplementarityProblem to display
- siconos.numerics.linearComplementarity_printInFile(problem, file)[source]#
function to write in a file a LinearComplementarityProblem
- Parameters:
problem (
LinearComplementarityProblem
) – pointer to a LinearComplementarityProblem to printfile (FILE) – pointer to a FILE
- Return type:
- Returns:
0 if ok
- siconos.numerics.linearComplementarity_newFromFile(problem, file)[source]#
Read and create a LinearComplementarityProblem from a file
- Parameters:
problem (
LinearComplementarityProblem
) – pointer to a LinearComplementarityProblem to createfile (FILE) – pointer to a FILE
- Return type:
- Returns:
0 if ok
- siconos.numerics.linearComplementarity_newFromFilename(problem, filename)[source]#
Read and create a LinearComplementarityProblem from a file
- Parameters:
problem (
LinearComplementarityProblem
) – pointer to a LinearComplementarityProblem to createfilename (string) – that contains the lcp
- Return type:
- Returns:
0 if ok
- siconos.numerics.freeLinearComplementarityProblem(problem)[source]#
Delete a LinearComplementarityProblem
- Parameters:
problem (
LinearComplementarityProblem
) – pointer to a LinearComplementarityProblem to delete
- siconos.numerics.newLCP()[source]#
Create new LCP and clear its fields
- Return type:
LinearComplementarityProblem
- Returns:
a LinearComplementarityProblem
- siconos.numerics.lcp_qp(problem, z, w, options)[source]#
lcp_qp uses a quadratic programm formulation for solving a LCP
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) –
- an integer which returns the termination value:
0 : convergence / minimization sucessfull 1 : Too Many iterations
- 2Accuracy insuficient to satisfy convergence criterion
5 : Length of working array insufficient Other : The constraints are inconstent
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_cpg(problem, z, w, options)[source]#
lcp_cpg is a CPG (Conjugated Projected Gradient) solver for LCP based on quadratic minimization.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0: convergence 1: iter = itermax 2: negative diagonal term 3: pWp nul
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_pgs(problem, z, w, options)[source]#
lcp_pgs (Projected Gauss-Seidel) is a basic Projected Gauss-Seidel solver for LCP.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) –
- an integer which returns the termination value:
0 : convergence 1 : iter = itermax 2 : negative diagonal term
- type options:
SolverOptions
, in/out- param options:
structure used to define the solver and its parameters.
- siconos.numerics.lcp_rpgs(problem, z, w, options)[source]#
lcp_rpgs (Regularized Projected Gauss-Seidel ) is a solver for LCP, able to handle matrices with null diagonal terms.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) –structure used to define the solver and its parameters.
TODO: Sizing the regularization paramter and apply it only on null diagnal term
- siconos.numerics.lcp_psor(problem, z, w, options)[source]#
lcp_psor Projected Succesive over relaxation solver for LCP. See cottle, Pang Stone Chap 5
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters. TODO: use the relax parameter add test add a vector of relaxation parameter wtith an auto sizing (see SOR algorithm for linear solver.)
- siconos.numerics.lcp_nsqp(problem, z, w, options)[source]#
lcp_nsqp use a quadratic programm formulation for solving an non symmetric LCP
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) –
- an integer which returns the termination value:
0 : convergence / minimization sucessfull 1 : Too Many iterations
- 2Accuracy insuficient to satisfy convergence criterion
5 : Length of working array insufficient Other : The constraints are inconstent
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_latin(problem, z, w, options)[source]#
lcp_latin (LArge Time INcrements) is a basic latin solver for LCP.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : Cholesky Factorization failed 3 : nul diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_latin_w(problem, z, w, options)[source]#
lcp_latin_w (LArge Time INcrements) is a basic latin solver with relaxation for LCP.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : Cholesky Factorization failed 3 : nul diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_lexicolemke(problem, z, w, options)[source]#
lcp_lexicolemke is a direct solver for LCP based on pivoting method principle for degenerate problem Choice of pivot variable is performed via lexicographic ordering Ref: “The Linear Complementarity Problem” Cottle, Pang, Stone (1992)
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_newton_min(problem, z, w, options)[source]#
lcp_newton_min uses a nonsmooth Newton method based on the min formulation (or max formulation) of the LCP
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence / minimization sucessfull 1 : Too Many iterations 2 : Accuracy insuficient to satisfy convergence criterion 5 : Length of working array insufficient Other : The constraints are inconstent
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
TODO: Optimizing the memory allocation (Try to avoid the copy of JacH into A) Add rules for the computation of the penalization rho Add a globalization strategy based on a decrease of a merit function. (Nonmonotone LCP) Reference in Ferris Kanzow 2002
- siconos.numerics.lcp_newton_FB(problem, z, w, options)[source]#
lcp_newton_FB use a nonsmooth newton method based on the Fischer-Bursmeister convex function
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 - convergence 1 - iter = itermax 2 - failure in the descent direction search (in LAPACK)
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
TODO: Optimizing the memory allocation (Try to avoid the copy of JacH into A) Add rules for the computation of the penalization rho Add a globalization strategy based on a decrease of a merit function. (Nonmonotone LCP) Reference in Ferris Kanzow 2002
- siconos.numerics.lcp_newton_minFB(problem, z, w, options)[source]#
lcp_newton_minFB use a nonsmooth newton method based on both a min and Fischer-Bursmeister reformulation References: Facchinei–Pang (2003)
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 - convergence 1 - iter = itermax 2 - failure in the descent direction search (in LAPACK)
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_path(problem, z, w, options)[source]#
path solver
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax 2 : negative diagonal term
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_enum(problem, z, w, options)[source]#
enumerative solver
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : success 1 : failed
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_enum_init(problem, options, withMemAlloc)[source]#
Proceed with initialisation required before any call of the enum solver.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.withMemAlloc (int, in) – If it is not 0, then the necessary work memory is allocated.
- siconos.numerics.lcp_enum_reset(problem, options, withMemAlloc)[source]#
Reset state for enum solver parameters.
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.withMemAlloc (int, in) – If it is not 0, then the work memory is free.
- siconos.numerics.lcp_avi_caoferris(problem, z, w, options)[source]#
lcp_avi_caoferris is a direct solver for LCP based on an Affine Variational Inequalities (AVI) reformulation The AVI solver is here the one from Cao and Ferris Ref: “A Pivotal Method for Affine Variational Inequalities” Menglin Cao et Michael Ferris (1996)
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_pivot(problem, z, w, options)[source]#
lcp_pivot is a direct solver for LCP based on a pivoting method It can currently use Bard, Murty’s least-index or Lemke rule for choosing the pivot. The default one is Lemke and it can be changed by setting iparam[SICONOS_LCP_IPARAM_PIVOTING_METHOD_TYPE]. The list of choices are in the enum LCP_PIVOT (see lcp_cst.h).
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_pathsearch(problem, z, w, options)[source]#
lcp_pathsearch is a direct solver for LCP based on the pathsearch algorithm Warning: this solver is available for testing purposes only! consider using lcp_pivot() if you are looking for simular solvers
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_gams(problem, z, w, options)[source]#
lcp_gams uses the solver provided by GAMS
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int, out) – an integer which returns the termination value: 0 : convergence 1 : iter = itermax
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_nsgs_SBM(problem, z, w, options)[source]#
generic interface used to call any LCP solver applied on a Sparse-Block structured matrix M, with a Gauss-Seidel process to solve the global problem (formulation/solving of local problems for each row of blocks)
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…). M must be a SparseBlockStructuredMatrixz (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
info (int) – an integer which returns the termination value: 0 : convergence >0 : failed, depends on local solver
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.lcp_nsgs_SBM_buildLocalProblem(rowNumber, blmat, local_problem, q, z)[source]#
Construct local problem from a “global” one
- Parameters:
rowNumber (int) – index of the local problem
blmat (
SparseBlockStructuredMatrix
) – matrix containing the problemlocal_problem (
LinearComplementarityProblem
) – problem to fillq (float) – big q
z (float) – big z
- siconos.numerics.lcp_compute_error(problem, z, w, tolerance)[source]#
Computes error criterion and update \(w = Mz + q\).
- Parameters:
problem (
LinearComplementarityProblem
, in) – structure that represents the LCP (M, q…)z (float, in/out) – a n-vector of doubles which contains the initial solution and returns the solution of the problem.
w (float, in/out) – a n-vector of doubles which returns the solution of the problem.
tolerance (float, in) – threshold used to validate the solution: if the error is less than this value, the solution is accepted
error (float, out) – the actual error of the solution with respect to the problem
- Return type:
- Returns:
status: 0 : convergence, 1: error > tolerance
- siconos.numerics.lcp_driver_DenseMatrix(problem, z, w, options)[source]#
Interface to solvers for Linear Complementarity Problems, dedicated to dense matrix storage
- Parameters:
problem (
LinearComplementarityProblem
, in) – the LinearComplementarityProblem structure which handles the problem (M,q)z (float, in/out) – a n-vector of doubles which contains the solution of the problem.
w (float, in/out) – a n-vector of doubles which contains the solution of the problem.
options (
SolverOptions
, in/out) – structure used to define the solver(s) and their parameters
- Return type:
- Returns:
info termination value - 0 : successful - >0 : otherwise see each solver for more information about the log info
- siconos.numerics.SICONOS_LCP_IPARAM_NSGS_ITERATIONS_SUM = 4#
index in iparam to store the sum of local solver iterations number
- siconos.numerics.SICONOS_LCP_IPARAM_PIVOTING_METHOD_TYPE = 5#
index in iparam to store type of pivoting methods
- siconos.numerics.SICONOS_LCP_IPARAM_SKIP_TRIVIAL = 6#
index in iparam to skip trivial solution
- siconos.numerics.SICONOS_LCP_IPARAM_ENUM_NUMBER_OF_SOLUTIONS = 7#
index in iparam to store the number of solutions
- siconos.numerics.SICONOS_LCP_IPARAM_ENUM_CURRENT_ENUM = 8#
index in iparam to store the current enum
- siconos.numerics.SICONOS_LCP_IPARAM_ENUM_SEED = 9#
index in iparam to store the seed for starting enum
- siconos.numerics.SICONOS_LCP_IPARAM_ENUM_USE_DGELS = 10#
index in iparam to store the first seed for enum
- siconos.numerics.SICONOS_LCP_IPARAM_ENUM_MULTIPLE_SOLUTIONS = 11#
index in iparam to store to activate multiple solutions search
- siconos.numerics.SICONOS_LCP_DPARAM_RHO = 3#
index in dparam to store to the relaxation or regularization parameter
- siconos.numerics.SICONOS_LCP_DPARAM_NSGS_LOCAL_ERROR_SUM = 4#
index in dparam to store the sum of local error values
- siconos.numerics.SICONOS_LCP_DPARAM_LATIN_PARAMETER = 12#
index in dparam to store the latin parameter
- class siconos.numerics.AVI(*args)[source]#
Bases:
object
Structure that contains and defines an AVI
The problem is : given a matrix \(M\) and a vector \(q\), find \(z\) such that
\[\langle x - z, q + Mz \rangle \geq 0 \ \text{for all }x\in K\]See users’guide for details.
- property size#
size of the problem
- property M#
M matrix of the AVI (see the mathematical description)
- property q#
vector of the AVI (see the mathematical description)
- property d#
Covering vector (optional)
- property poly#
Polyhedra where the solution has to belong
- property lb#
Lower bounds for the variables
- property ub#
Upper bounds for the variables
- property cones#
Non-polyhedral Cones where the variable lives (not implemented yet)
- siconos.numerics.AVI_display(avi)[source]#
Affine Variational Inequalities display
- Parameters:
avi (
AffineVariationalInequalities
) – pointer to the AffineVariationalInequalities to display
- siconos.numerics.AVI_printInFile(avi, file)[source]#
write AVI to file
- Parameters:
avi (
AffineVariationalInequalities
) – pointer to a AffineVariationalInequalities to printfile (FILE) – pointer to a FILE
- Return type:
- Returns:
1 if successfull
- siconos.numerics.AVI_newFromFile(avi, file)[source]#
read from file and create AffineVariationalInequalities
- Parameters:
avi (
AffineVariationalInequalities
) – pointer to a AffineVariationalInequalities to createfile (FILE) – pointer to a FILE
- Return type:
- Returns:
1 if successfull
- siconos.numerics.AVI_newFromFilename(avi, filename)[source]#
function to read and create a AffineVariationalInequalities from a file
- Parameters:
avi (
AffineVariationalInequalities
) – pointer to a AffineVariationalInequalities to createfilename (string) – that contains the AVI
- Return type:
- Returns:
1 if successfull
- siconos.numerics.freeAVI(avi)[source]#
function to delete a AffineVariationalInequalities
- Parameters:
avi (
AffineVariationalInequalities
) – pointer to a AffineVariationalInequalities to delete
- siconos.numerics.newAVI()[source]#
Create an empty AVI struct
- Return type:
AffineVariationalInequalities
- Returns:
an empty AffineVariationalInequalities
- siconos.numerics.avi_caoferris(problem, z, w, options)[source]#
avi_caoferris is a direct solver for AVI based on pivoting method principle for degenerate problem Choice of pivot variable is performed via lexicographic ordering Ref: “A Pivotal Method for Affine Variational Inequalities” Menglin Cao et Michael Ferris (1996)
- Parameters:
problem (
AffineVariationalInequalities
, in) – structure that represents the AVI (M, q, K)z (float, in/out) – on call contains the initial solution and on return holds the solution of the problem.
w (float, in/out) – defined as Mz + q
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- Return type:
- Returns:
info about the convergence: 0 ok; 1 …
- siconos.numerics.avi_pathavi(problem, z, w, options)[source]#
avi_pathavi is using PATHVI, a direct solver for VI based on pivoting method principle for degenerate problem Ref: “A structure-preserving Pivotal Method for Affine Variational Inequalities” Y. Kim, O. Huber, M.C. Ferris, Math Prog B (2017)
- Parameters:
problem (
AffineVariationalInequalities
, in) – structure that represents the AVI (M, q, K)z (float, in/out) – on call contains the initial solution and on return holds the solution of the problem.
w (float, in/out) – defined as Mz + q
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- Return type:
- Returns:
info about the convergence: 0 ok; 1 …
- siconos.numerics.SICONOS_FRICTION_2D_NSGS = 400#
2D Frictional Contact solvers
- siconos.numerics.SICONOS_FRICTION_3D_NSGS = 500#
Non-smooth Gauss Seidel, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_NSGSV = 501#
Non-smooth Gauss Seidel-velocity, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_PROX = 502#
proximal, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_TFP = 503#
Tresca, fixed point, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_NSN_AC = 504#
Non-smooth Newton Alart-Curnier, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_DSFP = 505#
De Saxce fixed point, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_VI_FPP = 506#
VI formulation, fixed point projection, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_VI_EG = 507#
VI formulation, Extra-gradient, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_HP = 508#
Hyperplane projection, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_NCPGlockerFBFixedPoint = 510#
Fischer Burmeister fixed point, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_FPP = 511#
Fixed point projection, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_EG = 512#
Extra-gradient, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FB = 513#
Non-smooth Newton Fischer Burmeister, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_GAMS_PATH = 514#
GAMS/Path (Ferris), local formulation
- siconos.numerics.SICONOS_FRICTION_3D_GAMS_PATHVI = 515#
VI formulation, GAMS/Path (Ferris), local formulation
- siconos.numerics.SICONOS_FRICTION_3D_ACLMFP = 516#
Alart-Curnier fixed point, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_SOCLCP = 517#
Second-order Cone LCP, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_GAMS_LCP_PATH = 518#
GAMS/PATH (Ferris) LCP, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_GAMS_LCP_PATHVI = 519#
VI formulation, GAMS/PATH (Ferris) LCP, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_NSN_NM = 520#
Non-smooth Newton, natural map, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_PFP = 522#
Panagiotopoulos, fixed point, local formulation
- siconos.numerics.SICONOS_FRICTION_3D_ADMM = 523#
ADMM local formulation
- siconos.numerics.SICONOS_FRICTION_3D_ONECONTACT_NSN = 550#
Non-smooth Newton Alart-Curnier, ‘direct’, one contact solver
- siconos.numerics.SICONOS_FRICTION_3D_ONECONTACT_NSN_GP = 551#
Non-smooth Newton Alart-Curnier, ‘damped’, one contact solver
- siconos.numerics.SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnCone = 552#
Projection on cone, one contact solver
- siconos.numerics.SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration = 553#
Projection on cone, one contact solver
- siconos.numerics.SICONOS_FRICTION_3D_NCPGlockerFBPATH = 556#
Fischer Burmeister/Path, Glocker formulation, one contact solver
- siconos.numerics.SICONOS_FRICTION_3D_NCPGlockerFBNewton = 561#
Newton/Fischer Burmeister, Glocker formulation, one contact solver
- siconos.numerics.SICONOS_GLOBAL_FRICTION_3D_NSGS_WR = 600#
3D Frictional contact local solvers on global formulation
- siconos.numerics.SICONOS_GLOBAL_FRICTION_3D_VI_FPP = 610#
VI formulation, Fixed Point Projection, local formulation
- siconos.numerics.SICONOS_GLOBAL_FRICTION_3D_VI_EG = 611#
VI formulation, Extra-gradient, local formulation
- siconos.numerics.SICONOS_ROLLING_FRICTION_3D_NSGS = 3000#
Non-smooth Gauss Seidel, local formulation
- siconos.numerics.SICONOS_ROLLING_FRICTION_2D_NSGS = 4000#
Non-smooth Gauss Seidel, local formulation
- siconos.numerics.SICONOS_GLOBAL_ROLLING_FRICTION_3D_NSGS_WR = 5000#
Non-smooth Gauss Seidel, global formulation
- siconos.numerics.SICONOS_FRICTION_3D_IPARAM_INTERNAL_ERROR_STRATEGY = 2#
index in iparam to store the error strategy for the internal solver
- siconos.numerics.SICONOS_FRICTION_3D_IPARAM_RESCALING = 3#
index in iparam to store the rescaling
- siconos.numerics.SICONOS_FRICTION_3D_IPARAM_RESCALING_CONE = 4#
index in iparam to store the rescaling
- siconos.numerics.SICONOS_FRICTION_3D_CURRENT_CONTACT_NUMBER = 5#
one contact solvers) *
- Type:
current contact number (example of use
- siconos.numerics.SICONOS_FRICTION_3D_IPARAM_ERROR_EVALUATION = 7#
index in iparam to store the error evaluation method
- siconos.numerics.SICONOS_FRICTION_3D_IPARAM_ERROR_EVALUATION_FREQUENCY = 8#
index in iparam to store the frequency of error evaluation method
- siconos.numerics.SICONOS_FRICTION_3D_DPARAM_INTERNAL_ERROR_RATIO = 2#
index in dparam to store the internal solver error ratio
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_RELAXATION = 4#
index in iparam to store the relaxation strategy
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_SHUFFLE = 5#
index in iparam to store the shuffle strategy
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_SHUFFLE_SEED = 6#
index in iparam to store the shuffle seed
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_FREEZING_CONTACT = 19#
index in iparam to store the
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_FILTER_LOCAL_SOLUTION = 14#
index in iparam to store the
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_RELAXATION_VALUE = 8#
index in dparam to store the relaxation strategy
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_ERROR_EVALUATION_FULL = 0#
Evaluation of the error with the expensive function fc3d_compute_error *
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_ERROR_EVALUATION_LIGHT = 1#
Evaluation of the error with the cheap incremental variation *
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_ERROR_EVALUATION_LIGHT_WITH_FULL_FINAL = 2#
Evaluation of the error with the cheap incremental variation but we modify the incremental toleranve to reach the requred accuracy *
- siconos.numerics.SICONOS_FRICTION_3D_NSGS_ERROR_EVALUATION_ADAPTIVE = 3#
Evaluation of the error with the expensive function fc3d_compute_error and an adaptive frequency for calling the error function *
- siconos.numerics.SICONOS_FRICTION_3D_NSN_RHO_STRATEGY = 9#
index in iparam to store the strategy for computing rho
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FORMULATION = 10#
index in iparam to store the formulation
- siconos.numerics.SICONOS_FRICTION_3D_NSN_LINESEARCH = 11#
index in iparam to store the line-search
- siconos.numerics.SICONOS_FRICTION_3D_NSN_LINESEARCH_MAX_ITER = 12#
index in iparam to store the maximum number of iterations
- siconos.numerics.SICONOS_FRICTION_3D_NSN_LINEAR_SOLVER = 13#
index in iparam to set the linear solver used at each Newton iteration cs_lusol or mumps
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_STRATEGY = 14#
index in iparam to store the strategy for the hybrid solver
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_MAX_LOOP = 15#
index in iparam to store the maximum number of loop for the hybrid solver
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_MAX_ITER = 16#
index in iparam to store the maximum number of iterations for the projection solver
- siconos.numerics.SICONOS_FRICTION_3D_NSN_MEMORY_ALLOCATED = 17#
index in iparam used to check if memory allocation has already be done (if true/1) or not (if 0/false) for internal work array.
- siconos.numerics.SICONOS_FRICTION_3D_NSN_MPI_COM = 18#
index in iparam to store the boolean to know if allocation of dwork is needed
- siconos.numerics.SICONOS_FRICTION_3D_NSN_RHO = 3#
index in dparam to store the rho value for projection formulation
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FORMULATION_RHO_STRATEGY_CONSTANT = 0#
A constant value given in dparam[SICONOS_FRICTION_3D_NSN_RHO] is used
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FORMULATION_RHO_STRATEGY_SPECTRAL_NORM = 1#
A computed value stored in dparam[SICONOS_FRICTION_3D_NSN_RHO] is used
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FORMULATION_RHO_STRATEGY_SPLIT_SPECTRAL_NORM_COND = 2#
A computed value stored in dparam[SICONOS_FRICTION_3D_NSN_RHO] is used
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FORMULATION_RHO_STRATEGY_SPLIT_SPECTRAL_NORM = 3#
An adaptive strategy for rho is used
- siconos.numerics.SICONOS_FRICTION_3D_NSN_FORMULATION_RHO_STRATEGY_ADAPTIVE = 4#
An adaptive strategy for rho is used
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_STRATEGY_NO = 0#
No strategy for the hybrid solver
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_STRATEGY_PLI_NSN_LOOP = 1#
Loop PLI-NSN strategy for the hybrid solver
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_STRATEGY_NSN_AND_PLI_NSN_LOOP = 2#
NSN and after Loop PLI-NSN strategy for the hybrid solver
- siconos.numerics.SICONOS_FRICTION_3D_NSN_HYBRID_STRATEGY_VI_EG_NSN = 3#
VI_EG preconditionning to NSN strategy for the hybrid solver
- siconos.numerics.SICONOS_FRICTION_3D_FP_ERROR_STRATEGY = 2#
index in iparam to store the error strategy for the internal solver
- siconos.numerics.SICONOS_FRICTION_3D_PROXIMAL_IPARAM_CUMULATIVE_ITER_DONE = 6#
index in iparam to store the relaxation strategy
- siconos.numerics.SICONOS_FRICTION_3D_PROXIMAL_IPARAM_RELAXATION = 8#
index in iparam to store the relaxation strategy
- siconos.numerics.SICONOS_FRICTION_3D_PROXIMAL_IPARAM_STRATEGY = 9#
index in iparam to store the proximal strategy
- siconos.numerics.SICONOS_FRICTION_3D_PROXIMAL_DPARAM_ALPHA = 3#
index in dparam to store the parameter alpha
- siconos.numerics.SICONOS_FRICTION_3D_PROXIMAL_PROX = 0#
Proximal algorithm
- siconos.numerics.SICONOS_FRICTION_3D_PROXIMAL_REGULARIZATION = 1#
Regularization algorithm
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_IPARAM_RHO_STRATEGY = 9#
index in iparam to store the strategy for computing rho
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_IPARAM_INITIAL_RHO = 10#
index in iparam to store the strategy for computing rho
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_IPARAM_ACCELERATION = 11#
index in iparam to store the acceleration parameter
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_IPARAM_SYMMETRY = 12#
index in iparam to store the symmetry parameter
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_IPARAM_SPARSE_STORAGE = 13#
index in iparam to store the sparse storage parameter
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_IPARAM_GET_PROBLEM_INFO = 14#
index in iparam to get problem info
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_RHO = 3#
index in dparam to store the rho value for projection formulation
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_RESTART_ETA = 4#
index in dparam to store the eta value for the restarting criteria
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_BALANCING_RESIDUAL_TAU = 5#
index in dparam to store the tau value for the balancing residual technique
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_BALANCING_RESIDUAL_PHI = 6#
index in dparam to store the phi value for the balancing residual technique
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_RHO_STRATEGY_CONSTANT = 0#
A constant value given in dparam[SICONOS_FRICTION_3D_NSN_RHO] is used
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_RHO_STRATEGY_RESIDUAL_BALANCING = 2#
An adaptive strategy for rho is used
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_RHO_STRATEGY_SCALED_RESIDUAL_BALANCING = 3#
An adaptive strategy for rho is used
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_INITIAL_RHO_GIVEN = 0#
A constant value given in dparam[SICONOS_FRICTION_3D_NSN_RHO] is used
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_INITIAL_RHO_NORM_INF = 1#
A computed value stored in dparam[SICONOS_FRICTION_3D_NSN_RHO] is used
- siconos.numerics.SICONOS_FRICTION_3D_ADMM_INITIAL_RHO_EIGENVALUES = 2#
An adaptive strategy for rho is used
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_NESTEROV_TODD_SCALING = 11#
index in iparam to use NT scaling technique
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_SPARSE_STORAGE = 12#
index in iparam to store the sparse storage parameter
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_GET_PROBLEM_INFO = 13#
index in iparam to get problem info
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_ITERATES_MATLAB_FILE = 14#
index in iparam to print iterates (including problem data) into a Matlab file
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_REDUCED_SYSTEM = 15#
index in iparam to use reduce the linear system
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_FINISH_WITHOUT_SCALING = 16#
index in iparam to finish the solution without scaling
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_UPDATE_S = 17#
index in iparam to update the vector w for solving nonconvex problem
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_NESTEROV_TODD_SCALING_METHOD = 18#
index in iparam to use Qp or F formula for computing Nesterov-Todd scaling *
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_REDUCED_SYSTEM_METHOD = 19#
index in iparam to use a reduced symmetric system with Qp2 or QpH inside the matrix *
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_LS_FORM = 10#
index in iparam to choose the linear system formulation *
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_REFINEMENT = 9#
index in iparam to perform iterative refinement with MA57 (LDT) *
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_CHOLESKY = 8#
index in iparam to perform Cholesky factorization *
- siconos.numerics.SICONOS_FRICTION_3D_IPM_IPARAM_ITERATES_PYTHON_FILE = 7#
index in iparam to print iterates (including problem data) into a Python file
- siconos.numerics.SICONOS_FRICTION_3D_IPM_SIGMA_PARAMETER_1 = 7#
index in dparam to store the parameter for computation the power of sigma
- siconos.numerics.SICONOS_FRICTION_3D_IPM_GAMMA_PARAMETER_1 = 10#
index in dparam to store the parameter for computation the safity coefficient of step length
- siconos.numerics.SICONOS_VI_IPARAM_LINESEARCH_METHOD = 6#
index in iparam to store the linesearch method
- siconos.numerics.SICONOS_VI_IPARAM_ERROR_EVALUATION = 7#
index in iparam to store the error evaluation method
- siconos.numerics.SICONOS_VI_IPARAM_ERROR_EVALUATION_FREQUENCY = 8#
index in iparam to store the frequency of error evaluation method
- siconos.numerics.SICONOS_VI_IPARAM_LS_MAX_ITER = 9#
index for max number of iterations allowed in line search
- siconos.numerics.SICONOS_VI_IPARAM_ACTIVATE_UPDATE = 10#
false default choice)
- Type:
activate the update in the loop (0
- siconos.numerics.SICONOS_VI_LS_ARMIJO = 0#
Armijo rule with Khotbotov ratio (default)
- siconos.numerics.SICONOS_VI_LS_SOLODOV = 1#
Armijo rule with Solodov.Tseng ratio
- siconos.numerics.SICONOS_VI_LS_HANSUN = 2#
Armijo rule with Han.Sun ratio
- siconos.numerics.SICONOS_VI_DPARAM_RHO = 3#
index in dparam to store the initial value of rho
- siconos.numerics.SICONOS_VI_DPARAM_LS_TAU = 4#
index in dparam to store the tau coeff of line-search
- siconos.numerics.SICONOS_VI_DPARAM_LS_TAUINV = 5#
index in dparam to store the tauinv coeff of line-search
- siconos.numerics.SICONOS_VI_DPARAM_LS_L = 6#
index in dparam to store the L coeff of line-search
- siconos.numerics.SICONOS_VI_DPARAM_LS_LMIN = 7#
index in dparam to store the LMIN coeff of line-search
- siconos.numerics.SICONOS_VI_DPARAM_SIGMA = 8#
index in dparam to store the sigma coeff (HP)
- class siconos.numerics.functions_LSA[source]#
Bases:
object
Struct holding the necessary pointers to functions needed by the newton_LSA() procedure.
- property compute_F#
function to evaluate w = F(z)
- property compute_F_merit#
function to evaluate F_merit(z) (e.g. F_FB, F_{min}, …)
- property compute_H#
function to get an element H of T
- property compute_error#
function to compute the error
- property compute_RHS_desc#
function to evaluate F_desc(z) (e.g. F_FB, F_{min}, …), optional
- property compute_H_desc#
function to get an element H_desc of T_desc, optional
- property compute_descent_direction#
function to get the descent direction, used for instance in the Newton-Josephy method
- property compute_JacTheta_merit#
function to get the descent direction, used for instance in the Newton-Josephy method
- property get_set_from_problem_data#
Function returning the set description from the
- property ls_failure_fn#
Function to call when the line search fails
- siconos.numerics.SICONOS_IPARAM_LSA_NONMONOTONE_LS = 3#
line search based algo use this
- siconos.numerics.SICONOS_IPARAM_NMS_WATCHDOG_TYPE = 7#
non-monotone specific part
- siconos.numerics.SICONOS_DPARAM_LSA_ALPHA_MIN = 2#
line-search
- siconos.numerics.SICONOS_DPARAM_NMS_DELTA = 2#
non-monotone specific part
- siconos.numerics.newton_LSA(n, z, w, data, options, functions)[source]#
Newton algorithm for finding the zero of a function with a line search. Mainly used for equation-based reformulation of CP or VI.
- Parameters:
n (int) – size of the problem
z (float) – variable
w (float) – value of F(z)
info (int) – solver-specific values
data (void) – opaque problem definition
options (
SolverOptions
) – options for this solverfunctions (
functions_LSA
) – struct of function pointers to compute F, H and the error
- siconos.numerics.init_lsa_functions(functions, compute_F, merit_function)[source]#
Set the functions to compute F and F_merit and all the other pointers to NULL
- Parameters:
functions (
functions_LSA
) – structure to fillcompute_F (void) – function to compute F
merit_function (void) – function to compute F_merit
- siconos.numerics.set_lsa_params_data(options, mat)[source]#
Set the parameters and data for newton_LSA
- Parameters:
options (
SolverOptions
) – the solver optionmat (
NumericsMatrix
) – the
- siconos.numerics.newton_LSA_free_solverOptions(options)[source]#
clear the solver-specific data
- Parameters:
options (
SolverOptions
) – the SolverOption structure
- siconos.numerics.projectionOnCone(r, mu)[source]#
projectionOnCone Projection on the second Order Cone in \(R^3\), \(K \{ r, r_1 \geq 0, 0 \sqrt(r_2^2+r_3^2) \geq mu r_1 \}\)
- siconos.numerics.projectionOnDualCone(u, mu)[source]#
projectionOnDualCone Projection on the second Order Cone in \(R^3\), \(K \{ r, r_1 \geq 0, 0 mu \sqrt(u_2^2+u_3^2) \geq u_1 \}\)
- siconos.numerics.projectionOnSecondOrderCone(r, mu, size)[source]#
projectionOnCone Projection on the second Order Cone in \(R^n\), \(K \{ r, r_1 \geq 0, 0 \|[r_2,r_n]\| \geq mu r_1 \}\)
- siconos.numerics.projectionOnRollingCone(r, mu, mur)[source]#
projectionOnCone Projection on the second Order Cone in \(R^3\), \(K \{ r, r_1 \geq 0, 0 \sqrt(r_2^2+r_3^2) \geq mu r_1 \}\)
- siconos.numerics.projectionOn2DRollingCone(r, mu, mur)[source]#
projectionOnCone Projection on the second Order Cone in \(R^3\), \(K \{ r, r_1 \geq 0, 0 \sqrt(r_2^2+r_3^2) \geq mu r_1 \}\)
- siconos.numerics.projectionOnDualRollingCone(u, mu, mur)[source]#
projectionOnDualCone Projection on the second Order Cone in \(R^3\), \(K \{ r, r_1 \geq 0, 0 mu \sqrt(u_2^2+u_3^2) \geq u_1 \}\)
- class siconos.numerics.MCP(*args)[source]#
Bases:
object
Structure that contains and defines a MixedComplementarityProblem
- property n1#
number of equalities constraints
- property n2#
size of complementarity variables
- property compute_Fmcp#
pointer to the function used to compute \(F_{mcp}(z) = (G(z), H(z))\)
- property compute_nabla_Fmcp#
pointer to the function used to compute \(\nabla_z F_{mcp}\)
- property nabla_Fmcp#
storage for \(\nabla_z F_{mcp}\)
- property env#
environment for the compute_Fmcp and compute_nabla_Fmcp function. When called from Python, it contains an object with compute_Fmcp and compute_nabla_Fmcp as methods. When called from C, it can reference a data struct containing variables needed for the computations.
- class siconos.numerics.MCP_old(*args)[source]#
Bases:
object
The structure that defines a Mixed Complementarity problem (MCP) : find two vectors \((z,w \in {{\mathrm{I\!R}}}^{n+m})\) such that:
\[\begin{split}w &= \begin{pmatrix}w_e\\w_i\end{pmatrix} = F(z) \ \ w_e &=0 \ \ 0 &\le w_i \perp z_i \ge 0\end{split}\]where “i” (resp. “e”) stands for inequalities (resp. equalities). The vector \(z\) is splitted like \(w\):
\[\begin{split}z =\begin{pmatrix}z_e\\z_i\end{pmatrix}\end{split}\]\(z_i,w_i\) are vectors of size sizeEqualities, \(z_e,w_e\) vectors of size sizeInequalities
and \(F\) is a non linear function that must be user-defined.
- property sizeEqualities#
size of equalities \(z_e, w_e\) size
- property sizeInequalities#
size of inequalities \(z_i,w_i\) size
- property computeFmcp#
pointer to the function to compute F(z)
- property Fmcp#
pointer to the function to compute the jacobian of F(z) The value F(z)
- property nablaFmcp#
jacobian of F(z)
- siconos.numerics.mixedComplementarityProblem_free(mcp)[source]#
free a MCP problem
- Parameters:
mcp (
MixedComplementarityProblem
) – structure to free
- siconos.numerics.mixedComplementarityProblem_new()[source]#
- Return type:
MixedComplementarityProblem
- Returns:
an empty MixedComplementarityProblem instance
- siconos.numerics.mixedComplementarityProblem_old_free(problem)[source]#
Delete a MixedComplementarityProblem_old
- Parameters:
problem (
MixedComplementarityProblem_old
) – pointer to a MixedComplementarityProblem_old to delete
- siconos.numerics.mcp_newton_FB_FBLSA(problem, z, Fmcp, options)[source]#
Solver based on Fischer-Burmeister reformulation and line search (VFBLSA in Facchinei–Pang 2003 p. 834)
- Parameters:
problem (
MixedComplementarityProblem
, in) – a structure which represents the MCPz (float, in/out) – a n1+n2-vector, initial solution + returns the solution of the problem.
Fmcp (float, out) – n1+n2-vector which contains the value of Fmcp(z) = (G(z), H(z))
info (int, out) – termination value: 0 if success else >0.
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mcp_newton_min_FBLSA(problem, z, Fmcp, options)[source]#
Solver based on Fischer-Burmeister reformulation and line search. The descent direction is found using a min reformulation (minFBLSA in Facchinei–Pang 2003 p. 855)
- Parameters:
problem (
MixedComplementarityProblem
, in) – a structure which represents the MCPz (float, in/out) – a n1+n2-vector, initial solution + returns the solution of the problem.
Fmcp (float, out) – n1+n2-vector which contains the value of Fmcp(z) = (G(z), H(z))
info (int, out) – termination value: 0 if success else >0.
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mcp_old_driver_init(problem, options)[source]#
Initialisation of the MCP solver (set problem, allocate working memory and so on. This routine must be called before any attempt to run the mcp_old_driver.
- Parameters:
problem (
MixedComplementarityProblem_old
, in) – the description of the MCPoptions (
SolverOptions
, in) – for the solver
- siconos.numerics.mcp_old_driver_reset(problem, options)[source]#
Reset of the MCP solver
- Parameters:
problem (
MixedComplementarityProblem_old
, in) – the description of the MCPoptions (
SolverOptions
, in) – for the solver
- siconos.numerics.mcp_old_FischerBurmeister(problem, z, w, options)[source]#
Fischer Burmeister solver
- Parameters:
problem (
MixedComplementarityProblem_old
, in) – a structure which represents the MCPz (float, in/out) – a m+n-vector, initial solution + returns the solution of the problem.
w (float, out) – not used
info (int, out) – termination value: 0 if success else >0.
options (
SolverOptions
, in/out) – structure used to define the solver and its parameters.
- siconos.numerics.mcp_old_FischerBurmeister_init(problem, options)[source]#
Initialisation of the MCP Fischer solver (set problem, allocate working memory and so on. This routine must be called before any attempt to run the mcp_old_driver.
- Parameters:
problem (
MixedComplementarityProblem_old
, in) – description of the MCPoptions (
SolverOptions
, in) – for the solver
- siconos.numerics.mcp_old_FischerBurmeister_reset(problem, options)[source]#
Reset of the MCP Fischer solver (free local variable)
- Parameters:
problem (
MixedComplementarityProblem_old
, in) – description of the MCPoptions (
SolverOptions
, in) – for the solver
- class siconos.numerics.NCP(*args)[source]#
Bases:
object
The structure that defines a Nonlinear Complementarity Problem (NCP) : Find two vectors \((z,w \in {{\mathrm{I\!R}}}^{n})\) such that:
\[\begin{split}w &= F(z) \\ 0 &\le w \perp z \ge 0\end{split}\]- property n#
size of the problem
- property compute_F#
pointer to the function used to compute \(F(z)\)
- property compute_nabla_F#
pointer to the function used to compute \(\nabla_z F(z)\)
- property nabla_F#
storage for \(\nabla_z F\)
- property env#
environment for the compute_Fmcp and compute_nabla_F function. When called from Python, it contains an object with compute_F and compute_nabla_F as methods. When called from C, it can reference a data struct containing variables needed for the computations.
- siconos.numerics.freeNCP(ncp)[source]#
free an NCP problem
- Parameters:
ncp (
NonlinearComplementarityProblem
) – structure to free
- siconos.numerics.newNCP()[source]#
create an empty NCP problem
- Return type:
NonlinearComplementarityProblem
- Returns:
an MixedComplementarityProblem instance
- siconos.numerics.ncp_compute_error(n, z, F, tol, err)[source]#
This function compute the complementarity error of the NCP: \(0 \leq z \perp F(z) \geq 0\).
- siconos.numerics.ncp_newton_FBLSA(problem, z, F, options)[source]#
NCP Solver using the FB merit function and a Newton-based method with line-search
- Parameters:
problem (
NonlinearComplementarityProblem
) – the formalization of the NCP problemz (float, in/out) – on input, initial guess; on output the solution
F (float) – the value of the function at the solution
info (int) – 0 if everything worked
options (
SolverOptions
) – struct used to specify the solver parameters
- siconos.numerics.ncp_newton_minFBLSA(problem, z, F, options)[source]#
NCP Solver using the min merit function (+ the FB as backup) and a Newton-based method with line-search
- Parameters:
problem (
NonlinearComplementarityProblem
) – the formalization of the NCP problemz (float, in/out) – on input, initial guess; on output the solution
F (float) – the value of the function at the solution
info (int) – 0 if everything worked
options (
SolverOptions
) – struct used to specify the solver parameters
- siconos.numerics.ncp_pathsearch(problem, z, F, options)[source]#
NCP Solver using a path search algorithm, following the work of D. Ralph. M. Ferris, and many other collaborators of the latter.
- Parameters:
problem (
NonlinearComplementarityProblem
) – the formalization of the NCP problemz (float, in/out) – on input, initial guess; on output the solution
F (float) – the value of the function at the solution
info (int) – 0 if everything worked
options (
SolverOptions
) – struct used to specify the solver parameters
- siconos.numerics.ncp_path(problem, z, F, options)[source]#
NCP Solver using the PATH solver
- Parameters:
problem (
NonlinearComplementarityProblem
) – the formalization of the NCP problemz (float, in/out) – on input, initial guess; on output the solution
F (float) – the value of the function at the solution
info (int) – 0 if everything worked
options (
SolverOptions
) – struct used to specify the solver parameters
- siconos.numerics.variationalInequality_display(vi)[source]#
display a VariationalInequalityProblem
- Parameters:
vi (
VariationalInequality
) – the problem to display
- siconos.numerics.variationalInequality_printInFile(vi, file)[source]#
print a VariationalInequalityProblem in a file (numerics .dat format)
- Parameters:
vi (
VariationalInequality
) – the problem to print outfile (FILE) – the dest file
- Return type:
- Returns:
ok if successfull
- siconos.numerics.variationalInequality_newFromFile(vi, file)[source]#
read a VariationalInequalityProblem in a file (numerics .dat format)
- Parameters:
vi (
VariationalInequality
) – the problem to readfile (FILE) – the target file
- Return type:
- Returns:
ok if successfull
- siconos.numerics.freeVariationalInequalityProblem(vi)[source]#
free a VariationalInequalityProblem
- Parameters:
vi (
VariationalInequality
) – the problem to free
- siconos.numerics.variationalInequality_clear(vi)[source]#
Clear VariationalInequality structure: set all pointeurs to NULL, double and int to 0
- Parameters:
vi (
VariationalInequality
) – the problem to clear
- siconos.numerics.variationalInequality_new(size)[source]#
new VariationalInequality problem
- Parameters:
size (int) – size of the ambient space for the VI
- Return type:
VariationalInequality
- Returns:
a initialized VariationalInequality struct
- siconos.numerics.newVI()[source]#
new VariationalInequality problem
- Return type:
VariationalInequality
- Returns:
an empty VI
- siconos.numerics.VI_get_env(vi)[source]#
get the environment from the struct
- Parameters:
vi (void) – a VariationalInequality problem
- Return type:
void
- Returns:
the environment from the struct
- siconos.numerics.variationalInequality_ExtraGradient(problem, x, w, options)[source]#
Extra Gradient solver forvariational inequality problem based on the De Saxce Formulation
- Parameters:
problem (
VariationalInequality
) – the variational inequality problem to solvex (float) – global vector (n), in-out parameter
w (float) – global vector (n), in-out parameters
info (int) – return 0 if the solution is found
options (
SolverOptions
) – the solver options iparam[SICONOS_IPARAM_MAX_ITER] : Maximum iteration number iparam[SICONOS_VI_IPARAM_LINESEARCH_METHOD] : Choice of the line search SICONOS_VI_LS_ARMIJO : Armijo rule with Khotbotov ratio (default) SICONOS_VI_LS_SOLODOV : Armijo rule with Solodov.Tseng ratio iparam[SICONOS_IPARAM_PREALLOC] : bool activate the update in the loop (0:false default choice) iparam[SICONOS_VI_IPARAM_DECREASE_RHO] : use rho_k * tau * min(1.0,a2/(rho_k*a1)) to decrease rho; commented in the code
dparam[SICONOS_VI_DPARAM_RHO] : rho parameter. If rho >0, then self-adaptive (Armijo like) procedure. If rho <0, then constant rho parameter (rho <– -rho) Adaptive step-size parameters: Adaptive step-size parameters: dparam[SICONOS_VI_DPARAM_LS_TAU] = 2/3.0; tau dparam[SICONOS_VI_DPARAM_LS_TAUINV] = 3.0/2.0; tauinv dparam[SICONOS_VI_DPARAM_LS_L] = 0.9; L dparam[SICONOS_VI_DPARAM_LS_MIN] = 0.3; Lmin
- siconos.numerics.variationalInequality_FixedPointProjection(problem, x, w, options)[source]#
Fixed Point Projection solver for variational inequality problem based on the De Saxce Formulation
- Parameters:
problem (
VariationalInequality
) – the variational inequality problem to solvex (float) – global vector (n), in-out parameter
w (float) – global vector (n), in-out parameters
info (int) – return 0 if the solution is found
options (
SolverOptions
) – the solver options : iparam[SICONOS_IPARAM_MAX_ITER] : Maximum iteration number iparam[SICONOS_VI_IPARAM_LINESEARCH_METHOD] : Choice of the line search SICONOS_VI_LS_ARMIJO : Armijo rule with Khotbotov ratio (default) SICONOS_VI_LS_SOLODOV : Armijo rule with Solodov.Tseng ratio SICONOS_VI_LS_HANSUN : Armijo rule with Han.Sun ratio iparam[SICONOS_IPARAM_PREALLOC] : bool activate the update in the loop (0:false default choice) iparam[SICONOS_VI_IPARAM_DECREASE_RHO] : use rho_k * tau * min(1.0,a2/(rho_k*a1)) to decrease rho; commented in the code dparam[SICONOS_VI_DPARAM_RHO] : rho parameter.
If rho >0, then self-adaptive (Armijo like) procedure.
If rho <0, then constant rho parameter (rho <– -rho)
Adaptive step-size parameters: dparam[SICONOS_VI_DPARAM_LS_TAU] = 2/3.0; tau dparam[SICONOS_VI_DPARAM_LS_TAUINV] = 3.0/2.0; tauinv dparam[SICONOS_VI_DPARAM_LS_L] = 0.9; L dparam[SICONOS_VI_DPARAM_LS_MIN] = 0.3; Lmin
- siconos.numerics.variationalInequality_HyperplaneProjection(problem, x, w, options)[source]#
Hyperplane Projection solver for variational inequality problem based on the De Saxce Formulation
- Parameters:
problem (
VariationalInequality
) – the variational inequality problem to solvex (float) – global vector (n), in-out parameter
w (float) – global vector (n), in-out parameters
info (int) – return 0 if the solution is found
options (
SolverOptions
) – the solver options
- siconos.numerics.variationalInequality_box_newton_QiLSA(problem, x, F, options)[source]#
VI Solver based on a merit function minimization with a line-search type algorithm
- Parameters:
problem (
VariationalInequality
) – the variational inequality problem to solvex (float, in/out) – as input, the initial guess; as output the solution if the algorithm is successful
F (float, in/out) – value of the function
info (int) – 0 if a solution is found
options (
SolverOptions
) – the solver options
- siconos.numerics.vi_box_AVI_LSA(problem, x, F, options)[source]#
VI Solver based on the Newton-Josephy method globalized with a line-search type algorithm using the Qi merit function.
- Parameters:
problem (
VariationalInequality
) – the variational inequality problem to solvex (float, in/out) – as input, the initial guess; as output the solution if the algorithm is successful
F (float, in/out) – value of the function
info (int) – 0 if a solution is found
options (
SolverOptions
) – the solver options
- siconos.numerics.vi_get_set(problem)[source]#
Get the set from the VariationalInequality
- Parameters:
problem (void) – the VI
- siconos.numerics.vi_box_path(problem, z, F, options)[source]#
Solver for box constrainted VI using PATH.
- Parameters:
problem (
VariationalInequality
) – the variational inequality problem to solvez (float, in/out) – as input, the initial guess; as output the solution if the algorithm is successful
F (float, in/out) – value of the function
info (int) – 0 if a solution is found
options (
SolverOptions
) – the solver options
- siconos.numerics.checkTrivialCase_vi(problem, x, fx, options)[source]#
Check for trivial solution in the variational inequality problem
- Parameters:
problem (
VariationalInequality
) – VariationalInequality* the problemx (float) – global vector (n), in-out parameter
fx (float) – global vector (n), in-out parameters
options (
SolverOptions
) – the pointer to the array of options to set
- Return type:
- Returns:
info =0 if a trivial solution has been found, else = -1
- siconos.numerics.convexQP_display(cqp)[source]#
display a ConvexQPProblem
- Parameters:
cqp (
ConvexQP
) – the problem to display
- siconos.numerics.convexQP_printInFile(cqp, file)[source]#
print a ConvexQPProblem in a file (numerics .dat format)
- Parameters:
cqp (
ConvexQP
) – the problem to print outfile (FILE) – the dest file
- Return type:
- Returns:
ok if successfull
- siconos.numerics.convexQP_newFromFile(cqp, file)[source]#
read a ConvexQPProblem in a file (numerics .dat format)
- Parameters:
cqp (
ConvexQP
) – the problem to readfile (FILE) – the target file
- Return type:
- Returns:
ok if successfull
- siconos.numerics.convexQP_free(cqp)[source]#
free a ConvexQPProblem
- Parameters:
cqp (
ConvexQP
) – the problem to free
- siconos.numerics.convexQP_clear(cqp)[source]#
Clear ConvexQP structure: set all pointeurs to NULL, double and int to 0.
- Parameters:
cqp (
ConvexQP
) – the problem to clear
- siconos.numerics.convexQP_new(size)[source]#
new ConvexQP problem
- Parameters:
size (int) – size of the ambient space for the CQP
- Return type:
ConvexQP
- Returns:
a initialized ConvexQP struct
- siconos.numerics.convexQP_get_env(cqp)[source]#
get the environment from the struct
- Parameters:
cqp (void) – a ConvexQP problem
- Return type:
void
- Returns:
the environment from the struct
- siconos.numerics.convexQP_ProjectedGradient(problem, z, w, options)[source]#
Projected Gradient solver for Convex QP problem
- Parameters:
problem (
ConvexQP
) – the variational inequality problem to solvez (float) – global vector (n), in-out parameter
w (float) – global vector (n), in-out parameters
info (int) – return 0 if the solution is found
options (
SolverOptions
) – the solver options : iparam[0] : Maximum iteration number
dparam[3] : rho parameter. If rho >0, then self-adaptive (Armijo like) procedure. If rho <0, then constant rho parameter (rho <– -rho) Adaptive step-size parameters: Adaptive step-size parameters: dparam[4] = 2/3.0; tau dparam[5] = 3.0/2.0; tauinv dparam[6] = 0.9; L dparam[7] = 0.3; Lmin