cuiksystem.h File Reference

Introduction

Definition of the TCuikSystem type and the associated functions.

See also
TCuikSystem, cuiksystem.c, readcuiksystem.l, readcuiksystem.y,

Definition in file cuiksystem.h.

Data Structures

struct  TCuikSystem
 A cuiksystem, i.e., a set of variables and equations defining a position analysis problem. More...
 

Macros

#define EQ_MIN_IN_CENTER   0
 Set to 1 to sort boxes according to the evaluation in its center. More...
 
#define NEWTON_WITHIN_RANGES   0
 Set to one to avoid Newton to scape from boxes. More...
 
#define DEPTH_FIRST_SEARCH   1
 Depth first search. More...
 
#define BREADTH_FIRST_SEARCH   2
 Breadth first search. More...
 
#define MINIMIZATION_SEARCH   3
 Search based on a minimum value of a given equation. More...
 
#define CUT_POINT   0.45+0.1*randomDouble()
 Point, relative to the size of the selected box side, where we split a box. More...
 
#define MPI_TREAT_BOX_TIMEOUT(cs)   (cs->nvariables*SIMPLEX_TIMEOUT*10)
 MPI child-process timeout. More...
 
#define DIVERGED   1
 One of the possible outputs of the Newton iteration. More...
 
#define CONVERGED_IN_BOX   2
 One of the possible outputs of the Newton iteration. More...
 
#define CONVERGED_IN_GLOBAL   4
 One of the possible outputs of the Newton iteration. More...
 
#define CONVERGED_OUTSIDE_GLOBAL   8
 One of the possible outputs of the Newton iteration. More...
 
#define CONVERGED   (CONVERGED_IN_BOX|CONVERGED_IN_GLOBAL|CONVERGED_OUTSIDE_GLOBAL)
 Union of all possible convergence cases for Newton interation. More...
 

Functions

void InitCuikSystem (TCuikSystem *cs)
 Constructor. More...
 
void InitCuikSystemFromFile (Tparameters *p, char *filename, TCuikSystem *cs)
 Constructor from a file. More...
 
void AddCuikSystemFromFile (Tparameters *p, boolean prefix, Tconstants *cts, char *filename, TCuikSystem *cs)
 Adds information from a file. More...
 
void VerifyCuikSystem (Tparameters *p, TCuikSystem *cs)
 Checks the consistency of the cuiksystem. More...
 
void CopyCuikSystem (TCuikSystem *cs_dst, TCuikSystem *cs_src)
 Copy constructor. More...
 
void CuikSystemMerge (Tparameters *p, TCuikSystem *cs1, TCuikSystem *cs2, TCuikSystem *cs)
 Produces the union of two cuik systems. More...
 
boolean CmpBoxesEquation (void *b1, void *b2, void *cs)
 Determines which box to explore first in minimization mode. More...
 
void SetCSSearchMode (unsigned int sm, Tequation *eqMin, TCuikSystem *cs)
 Sets the search mode for the cuiksystem. More...
 
void AddTerm2SearchCriterion (double w, unsigned int v, double val, TCuikSystem *cs)
 Adds penalty terms to the search criterion. More...
 
unsigned int AddVariable2CS (Tvariable *v, TCuikSystem *cs)
 Adds a variable to the system. More...
 
void AddEquation2CS (Tparameters *p, Tequation *eq, TCuikSystem *cs)
 Adds an equation to the system. More...
 
void AddMatrixEquation2CS (Tparameters *p, TMequation *eq, TCuikSystem *cs)
 Adds a matrix equation to the system. More...
 
void GetCSVariables (Tvariables *vs, TCuikSystem *cs)
 Gets the cuiksystem variables. More...
 
void GetCSVariableNames (char **varNames, TCuikSystem *cs)
 Gets points to the variable names. More...
 
unsigned int GetCSNumVariables (TCuikSystem *cs)
 Gets the number of variables already in the cuiksystem. More...
 
unsigned int GetCSNumSystemVariables (TCuikSystem *cs)
 Gets the number of system variables already in the cuiksystem. More...
 
unsigned int GetCSNumNonDynamicVariables (TCuikSystem *cs)
 Gets the number of non dynamic variables already in the cuiksystem. More...
 
unsigned int GetCSNumNonDummyVariables (TCuikSystem *cs)
 Gets the number of non-dummy variables already in the cuiksystem. More...
 
boolean CuikHasVelocity (Tparameters *p, TCuikSystem *cs)
 Determines if a cuiksystem includes velocity information. More...
 
void GetCSVariable (unsigned int n, Tvariable *v, TCuikSystem *cs)
 Gets the a variable from a cuiksystem. More...
 
void SetCSVariableRange (unsigned int n, Tinterval *r, TCuikSystem *cs)
 Gets the range of a variable from a cuiksystem. More...
 
unsigned int GetCSVariableID (char *name, TCuikSystem *cs)
 Gets the numerical identifier of a variable given its name. More...
 
char * GetCSVariableName (unsigned int id, TCuikSystem *cs)
 Gets a variable name. More...
 
char * GetCSSystemVariableName (unsigned int id, TCuikSystem *cs)
 Gets a system variable name. More...
 
boolean IsSystemVarInSimpCS (Tparameters *p, char *v, TCuikSystem *cs)
 Identifies system variables that survive in the simplified system. More...
 
unsigned int GetCSSystemVars (boolean **sv, TCuikSystem *cs)
 Identifies the system variables. More...
 
unsigned int GetCSPositionVars (boolean **pv, TCuikSystem *cs)
 Identifies the position variables. More...
 
unsigned int GetCSPositionEqs (boolean **pv, TCuikSystem *cs)
 Identifies the position equations. More...
 
unsigned int GetCSPositionVelocityVars (boolean **pv, TCuikSystem *cs)
 Identifies the position or velocity variables. More...
 
unsigned int GetCSPositionVelocityEqs (boolean **pv, TCuikSystem *cs)
 Identifies the position or velocity equations. More...
 
unsigned int GetCSVarTopology (unsigned int vID, TCuikSystem *cs)
 Determines the topology of a given variable. More...
 
void GetCSEquations (Tequations *eqs, TCuikSystem *cs)
 Gets a copy of the system equations. More...
 
unsigned int GetCSNumEquations (TCuikSystem *cs)
 Gets the number of equations already in the cuiksystem. More...
 
void GetCSEquation (unsigned int n, Tequation *eq, TCuikSystem *cs)
 Gets the an equation from a cuiksystem. More...
 
boolean IsCSPolynomial (TCuikSystem *cs)
 Identifies polynomial cuiksystems. More...
 
boolean IsCSScalar (TCuikSystem *cs)
 Identifies scalar cuiksystems. More...
 
void GetCSJacobian (TJacobian *J, TCuikSystem *cs)
 Defines the Jacobian of a CuikSystem. More...
 
unsigned int GetSimpCSTopology (Tparameters *p, unsigned int **t, TCuikSystem *cs)
 Topology of the variables in the simplified system. More...
 
unsigned int GetCSTopology (Tparameters *p, unsigned int **t, TCuikSystem *cs)
 Topology of the variables in the system. More...
 
void GetSimpCSJacobian (Tparameters *p, TJacobian *J, TCuikSystem *cs)
 Defines the Jacobian of a simplified CuikSystem. More...
 
boolean GetSimpCSNJacobian (Tparameters *p, TNJacobian *nJ, TCuikSystem *cs)
 Defines the numerical Jacobian of a simplified CuikSystem. More...
 
boolean GetSimpCSNHessian (Tparameters *p, TJacobian *sJ, TNHessian *nH, TCuikSystem *cs)
 Defines the numerical Hessian of a simplified CuikSystem. More...
 
void AddJacobianEquations (Tparameters *p, boolean *selectedVars, TCuikSystem *cs)
 Adds linear a linear combination of the Jacobian to the system. More...
 
void AddVelocityEquations (Tparameters *p, double *vl, TCuikSystem *cs)
 Adds the velocity equations. More...
 
void AddSimplifiedJacobianEquations (Tparameters *p, boolean *selectedVars, TCuikSystem *cs)
 Adds a linear combination of the Jacobian to the system. More...
 
unsigned int MaxReduction (Tparameters *p, unsigned int varMask, double *r, Tbox *b, TCuikSystem *cs)
 Reduces a box as much as possible. More...
 
boolean SampleCuikSystem (Tparameters *p, char *fname, Tlist *sb, unsigned int nsamples, unsigned int ntries, unsigned int ndof, TCuikSystem *cs)
 Generates samples for a cuiksystem. More...
 
boolean SampleCuikSystemInBox (Tparameters *p, char *fname, Tlist *sb, unsigned int nsamples, unsigned int ntries, unsigned int ndof, Tbox *init_box, TCuikSystem *cs)
 Generates samples for a cuiksystem in given box. More...
 
boolean IncrementalSampleCuikSystem (Tparameters *p, char *fname, Tlist *sb, boolean *fixVars, unsigned int nsamples, unsigned int ntries, unsigned int ndof, TCuikSystem *cs)
 Generates samples for a cuiksystem. More...
 
boolean IncrementalSampleCuikSystemInBox (Tparameters *p, char *fname, Tlist *sb, boolean *fixVars, unsigned int nsamples, unsigned int ntries, unsigned int ndof, Tbox *init_box, TCuikSystem *cs)
 Generates samples for a cuiksystem in given box. More...
 
unsigned int CuikNewtonSimp (Tparameters *p, double *x, TCuikSystem *cs)
 CuikNewton on the simplified system. More...
 
unsigned int CuikNewtonInBox (Tparameters *p, Tbox *bIn, double *sol, Tbox *b_sol, TCuikSystem *cs)
 Applies Newton-Rhapson to a set of equations. More...
 
boolean CuikNewton (Tparameters *p, double *sol, Tbox *b_sol, TCuikSystem *cs)
 Applies Newton-Rhapson to a set of equations. More...
 
unsigned int CuikGradientInBox (Tparameters *p, Tbox *bIn, double *sol, Tbox *b_sol, TCuikSystem *cs)
 Applies gradient descent to a set of equations. More...
 
boolean CuikGradient (Tparameters *p, double *sol, Tbox *b_sol, TCuikSystem *cs)
 Applies gradient descent to a set of equations. More...
 
void SolveCuikSystem (Tparameters *p, boolean restart, char *fstate, Tbox *searchSpace, FILE *f_out, Tlist *sol, TCuikSystem *cs)
 Determines the solution set for a cuiksystem. More...
 
void MPI_SolveCuikSystem (Tparameters *p, boolean restart, char *fstate, Tbox *searchSpace, FILE *f_out, TCuikSystem *cs)
 Determines the solution set for a cuiksystem. Main scheduler. More...
 
void MPI_TreatBox (Tparameters *p, TCuikSystem *cs)
 Determines the solution set for a cuiksystem. Child process. More...
 
void GenerateInitialBox (Tbox *box, TCuikSystem *cs)
 Gives the search space in the form of a box. More...
 
void GenerateSimpInitialBox (Tparameters *p, Tbox *box, TCuikSystem *cs)
 Gives the search space in the form of a box for the simplified system. More...
 
boolean RegenerateSolution (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Regenerates a box from the system variables. More...
 
unsigned int RegenerateSolutionPoint (Tparameters *p, double *pt, double **rp, TCuikSystem *cs)
 Regenerates a solution point from the system variables. More...
 
void RegenerateOriginalBox (Tparameters *p, Tbox *boxS, Tbox *boxO, TCuikSystem *cs)
 Generates a box in the original cuiksystem from a box of the simplified one. More...
 
unsigned int RegenerateOriginalPoint (Tparameters *p, double *s, double **o, TCuikSystem *cs)
 Generates an original point from a simplified point. More...
 
unsigned int GenerateSimplifiedPoint (Tparameters *p, double *o, double **s, TCuikSystem *cs)
 Generates a simplified point. More...
 
unsigned int SimplifyBooleanArray (Tparameters *p, boolean *bo, boolean **bs, TCuikSystem *cs)
 Transforms arrays of booleans from the original to the simplified system. More...
 
unsigned int ComputeSplitDim (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Determines the best dimensions to split a given box. More...
 
boolean PointInSystemBox (Tvector *v, Tbox *b, TCuikSystem *cs)
 Determines if a given point is fully included in the system sub-box (i.e., the sub-box fot the system variables). More...
 
void EvaluateCSEquations (double *p, double *r, TCuikSystem *cs)
 Evaluates the equation set on a point. More...
 
void EvaluateSimpCSEquations (Tparameters *pr, double *p, double *r, TCuikSystem *cs)
 Evaluates the simplified equation set on a point. More...
 
void EvaluateSubSetSimpCSEquations (Tparameters *pr, boolean *se, double *p, double *r, TCuikSystem *cs)
 Evaluates a subset of the simplified equation set on a point. More...
 
double ErrorInCSEquations (Tparameters *pr, double *p, TCuikSystem *cs)
 Evalates the norm of the error in a point. More...
 
double ErrorInSimpCSEquations (Tparameters *pr, double *p, TCuikSystem *cs)
 Evaluates the norm of the error in a point for the simplified equations. More...
 
double EvaluateCSCost (Tparameters *p, boolean simp, double *s, void *cs)
 Evalutes the equation to minimize in a given point. More...
 
void EvaluateCSJacobian (double *p, double ***J, TCuikSystem *cs)
 Evaluates the Jacobian of the system in a given point. More...
 
double ErrorInSolution (Tbox *b, TCuikSystem *cs)
 Maximum error for a box. More...
 
double ErrorInInequalities (Tbox *b, TCuikSystem *cs)
 Maximum inequality error for a box. More...
 
boolean InequalitiesHoldOnPoint (double *p, TCuikSystem *cs)
 Tests if all inqualities hold for a given point. More...
 
boolean SimpInequalitiesHoldOnPoint (Tparameters *pr, double *p, TCuikSystem *cs)
 Tests if all simplified inqualities hold for a given point. More...
 
double ErrorInSimpInequalitiesOnPoint (Tparameters *pr, double *p, TCuikSystem *cs)
 Computes the maximum error in all the simplified inqualities for a given point. More...
 
unsigned int ManifoldDimension (Tparameters *pr, double *p, TCuikSystem *cs)
 Computes the dimension of the solution space. More...
 
void PrintCuikSystem (Tparameters *p, FILE *f, TCuikSystem *cs)
 Prints a cuiksystem. More...
 
void PrintCuikSystemWithSimplification (Tparameters *p, FILE *f, TCuikSystem *cs)
 Prints the simplified cuiksystem. More...
 
void SaveCuikSystemSimplification (Tparameters *p, FILE *f, TCuikSystem *cs)
 Saves the simplification information associated with a cuiksystem. More...
 
void DeleteCuikSystem (TCuikSystem *cs)
 Destructor. More...
 

Macro Definition Documentation

◆ EQ_MIN_IN_CENTER

#define EQ_MIN_IN_CENTER   0

Boxes to be reduced can be sorted according to a given equation. If this is set to 1 we evaluate this equation in the center of each box If set to 1 we evaluate the equation interval-wise and take the center of the resulting interval.

Todo:
Just select the evaluation method that is better and remove the other.

Definition at line 41 of file cuiksystem.h.

◆ NEWTON_WITHIN_RANGES

#define NEWTON_WITHIN_RANGES   0

Set to one to avoid Newton to scape from boxes.

Todo:
Remove this if box limits do not help at all

Definition at line 49 of file cuiksystem.h.

◆ DEPTH_FIRST_SEARCH

#define DEPTH_FIRST_SEARCH   1

In this mode, boxes to be reduced are sorted so that boxes with a higher level (i.e., resulting from more bisections) are treated first.

Definition at line 57 of file cuiksystem.h.

◆ BREADTH_FIRST_SEARCH

#define BREADTH_FIRST_SEARCH   2

In this mode, boxes to be reduced are sorted so that boxes with a smaller level (i.e., resulting from less bisections) are treated first.

Definition at line 66 of file cuiksystem.h.

◆ MINIMIZATION_SEARCH

#define MINIMIZATION_SEARCH   3

In this mode, boxes to be reduced are sorted so that we tread first boxes whose value with repect to a given equation are minimal (among all boxes pending to be treated).

In the current implementation the center of the box is used to evaluate the criterion to be minimized.

Definition at line 79 of file cuiksystem.h.

◆ CUT_POINT

#define CUT_POINT   0.45+0.1*randomDouble()

Point, relative to the size of the selected box side, where we split a box.

Definition at line 91 of file cuiksystem.h.

◆ MPI_TREAT_BOX_TIMEOUT

#define MPI_TREAT_BOX_TIMEOUT (   cs)    (cs->nvariables*SIMPLEX_TIMEOUT*10)

Maximum time (in seconds) we give a child-process to reduce a box. Only used when cuik is executed in a multi-processor environment.

Definition at line 103 of file cuiksystem.h.

◆ DIVERGED

#define DIVERGED   1

Returned by CuikNewtonInBox when the Newton iteration was repeated for more than CT_MAX_NEWTON_ITERATIONS times without reaching a stationary point.

Definition at line 114 of file cuiksystem.h.

◆ CONVERGED_IN_BOX

#define CONVERGED_IN_BOX   2

Returned by CuikNewtonInBox when the Newton iteration converged to a point inside the given box.

Note that if the Newton converges in the current box it also converges in the initial box however the more restrictive condition (convergence in local box) is returned.

Definition at line 127 of file cuiksystem.h.

◆ CONVERGED_IN_GLOBAL

#define CONVERGED_IN_GLOBAL   4

Returned by CuikNewtonInBox when the Newton iteration converged to a point outside the given box, but inside the initial box.

Note that if the Newton converges in the current box it also converges in the initial box however the more restrictive condition (convergence in local box) is returned.

Definition at line 141 of file cuiksystem.h.

◆ CONVERGED_OUTSIDE_GLOBAL

#define CONVERGED_OUTSIDE_GLOBAL   8

Returned by CuikNewtonInBox when the Newton iteration converged but to a point that is outside the initial box.

Note that this is only returned if the process converged but outside the global box.

Definition at line 153 of file cuiksystem.h.

◆ CONVERGED

The union of all possible convergence cases for Newton iteration. Provide to facilitate the test whether or not a call actually converged (to anywhere)

Definition at line 161 of file cuiksystem.h.

Function Documentation

◆ InitCuikSystem()

◆ InitCuikSystemFromFile()

void InitCuikSystemFromFile ( Tparameters p,
char *  filename,
TCuikSystem cs 
)

Creates an cuiksystem from the information on a file. Right now we do not have a manual of the syntax of the ".cuik" files so check the examples in the CuikSuite examples directory or in the benchmarks section of our web page

Parameters
pA set of parameters.
filenameThe name of the file from which to read the variables and equations.
csThe cuiksystem to initialize.

Referenced by InitCSWDFromFile(), and main().

◆ AddCuikSystemFromFile()

void AddCuikSystemFromFile ( Tparameters p,
boolean  prefix,
Tconstants cts,
char *  filename,
TCuikSystem cs 
)

Adds information (constants/variables/equations) to a cuiksystem from another file. This is typically used to build a cuiksystem from a set of files where each file assumes we already loaded the previous ones (when adding contact equations to a cuiksystem or eigengrasp equations or singularity equations or....).

This function is exacty the same as InitCuikSystemFromFile but the system is not initialized from scratch but assumed pre-initialized.

Parameters
pA set of parameter.
prefixTRUE if the cuiksystem has been automatically generated. In this case the variables and constants have '_' as a prefix. This is the case when inserting a cuik file into a world file. In this case, the names of the variables are generated accordingly (adding '_').
ctsOptional set constants so that they can be used in the new added cuiksystem. This is only useful when adding equations to those automatically generated equation set. In this case we may need the new added equations to re-used some of the constants appearing in the world file. Thus the world constants are used to initialize the constants in the cuiksystem to add. Otherwise, this paremeter should be NULL.
filenameThe name of the file from which to read the variables and equations.
csThe cuiksystem to initialize.

Referenced by GenerateWorldEquations(), and main().

◆ VerifyCuikSystem()

void VerifyCuikSystem ( Tparameters p,
TCuikSystem cs 
)

Checks the consistency of the cuiksystem. If the system is inconsistent an error is trigered. Note that if new equations/variables are added to the cuiksystem its consistancy might no longer hold.

Parameters
pThe set of parameters.
csThe cuiksystem to verify.

Definition at line 2226 of file cuiksystem.c.

References Error(), and UpdateCuikSystem().

Referenced by main().

◆ CopyCuikSystem()

◆ CuikSystemMerge()

void CuikSystemMerge ( Tparameters p,
TCuikSystem cs1,
TCuikSystem cs2,
TCuikSystem cs 
)

Defines a new cuiksystem by union of two given cuiksystems.

CAUTION!

  • The variables for one of the input systems must be a subset (or equal) of the variable set of the other system. If this is not so the result is undefined.
Parameters
pThe set of parameters.
cs1The first cuik system merge.
cs2The second cuiksystem to merge.
csThe output merged cuiksystem.

Definition at line 2355 of file cuiksystem.c.

References AccumulateEquations(), AddVariable2CS(), TCuikSystem::consistent, TCuikSystem::constants, CopyEquation(), CopyEquations(), CopyVariables(), TCuikSystem::empty, FALSE, GetVariable(), InitCuikSystem(), MergeConstants(), MergeEquations(), TCuikSystem::nequations, TCuikSystem::notDummyVar, NVariables(), TCuikSystem::nvariables, TCuikSystem::orig2sd, TCuikSystem::orig_eqMin, TCuikSystem::orig_equations, TCuikSystem::orig_nequations, TCuikSystem::orig_notDummyVar, TCuikSystem::orig_nvariables, TCuikSystem::orig_systemVar, TCuikSystem::orig_variables, TCuikSystem::scalar, ScalarEquations(), TCuikSystem::searchMode, TCuikSystem::simp_empty, TCuikSystem::systemVar, TRUE, TCuikSystem::updated, and TCuikSystem::varType.

◆ CmpBoxesEquation()

boolean CmpBoxesEquation ( void *  b1,
void *  b2,
void *  cs 
)

Determines which box to explore first in minimization mode. In this mode boxes are sorted according to an objective function given by an equation in the problem file. The equation is evaluated at the center of the box and the box with a minimum value is processed first.

Parameters
b1The first box.
b2The second box.
csThe TCuikSystem structure storing the equation to use when evaluating
Returns
TRUE if the first box is to be explored before than the second one when in minimization mode.
See also
EvaluateEqMin

Definition at line 2448 of file cuiksystem.c.

References EvaluateEqMin().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

◆ SetCSSearchMode()

void SetCSSearchMode ( unsigned int  sm,
Tequation eqMin,
TCuikSystem cs 
)

Defines the criterion to be used sorting the boxes to be treated when searching for a solution.

Possible critera are

  • Depth First
  • Breadth First
  • Minimum value for a given equation first.
Parameters
smSearch mode: DEPTH_FIRST_SEARCH, BREADTH_FIRST_SEARCH or MINIMIZATION_SEARCH.
eqMinWhen the search mode is MINIMIZATION_SEARCH, the criterion to be minimized. Otherwise it is not used.
csThe cuiksystem to update.

Definition at line 2453 of file cuiksystem.c.

References BREADTH_FIRST_SEARCH, CopyEquation(), DeleteEquation(), DEPTH_FIRST_SEARCH, Error(), MINIMIZATION_SEARCH, TCuikSystem::orig_eqMin, TCuikSystem::searchMode, UnUpdateCuikSystem(), and TCuikSystem::updated.

Referenced by AddTerm2SearchCriterion().

◆ AddTerm2SearchCriterion()

void AddTerm2SearchCriterion ( double  w,
unsigned int  v,
double  val,
TCuikSystem cs 
)

Adds the

$w(v-val)^2$

to the equation guiding the search.
This is useful when incrementally defining a penalty function where we aim of finding solutions in the center of the range of some variables.

This function automatically calls SetCSSearchMode to set the search mode to MINIMIZATION_SEARCH it is is not so.

Parameters
wWeight for the new constraint to add.
vVariable for the new constraint to add.
valTarged value for the new variable. Typically the center of the variable range.
csThe cuiksystem to update.

Definition at line 2476 of file cuiksystem.c.

References AccumulateEquations(), AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteEquation(), DeleteMonomial(), EQU, InitEquation(), InitMonomial(), MINIMIZATION_SEARCH, NFUN, TCuikSystem::orig_eqMin, ResetMonomial(), TCuikSystem::searchMode, SetCSSearchMode(), SetEquationCmp(), UnUpdateCuikSystem(), and TCuikSystem::updated.

Referenced by GenerateJointRangeEquations().

◆ AddVariable2CS()

unsigned int AddVariable2CS ( Tvariable v,
TCuikSystem cs 
)

Adds a new variable to the system.

Parameters
vThe variable to add.
csThe cuiksystem where to add the variable.
Returns
The numerical identifier assigned to the new variable. If there is another variable with the same name, this function generates an error.

Definition at line 2551 of file cuiksystem.c.

References AddVariable(), GetVariableID(), GetVariableName(), NO_UINT, TCuikSystem::orig_variables, UnUpdateCuikSystem(), and TCuikSystem::updated.

Referenced by AddJacobianEquationsInt(), AddVelocityEquations(), AdjustBioWorldGeometry(), CuikSystemMerge(), GenerateEquationsFromBranch(), GenerateJointEquations(), GenerateJointRangeEquations(), GenerateJointRangeSingularityEquations(), GenerateLinkConf(), GenerateLinkRotAxisX(), GenerateLinkRotFLinks(), GenerateLinkRotLinks(), GenerateLinkRotQLinks(), GenerateWorldSingularityEquations(), and GetSCpSystem().

◆ AddEquation2CS()

void AddEquation2CS ( Tparameters p,
Tequation eq,
TCuikSystem cs 
)

◆ AddMatrixEquation2CS()

void AddMatrixEquation2CS ( Tparameters p,
TMequation eq,
TCuikSystem cs 
)

Adds a new matrix equation to the system. The equation must use the variables already added to the system. No check is performed to determine if the matrix equation is repeated.

Parameters
pA set of parameters.
eqThe matrix equation to add.
csThe cuiksystem where to add the equation.

Definition at line 2531 of file cuiksystem.c.

References AddMatrixEquation(), Error(), FALSE, TCuikSystem::orig_equations, TCuikSystem::scalar, SimplifiedMEquation(), UnUpdateCuikSystem(), and TCuikSystem::updated.

Referenced by GenerateEquationsFromBranch().

◆ GetCSVariables()

void GetCSVariables ( Tvariables vs,
TCuikSystem cs 
)

Returns a copy of the variables stored in the cuiksystem. This can be seen as a Tvariables copy constructor, thus the output variables does not need to be initialized beforehand.

Parameters
vsPointer to the space where to copy the variables.
csThe cuiksystem from where to get the variables.
See also
CopyVaribles

Definition at line 2569 of file cuiksystem.c.

References CopyVariables(), and TCuikSystem::orig_variables.

Referenced by GenerateWorldEquations().

◆ GetCSVariableNames()

void GetCSVariableNames ( char **  varNames,
TCuikSystem cs 
)

Initializes an array of pointers to variable names.

This is used to print boxes.

Parameters
varNamesThe array where to store the pointers. This array must be allocated/deallocated externally.
csThe cuiksystem to query.

Definition at line 2574 of file cuiksystem.c.

References GetVariableNames(), and TCuikSystem::orig_variables.

Referenced by AdjustBioWorldGeometry(), and GetWorldVarNames().

◆ GetCSNumVariables()

unsigned int GetCSNumVariables ( TCuikSystem cs)

Returns the number of variables already in the cuiksystem.

Parameters
csThe cuiksystem to query.
Returns
The number of variables already in the cuiksystem.

Definition at line 2584 of file cuiksystem.c.

References NVariables(), and TCuikSystem::orig_variables.

Referenced by DealWithCP(), GenerateWorldTWSEquations(), GetSCpSystem(), GetWorldNumVariables(), GetWorldSimpVariableMask(), IncrementalSampleCuikSystemInBox(), main(), MoveWorld(), RegenerateWorldSolutionPoint(), SampleCuikSystemInBox(), and WorldDOF2Sol().

◆ GetCSNumSystemVariables()

unsigned int GetCSNumSystemVariables ( TCuikSystem cs)

Returns the number of system variables in the cuiksystem. System variables are system+secondary (see GetCSSystemVars).

Parameters
csThe cuiksystem to query.
Returns
The number of system variables already in the cuiksystem.

Definition at line 2589 of file cuiksystem.c.

References GetNumNonDynamicVariables(), GetNumSecondaryVariables(), GetNumSystemVariables(), GetNumVelocityVariables(), and TCuikSystem::orig_variables.

Referenced by GetSolutionPointFromLinkTransforms(), GetWorldNumSystemVariables(), main(), MoveWorld(), and RegenerateWorldOriginalSystemPoint().

◆ GetCSNumNonDynamicVariables()

unsigned int GetCSNumNonDynamicVariables ( TCuikSystem cs)

Returns the number of non dynamic variables in the cuiksystem.

Parameters
csThe cuiksystem to query.
Returns
The number of non dynamic variables already in the cuiksystem.

Definition at line 2598 of file cuiksystem.c.

References GetNumNonDynamicVariables(), and TCuikSystem::orig_variables.

◆ GetCSNumNonDummyVariables()

unsigned int GetCSNumNonDummyVariables ( TCuikSystem cs)

Returns the number of non-dummy (i.e., the sum of system, secondary and cartesian variables) variables already in the cuiksystem.

Parameters
csThe cuiksystem to query.
Returns
The number of non-dummy variables already in the cuiksystem.

Definition at line 2606 of file cuiksystem.c.

References GetNumDummyVariables(), NVariables(), and TCuikSystem::orig_variables.

Referenced by AnimateWorld().

◆ CuikHasVelocity()

boolean CuikHasVelocity ( Tparameters p,
TCuikSystem cs 
)

Determines if a cuiksystem includes velocity information.

Parameters
pThe set of parameters.
csThe CuikSystem to query.

Definition at line 2611 of file cuiksystem.c.

References Error(), GetNumVelocityVariables(), NVelocityEquations(), TCuikSystem::simp_equations, TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by main(), and WorldHasVelocity().

◆ GetCSVariable()

void GetCSVariable ( unsigned int  n,
Tvariable v,
TCuikSystem cs 
)

Returns a copy of one of the variables of the cuiksystem. This can be seen as a Tvariable copy constructor, thus the output variable does not need to be initialized beforehand.

Parameters
nNumerical identifier of the variable to get.
vPlace where to store the copy of the variable.
csThe cuiksystem to query.
See also
CopyVariable

Definition at line 2623 of file cuiksystem.c.

References CopyVariable(), GetVariable(), and TCuikSystem::orig_variables.

◆ SetCSVariableRange()

void SetCSVariableRange ( unsigned int  n,
Tinterval r,
TCuikSystem cs 
)

Returns a copy of the range of one of the variables of the cuiksystem. This can be seen as a Tinterval constructor, thus the output interval does not need to be initialized beforehand.

Parameters
nNumerical identifier of the variable to get.
rPlace where to store the copy of the interval.
csThe cuiksystem to query.
See also
CopyInterval

Definition at line 2631 of file cuiksystem.c.

References GetVariable(), TCuikSystem::orig_variables, SetVariableInterval(), UnUpdateCuikSystem(), and TCuikSystem::updated.

Referenced by GetSCpSystem(), and SampleCuikSystemInBox().

◆ GetCSVariableID()

◆ GetCSVariableName()

char* GetCSVariableName ( unsigned int  id,
TCuikSystem cs 
)

Gets the name of a particular variable. The returned pointer should not be manipulated.

Parameters
idThe index of the variable.
csThe CuikSystem to query.
Returns
A pointer to the variable name of NULL if the variable does not exists.

Definition at line 2648 of file cuiksystem.c.

References TCuikSystem::orig_variables, and VariableName().

Referenced by GetLinkPoseSimpVars().

◆ GetCSSystemVariableName()

char* GetCSSystemVariableName ( unsigned int  id,
TCuikSystem cs 
)

Gets the name of a particular system variable. The returned pointer should not be manipulated.

Parameters
idThe index of the system variable (over all the system variables).
csThe CuikSystem to query.
Returns
A pointer to the variable name of NULL if the variable does not exists.

Definition at line 2653 of file cuiksystem.c.

References FALSE, IsPositionVariable(), IsSecondaryVariable(), IsSystemVariable(), NVariables(), TCuikSystem::orig_variables, TRUE, and VariableName().

Referenced by GetWorldSystemVarName().

◆ IsSystemVarInSimpCS()

boolean IsSystemVarInSimpCS ( Tparameters p,
char *  v,
TCuikSystem cs 
)

Identifies system variables that survive in the simplified system.

Parameters
pThe set of parameters.
vThe variable name.
csThe cuiksystem to query.
Returns
TRUE if the variable exists in the simplified system.

Definition at line 2678 of file cuiksystem.c.

References Error(), GetVariableID(), IsPositionVariable(), IsSecondaryVariable(), IsSystemVariable(), NO_UINT, TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by GetLinkPoseSimpVars().

◆ GetCSSystemVars()

unsigned int GetCSSystemVars ( boolean **  sv,
TCuikSystem cs 
)

Creates an array of booleans with the size of the number of variables in the cuiksystem and set to TRUE the entries corresponding to system, secondary, and velocity variables.

In coherence with the definition of the orig_systemVar field of TCuikSystem, here we identify system, secondary, and velocity varibles. Internally, though, we differentiate between them (for instance, secondary varibles are not used when splitting boxes).

Parameters
svPointer to the pointer of booleans to be allocated and updated.
csThe cuiksystem to query.
Returns
The number of variables in the cuiksystem (size of teh output array).

Definition at line 2697 of file cuiksystem.c.

References IsPositionVariable(), IsSecondaryVariable(), IsSystemVariable(), NEW, NVariables(), and TCuikSystem::orig_variables.

Referenced by AdjustBioWorldGeometry(), GenerateWorldEquations(), GetSCpSystem(), GetWorldSystemVars(), IncrementalSampleCuikSystemInBox(), main(), NewtonInWorld(), and SampleCuikSystemInBox().

◆ GetCSPositionVars()

unsigned int GetCSPositionVars ( boolean **  pv,
TCuikSystem cs 
)

Creates an array of booleans with the size of the number of variables in the cuiksystem and set to TRUE the entries corresponding to position, i.e., to non-velocity variables.

Parameters
pvPointer to the pointer of booleans to be allocated and updated.
csThe cuiksystem to query.
Returns
The number of variables in the cuiksystem (size of teh output array).

Definition at line 2711 of file cuiksystem.c.

References IsPositionVariable(), NEW, NVariables(), and TCuikSystem::orig_variables.

Referenced by GetWorldPositionVars().

◆ GetCSPositionEqs()

unsigned int GetCSPositionEqs ( boolean **  pv,
TCuikSystem cs 
)

Creates an array of booleans with the size of the number of variables in the cuiksystem and set to TRUE the entries corresponding to position, i.e., to non-velocity variables.

Parameters
pvPointer to the pointer of booleans to be allocated and updated.
csThe cuiksystem to query.
Returns
The number of variables in the cuiksystem (size of teh output array).

Definition at line 2724 of file cuiksystem.c.

References IsPositionEquation(), NEquations(), NEW, and TCuikSystem::orig_equations.

Referenced by GetWorldPositionEqs().

◆ GetCSPositionVelocityVars()

unsigned int GetCSPositionVelocityVars ( boolean **  pv,
TCuikSystem cs 
)

Creates an array of booleans with the size of the number of variables in the cuiksystem and set to TRUE the entries corresponding to position or velocity, i.e., the variables relevant for the dynamics. We essentially rule out discriminant variables.

Parameters
pvPointer to the pointer of booleans to be allocated and updated.
csThe cuiksystem to query.
Returns
The number of variables in the cuiksystem (size of teh output array).

Definition at line 2743 of file cuiksystem.c.

References IsNonDynamicVariable(), NEW, NVariables(), and TCuikSystem::orig_variables.

Referenced by GetWorldPositionVelocityVars().

◆ GetCSPositionVelocityEqs()

unsigned int GetCSPositionVelocityEqs ( boolean **  pv,
TCuikSystem cs 
)

Creates an array of booleans with the size of the number of variables in the cuiksystem and set to TRUE the entries corresponding to position or velocity, i.e., the equations relevant for the dynamics. We essentially rule out discriminant equations.

Parameters
pvPointer to the pointer of booleans to be allocated and updated.
csThe cuiksystem to query.
Returns
The number of variables in the cuiksystem (size of teh output array).

Definition at line 2756 of file cuiksystem.c.

References IsNonDynamicEquation(), NEquations(), NEW, and TCuikSystem::orig_equations.

Referenced by GetWorldPositionVelocityEqs().

◆ GetCSVarTopology()

unsigned int GetCSVarTopology ( unsigned int  vID,
TCuikSystem cs 
)

Determines the topology of a given variable (of the original variable set).

Parameters
vIDIdentifier of the variable (in the original system).
csThe cuiksystem to query.
Returns
The topology of the variable with the given identifier.

Definition at line 2774 of file cuiksystem.c.

References GetVariable(), GetVariableTopology(), and TCuikSystem::orig_variables.

Referenced by GetWorldVarTopology().

◆ GetCSEquations()

void GetCSEquations ( Tequations eqs,
TCuikSystem cs 
)

Returns a copy of the system equations. This is a Tequations copy constructor.

Parameters
eqsPlace where to copy the system variables.
csThe cuiksystem to query.
See also
CopyEquations

Definition at line 2782 of file cuiksystem.c.

References CopyEquations(), and TCuikSystem::orig_equations.

◆ GetCSNumEquations()

unsigned int GetCSNumEquations ( TCuikSystem cs)

Returns the number of equations already in the cuiksystem.

Parameters
csThe cuiksystem to query.
Returns
The number of equations already in the cuiksystem.

Definition at line 2811 of file cuiksystem.c.

References NEquations(), and TCuikSystem::orig_equations.

Referenced by GetSCpSystem(), IncrementalSampleCuikSystemInBox(), and SampleCuikSystemInBox().

◆ GetCSEquation()

void GetCSEquation ( unsigned int  n,
Tequation eq,
TCuikSystem cs 
)

Returns a copy of one of the equations of the cuiksystem. This can be seen as a Tequation copy constructor.

Parameters
nNumerical identifier of the equation to get.
eqPlace where to store the copy of the equation.
csThe cuiksystem to query.
See also
CopyEquation

Definition at line 2790 of file cuiksystem.c.

References CopyEquation(), Error(), GetEquation(), TCuikSystem::orig_equations, and TCuikSystem::scalar.

◆ IsCSPolynomial()

boolean IsCSPolynomial ( TCuikSystem cs)

Returns TRUE if the cuiksystem is fully polynomial.

We check if the original cuiksystem is polynomial since if this system is polynomial, so are the rest of systems (simplified, simplified+dummified).

Parameters
csThe cuiksystem to query.
Returns
TRUE if the cuiksystem is fully polynomial.

Definition at line 2798 of file cuiksystem.c.

References TCuikSystem::orig_equations, and PolynomialEquations().

Referenced by IsWorldPolynomial().

◆ IsCSScalar()

boolean IsCSScalar ( TCuikSystem cs)

Returns TRUE if the cuiksystem is fully scalar.

Parameters
csThe cuiksystem to query.
Returns
TRUE if the cuiksystem is fully scalar.

Definition at line 2803 of file cuiksystem.c.

References TCuikSystem::scalar.

◆ GetCSJacobian()

void GetCSJacobian ( TJacobian J,
TCuikSystem cs 
)

Defines the Jacobian of a CuikSystem considering each equation as a function.

Defines an array with as many rows as equations and as many columns as variables where each entry (i,j) is de derivative of equation i (considered as a function) with repect to variable j.

Parameters
JThe jacobian (output).
csThe cuik system from where to extract the Jacobian.

Definition at line 2816 of file cuiksystem.c.

References InitJacobian(), TCuikSystem::orig_equations, and TCuikSystem::orig_variables.

Referenced by AddJacobianEquations(), GetSCpSystem(), and GetWorldJacobian().

◆ GetSimpCSTopology()

unsigned int GetSimpCSTopology ( Tparameters p,
unsigned int **  t,
TCuikSystem cs 
)

Creates an array with the topology information for the variables in the simplified system.

The topology gives information on the type of range for each variable (either real or spherical). This is relevant when searching for nearest neighbours (in the case of spherical topology pi is close to -pi but not in the case of real topology).

Parameters
pThe set of parameters.
tSpace for the output array.
csThe cuiksystem to query.
Returns
The number of entries in the output array (i.e., the number of variables in the simplified system).

Definition at line 2821 of file cuiksystem.c.

References Error(), GetVariablesTopology(), TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by GetWorldSimpTopology().

◆ GetCSTopology()

unsigned int GetCSTopology ( Tparameters p,
unsigned int **  t,
TCuikSystem cs 
)

Creates an array with the topology information for the variables in the system.

The topology gives information on the type of range for each variable (either real or spherical). This is relevant when searching for nearest neighbours (in the case of spherical topology pi is close to -pi but not in the case of real topology).

Parameters
pThe set of parameters.
tSpace for the output array.
csThe cuiksystem to query.
Returns
The number of entries in the output array (i.e., the number of variables in the system).

Definition at line 2830 of file cuiksystem.c.

References GetVariablesTopology(), and TCuikSystem::orig_variables.

Referenced by GetWorldTopology().

◆ GetSimpCSJacobian()

void GetSimpCSJacobian ( Tparameters p,
TJacobian J,
TCuikSystem cs 
)

The same as GetCSJacobian but for the simplified system.

Parameters
pThe set of parameters
JThe jacobian (output).
csThe cuik system from where to extract the Jacobian.

Definition at line 2836 of file cuiksystem.c.

References Error(), InitJacobian(), TCuikSystem::simp_equations, TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by GetWorldSimpJacobian().

◆ GetSimpCSNJacobian()

boolean GetSimpCSNJacobian ( Tparameters p,
TNJacobian nJ,
TCuikSystem cs 
)

Defines the data necessary to numerically evaluate the Jacobian of the position variables/equations of the problem. Such structure is only defined in particular systems (systems including only matrix equations) and it is used to speed up the evaluation of the Jacobian (the evaluation of the symbolic Jacobian is slow since many matrix products are repated).

Parameters
pThe set of parameters
nJThe numerical Jacobian structure (output).
csThe cuik system from where to extract the Jacobian.
Returns
TRUE if the numerical Jacobian structure is actually created. If FALSE nothing is created and there is no need to delete the structure.

Definition at line 2843 of file cuiksystem.c.

References Error(), InitNJacobian(), TCuikSystem::simp_equations, TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by GetWorldSimpNJacobian().

◆ GetSimpCSNHessian()

boolean GetSimpCSNHessian ( Tparameters p,
TJacobian sJ,
TNHessian nH,
TCuikSystem cs 
)

Defines the data necessary to numerically evaluate the Hessian of the position variables/equations of the problem. Such structure is only defined in particular systems (systems including only matrix equations) and it is used to speed up the evaluation of the Hessian (the evaluation of the symbolic Hessian is slow since many matrix products are repated).

Parameters
pThe set of parameters
sJThe Jacobian of the scalar equations, if any.
nHThe numerical Hessian structure (output).
csThe cuik system from where to extract the Jacobian.
Returns
TRUE if the numerical Hessian structure is actually created. If FALSE nothing is created and there is no need to delete the structure.

Definition at line 2851 of file cuiksystem.c.

References Error(), InitNHessian(), TCuikSystem::simp_equations, TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by GetWorldSimpNHessian().

◆ AddJacobianEquations()

void AddJacobianEquations ( Tparameters p,
boolean selectedVars,
TCuikSystem cs 
)

Adds linear a linear combination of the Jacobian to the system. Generates a new variable for each equation in the system and creates a linear combination of the Jacobian rows using the new variables. Those new variables are normalized to avoid getting redudant solutions. Only the Jacobian columns corresponding to the selectedVars is used.

This functions is used when looking for singularities.

Parameters
pThe set of parameters.
selectedVarsThe variables to take into account. NULL to use all variables.
csThe cuiksystem to modify.

Definition at line 2916 of file cuiksystem.c.

References AddJacobianEquationsInt(), DeleteJacobian(), Error(), GetCSJacobian(), TCuikSystem::orig_nequations, TCuikSystem::orig_nvariables, TCuikSystem::scalar, UnUpdateCuikSystem(), and UpdateCuikSystem().

Referenced by main().

◆ AddVelocityEquations()

void AddVelocityEquations ( Tparameters p,
double *  vl,
TCuikSystem cs 
)

Generates the velocity variables and equations. We have as many velocity variables as variables in the simplified cuiksystem and the equations are defined as the product of the position Jacobian and the velocity variables.

Note that if the input cuiksystem already includes velocity variables and equations nothing is actually added. Otherwise we will be generating acceleration equations and this requires some code modifications (specially with the matrix equations).

Parameters
pThe parameters.
vlThe velocity limits. Optional. It only makes sense to give such limits if the interval problem variables are directly related with degrees of freedom. If not given (i.e., set ot NULL), the MAX_VELOCITY parameter is used.
csThe cuiksystem to extend with the velocity related information.

Definition at line 2946 of file cuiksystem.c.

References AddVariable2CS(), ChangeParameter(), CT_DEFAULT_MAX_VELOCITY, CT_DUMMIFY, DeleteJacobian(), DeleteVariable(), Error(), GetNumVelocityVariables(), GetParameter(), GetVarIDInOriginal(), InitPositionJacobian(), IsPositionVariable(), JacobianLinearCombination(), NEW, NewInterval(), NewVariable(), TCuikSystem::orig2s, TCuikSystem::orig_equations, TCuikSystem::orig_variables, RewriteJacobian2Orig(), SetVariableInterval(), TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nvariables, TCuikSystem::simp_variables, UnUpdateCuikSystem(), UpdateCuikSystem(), VariableName(), and VELOCITY_VAR.

Referenced by GenerateWorldEquations().

◆ AddSimplifiedJacobianEquations()

void AddSimplifiedJacobianEquations ( Tparameters p,
boolean selectedVars,
TCuikSystem cs 
)

This is the same as AddJacobianEquations but the we use the Jacobian of the simplified system instead of that of the original system.

Note that the selectedVars refer to the original system and they can be missing from the original system. We try to translate variables from original to simple. Original variables assigned to constants are unselected and variables assigned to other variables are replaced accordingly.

Parameters
pThe set of parameters.
selectedVarsThe variables to take into account. NULL to use all variables.
csThe cuiksystem to modify.

Definition at line 3045 of file cuiksystem.c.

References AddJacobianEquationsInt(), CopyCuikSystem(), DeleteCuikSystem(), DeleteJacobian(), DeleteLinearConstraint(), Error(), FALSE, GetJacobianEquation(), GetLinearConstraintVariable(), GetNumTermsInLinearConstraint(), GetOriginalVarRelation(), GetVariableNames(), InitJacobian(), NEW, TCuikSystem::orig2s, TCuikSystem::orig_nvariables, TCuikSystem::orig_variables, TCuikSystem::orig_varNames, PrintEquation(), RewriteJacobian2Orig(), TCuikSystem::scalar, TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nvariables, TCuikSystem::simp_variables, TRUE, UnUpdateCuikSystem(), UpdateCuikSystem(), and VariableName().

Referenced by GenerateWorldTWSEquations().

◆ MaxReduction()

unsigned int MaxReduction ( Tparameters p,
unsigned int  varMask,
double *  r,
Tbox b,
TCuikSystem cs 
)

Reduces a box using the constraints included in the cuiksystem and using the algorithms described in our papers.

Parameters
pA set of parameters.
varMaskThe type of variables to reduce (SYSTEM_VAR, CARTESIAN_VAR, DUMMY_VAR). Different types of variables can be indicated using '|'. A good option is to use ~DUMMY_VAR (this reduces for all variables except for dummy ones).
rThe reduction ration for the box.
bThe box to be reduced.
csThe cuiksystem with the constraints to use to reduce the box.

Definition at line 3156 of file cuiksystem.c.

References DeleteBox(), DUMMY_VAR, EMPTY_BOX, Error(), GetBoxSize(), TCuikSystem::orig2sd, ReduceBox(), TCuikSystem::scalar, SimpleFromOriginal(), TCuikSystem::systemVar, UpdateCuikSystem(), and UpdateOriginalFromSimple().

Referenced by IncrementalSampleCuikSystemInBox(), MaxWorldReduction(), and SampleCuikSystemInBox().

◆ SampleCuikSystem()

boolean SampleCuikSystem ( Tparameters p,
char *  fname,
Tlist sb,
unsigned int  nsamples,
unsigned int  ntries,
unsigned int  ndof,
TCuikSystem cs 
)

Determine points for which all the equations in the cuiksystem hold. Actually it determines tiny boxes (boxes with size below EPSILON) and the center of the box is taken as the solution point. Since, in general, EPSILON is very small (1e-6) the error of the given solutions is also tiny (order of 1e-12).
The function generates two types of output, the solution boxes (stored in a fname_samples.sol file) and the central point for each solution point (stored in a fname.samples file).
Samples are used in the planning process, to generate roadmap vertexes.
This functions generates samples in the search space defined by the variable ranges. For a function that generate samples in a particular box see SampleCuikSystemInBox.
Note that a sample includes values only for the system variables, that are the ones governing the movement for the mechanisms at hand.
The algorithm implemented for sampling proceed by fixing ndof variables at random and then solving the problem via CuikSolve.

Parameters
pA set of parameters.
fnameBase name for the output files. If NULL, the solutions are not stored in any file.
sbList of boxes where to store the solutions. If NULL, the boxes are not listed.
nsamplesThe number of samples to generate.
ntriesNumber of times we have to try to generate samples (i.e., of fixing some variables at random and solving). Use NO_UINT not to fix any limit.
ndofThe number of degrees of freedom of the mechanism under considerations. If we use NO_UINT, the function tries to determine the number of degrees of freedom from the variables and equations (ndof = Num Variables-Num Equations). However, our systems are typically overconstrained and this simple guess often fails.
csThe cuiksystem from which to drawn samples.
Returns
TRUE if the samples are actually generated before reaching the maximum number of tries.
See also
CuikPlan SampleCuikSystemInBox

Definition at line 3189 of file cuiksystem.c.

References DeleteBox(), Error(), GenerateInitialBox(), SampleCuikSystemInBox(), and TCuikSystem::scalar.

Referenced by main().

◆ SampleCuikSystemInBox()

boolean SampleCuikSystemInBox ( Tparameters p,
char *  fname,
Tlist sb,
unsigned int  nsamples,
unsigned int  ntries,
unsigned int  ndof,
Tbox init_box,
TCuikSystem cs 
)

This like function SampleCuikSystem but the samples are generated only in the given box. Morover, this function can store the (tiny) solution boxes in a list of boxes.

Parameters
pA set of parameters.
fnameBase name for the output files. If NULL, the solutions are not stored in any file.
sbList of boxes where to store the solutions. If NULL, the boxes are not listed.
nsamplesThe number of samples to generate.
ntriesNumber of times we have to try to generate samples (i.e., of fixing some variables at random and solving). Use NO_UINT not to fix any limit.
ndofThe number of degrees of freedom of the mechanism under considerations. If we use NO_UINT, the function tries to determine the number of degrees of freedom from the variables and equations (ndof = Num Variables-Num Equations). However, our systems are typically overconstrained and this simple guess often fails.
init_boxBox where to generate samples.
csThe cuiksystem from which to drawn samples.
Returns
TRUE if the samples are actually generated before reaching the maximum number of tries.
See also
SampleCuikSystem

Definition at line 3208 of file cuiksystem.c.

References AddLastElement(), Advance(), ChangeParameter(), ComputeSplitDim(), CopyBox(), CreateFileName(), CT_EPSILON, CT_N_SOLUTIONS, CT_SMALL_SIGMA, CT_SPLIT_TYPE, DeleteBox(), DeleteFileName(), DeleteListOfBoxes(), DUMMY_VAR, EMPTY_BOX, EndOfList(), Error(), FALSE, First(), GenerateInitialBox(), GetBoxInterval(), GetCSNumEquations(), GetCSNumVariables(), GetCSSystemVars(), GetCurrent(), GetFileFullName(), GetParameter(), GetVariable(), GetVariableTypeN(), InitIterator(), InitListOfBoxes(), IntervalCenter(), LINKS_EXT, MaxReduction(), NEW, NewInterval(), NO_UINT, NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_variables, PrintBox(), randomInInterval(), TCuikSystem::scalar, SetCSVariableRange(), SetVariableInterval(), SOL_EXT, SolveCuikSystem(), SYSTEM_VAR, TRUE, UnUpdateCuikSystem(), TCuikSystem::updated, and UsedVarInEquations().

Referenced by SampleCuikSystem().

◆ IncrementalSampleCuikSystem()

boolean IncrementalSampleCuikSystem ( Tparameters p,
char *  fname,
Tlist sb,
boolean fixVars,
unsigned int  nsamples,
unsigned int  ntries,
unsigned int  ndof,
TCuikSystem cs 
)

This function is very similar to SampleCuikSystem but degrees of freedom are progressively fixed instead of fixed all simultaneously.

Parameters
pA set of parameters.
fnameBase name for the output files. If NULL, the solutions are not stored in any file.
sbList of boxes where to store the solutions. If NULL, the boxes are not listed.
fixVarsBoolean array with the variables that can be fixed. If NULL the system variables are used.
nsamplesThe number of samples to generate.
ntriesNumber of times we have to try to generate samples (i.e., of fixing some variables at random and solving). Use NO_UINT not to fix any limit.
ndofThe number of degrees of freedom of the mechanism under considerations. If we use NO_UINT, the function tries to determine the number of degrees of freedom from the variables and equations (ndof = Num Variables-Num Equations). However, our systems are typically overconstrained and this simple guess often fails.
csThe cuiksystem from which to drawn samples.
Returns
TRUE if the samples are actually generated before reaching the maximum number of tries.

Definition at line 3466 of file cuiksystem.c.

References DeleteBox(), Error(), GenerateInitialBox(), IncrementalSampleCuikSystemInBox(), and TCuikSystem::scalar.

◆ IncrementalSampleCuikSystemInBox()

boolean IncrementalSampleCuikSystemInBox ( Tparameters p,
char *  fname,
Tlist sb,
boolean fixVars,
unsigned int  nsamples,
unsigned int  ntries,
unsigned int  ndof,
Tbox init_box,
TCuikSystem cs 
)

This function is very similar to SampleCuikSystemInBox but degrees of freedom are progressively fixed instead of fixed all simultaneously.

Parameters
pA set of parameters.
fnameBase name for the output files. If NULL, the solutions are not stored in any file.
sbList of boxes where to store the solutions. If NULL, the boxes are not listed.
fixVarsBoolean array with the variables that can be fixed. If NULL the system variables are used.
nsamplesThe number of samples to generate.
ntriesNumber of times we have to try to generate samples (i.e., of fixing some variables at random and solving). Use NO_UINT not to fix any limit.
ndofThe number of degrees of freedom of the mechanism under considerations. If we use NO_UINT, the function tries to determine the number of degrees of freedom from the variables and equations (ndof = Num Variables-Num Equations). However, our systems are typically overconstrained and this simple guess often fails.
init_boxBox where to generate samples.
csThe cuiksystem from which to drawn samples.
Returns
TRUE if the samples are actually generated before reaching the maximum number of tries.

Definition at line 3486 of file cuiksystem.c.

References AddLastElement(), Advance(), BoxFromVariables(), ChangeParameter(), CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CopyBox(), CreateFileName(), CT_EPSILON, CT_MAX_NEWTON_ITERATIONS, CT_N_SOLUTIONS, CT_SMALL_SIGMA, CuikNewtonInBox(), DeleteBox(), DeleteFileName(), DeleteListOfBoxes(), DUMMY_VAR, EMPTY_BOX, EndOfList(), Error(), ErrorInSolution(), FALSE, First(), GetBoxInterval(), GetBoxSumSide(), GetCSNumEquations(), GetCSNumVariables(), GetCSSystemVars(), GetCurrent(), GetFileFullName(), GetParameter(), InitIterator(), InitListOfBoxes(), IntervalCenter(), IntervalSize(), IsInSimple(), IsSystemVariable(), LINKS_EXT, MaxReduction(), NEW, NewInterval(), NO_UINT, NVariables(), TCuikSystem::orig2sd, TCuikSystem::orig_notDummyVar, TCuikSystem::orig_variables, TCuikSystem::orig_varNames, PrintBox(), PrintBoxSubset(), randomInInterval(), randomMax(), TCuikSystem::scalar, SetBoxInterval(), SOL_EXT, SolveCuikSystem(), TRUE, UnUpdateCuikSystem(), UpdateCuikSystem(), and VariablesFromBox().

Referenced by IncrementalSampleCuikSystem().

◆ CuikNewtonSimp()

unsigned int CuikNewtonSimp ( Tparameters p,
double *  x,
TCuikSystem cs 
)

This is simplified a version of CuikNewtonInBox since

  • It operates in the simplified system.
  • It can not include inequality constraints in the system.
  • It does not takes into account the original box.
  • It does not check the equation error at the end of the iteration (we assume convervenge if the step is small)

This used when defining a RRT: we sample points in ambient space (of the simplified system) and we want to converge to the manifold (if possible).

If you want to understand what is done in CuikNewtonInBox it is better to start by this function.

Todo:
Reduce the duplicity of code between CuikNewtonSimp and CuikNewtonInBox. This is not easy since CuikNewtonInBox includes lots of code to take into account box bondaries and inequalitites and code to convert from boxes in the original system to boxes in the simplified system at the beggining of the function and the revese change at the end of the function.
Parameters
pThe set of parameters.
xThe initial and output point. This is a point in the simplified system.
csThe cuiksystem.
Returns
DIVERGED if we could not reach a solution point or CONVERGED_IN_GLOBAL if a solution point is found.

Definition at line 3819 of file cuiksystem.c.

References ArrayPi2Pi(), CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CT_EPSILON, CT_MAX_NEWTON_ITERATIONS, DeleteNewton(), DIVERGED, Error(), ErrorInSimpCSEquations(), EvaluateEqualityEquations(), EvaluateJacobianInVector(), FALSE, GetNewtonMatrixBuffer(), GetNewtonRHBuffer(), GetParameter(), InitNewton(), TCuikSystem::J, NewtonStep(), TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nequations, TCuikSystem::simp_nvariables, TCuikSystem::simp_tp, TRUE, and UpdateCuikSystem().

Referenced by WorldSimpCuikNewton().

◆ CuikNewtonInBox()

unsigned int CuikNewtonInBox ( Tparameters p,
Tbox bIn,
double *  sol,
Tbox b_sol,
TCuikSystem cs 
)

Find a solution of a cuiksystem set of equations using the Newton-Rhapson method.

The initial point is sampled form the given box.

Parameters
pA set of parameters.
bInThe box from where sample the initial point.
solThe space where to store solution of the cuik system as a point. This must be allocated by the caller.
b_solThe solution as a punctual box. If the Newton diverged this will be a copy of the input box. The space is allocated inside this function.
csThe cuiksystem to solve.
Returns
DIVERGED, CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CONVERGED_OUTSIDE_GLOBAL.
See also
CuikNewton

Definition at line 3917 of file cuiksystem.c.

References ArrayPi2Pi(), CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CONVERGED_OUTSIDE_GLOBAL, CopyBox(), CT_EPSILON, CT_MAX_NEWTON_ITERATIONS, DeleteBox(), DeleteNewton(), DIVERGED, Error(), ErrorInInequalities(), EvaluateEqualityEquations(), EvaluateJacobianInVector(), FALSE, GenerateInitialBox(), GetBoxInterval(), GetBoxNIntervals(), GetNewtonMatrixBuffer(), GetNewtonRHBuffer(), GetNumDummyVariables(), GetParameter(), InitBoxFromPoint(), InitNewton(), IntervalCenter(), IntervalSize(), TCuikSystem::J, NEW, NewInterval(), NewtonSetMatrix(), NewtonSetRH(), NewtonStep(), Norm(), TCuikSystem::orig2s, TCuikSystem::orig_notDummyVar, TCuikSystem::orig_nvariables, TCuikSystem::orig_systemVar, TCuikSystem::orig_variables, PointInBox(), randomInInterval(), RegenerateSolution(), SetBoxInterval(), SetBoxSubset(), TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nequations, TCuikSystem::simp_nvariables, TCuikSystem::simp_tp, SimpleFromOriginal(), UpdateCuikSystem(), and UpdateOriginalFromSimple().

Referenced by CuikNewton(), IncrementalSampleCuikSystemInBox(), main(), and PostProcessBox().

◆ CuikNewton()

boolean CuikNewton ( Tparameters p,
double *  sol,
Tbox b_sol,
TCuikSystem cs 
)

Find a solution of a cuiksystem set of equations using the Newton-Rhapson method.

This function is only a wrapper of CuikNewtonInBox using the initial box (i.e., the one defined form the variable ranges) to sample the initial point.

Parameters
pA set of parameters.
solSpace where to store the solution as a point. This must be allocated by the caller.
b_solThe solution as a punctual box. If the Newton diverged this will be a copy of the input box. This box is allocated inside the function.
csThe cuiksystem to solve.
Returns
TRUE if the Newton-Raphson process converged to a solution in the initial box.
See also
CuikNewtonInBox, GenerateInitialBox.

Definition at line 4150 of file cuiksystem.c.

References CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CuikNewtonInBox(), DeleteBox(), and GenerateInitialBox().

Referenced by main(), and NewtonInWorld().

◆ CuikGradientInBox()

unsigned int CuikGradientInBox ( Tparameters p,
Tbox bIn,
double *  sol,
Tbox b_sol,
TCuikSystem cs 
)

Find a solution of a cuiksystem set of equations using the gradient descent method.

The initial point is sampled form the given box.

Parameters
pA set of parameters.
bInThe box from where sample the initial point.
solThe space where to store solution of the cuik system as a point. This must be allocated by the caller.
b_solThe solution as a punctual box. If the Newton diverged this will be a copy of the input box. The space is allocated inside this function.
csThe cuiksystem to solve.
Returns
DIVERGED, CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CONVERGED_OUTSIDE_GLOBAL.
See also
CuikGradient

Definition at line 4164 of file cuiksystem.c.

References ArrayPi2Pi(), CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CONVERGED_OUTSIDE_GLOBAL, CopyBox(), Crop2Box(), CT_EPSILON, DeleteBox(), DistanceToInterval(), DIVERGED, Error(), ErrorInInequalities(), EvaluateEqualitySparseEquations(), EvaluateJacobianInVector(), FALSE, GenerateInitialBox(), GetBoxInterval(), GetBoxIntervals(), GetBoxNIntervals(), GetNumDummyVariables(), GetParameter(), InitBoxFromPoint(), IntervalCenter(), TCuikSystem::J, NEW, NewInterval(), NEWZ, Norm(), TCuikSystem::orig2s, TCuikSystem::orig_notDummyVar, TCuikSystem::orig_nvariables, TCuikSystem::orig_systemVar, TCuikSystem::orig_variables, PointInBox(), randomInInterval(), RC2INDEX, RegenerateSolution(), SetBoxInterval(), SetBoxSubset(), TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nequations, TCuikSystem::simp_nvariables, TCuikSystem::simp_tp, SimpleFromOriginal(), SumVectorScale(), TMatrixVectorProduct(), TRUE, UpdateCuikSystem(), and UpdateOriginalFromSimple().

Referenced by CuikGradient(), and main().

◆ CuikGradient()

boolean CuikGradient ( Tparameters p,
double *  sol,
Tbox b_sol,
TCuikSystem cs 
)

Find a solution of a cuiksystem set of equations using gradient descent method.

This function is only a wrapper of CuikGradientInBox using the initial box (i.e., the one defined form the variable ranges) to sample the initial point.

Parameters
pA set of parameters.
solSpace where to store the solution as a point. This must be allocated by the caller.
b_solThe solution as a punctual box. If the Newton diverged this will be a copy of the input box. This box is allocated inside the function.
csThe cuiksystem to solve.
Returns
TRUE if the gradient descent process converged to a solution in the initial box.
See also
CuikGradientInBox, GenerateInitialBox.

Definition at line 4374 of file cuiksystem.c.

References CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CuikGradientInBox(), DeleteBox(), and GenerateInitialBox().

Referenced by main().

◆ SolveCuikSystem()

void SolveCuikSystem ( Tparameters p,
boolean  restart,
char *  fstate,
Tbox searchSpace,
FILE *  f_out,
Tlist sol,
TCuikSystem cs 
)

This is the entry function for the Cuik solver. It takes as input a cuiksystem and returns a set of boxes bounding the solution set. If the solutions are isolated (zero-dimensional) the output is a set of isolated boxes. If the solution is continuous the output is a set of boxes bounding the solution space. Be aware that isolating solution sets with high dimensionality can be expensive. To this end it is recommended to use the parallel version of cuik

Parameters
pA set of parameters.
restartTRUE is the process has be re-started from a previous execution that was, for some reason, crashed.
fstateName of the file from which to read the state (if restart is TRUE) and where to save the state from time to time (concretely every STATE_PERIOD boxes).
searchSpaceBox defining the search space where to look for the solutions. If null, the global search space is used (the one defined from the user-given variable ranges).
f_outFile where to store the solution boxes and the related information such as the parameters, the compilation flags and the statistics of the solving process (time, number of processed boxes,...). If NULL the boxes are not stored in the file (in this case sols must not be NULL).
solList of boxes where to store the solutions. If NULL, the boxes are not listed.
csThe cuiksystem to solve.
See also
MPI_SolveCuikSystem

Definition at line 4395 of file cuiksystem.c.

References AddBox2HeapOfBoxes(), AddList2Heap(), BoxFromVariables(), BREADTH_FIRST_SEARCH, CmpBoxBreadthFirst(), CmpBoxDepthFirst(), CmpBoxesEquation(), CT_N_SOLUTIONS, CT_STATE_PERIOD, DeleteBox(), DeleteHeap(), DeleteListOfBoxes(), DEPTH_FIRST_SEARCH, DUMMY_VAR, Error(), EvaluateEqMin(), ExtractMinElement(), FALSE, GetBoxLevel(), GetBoxSize(), GetBoxVolume(), GetNSolutionBoxes(), GetParameter(), Heap2List(), HeapEmpty(), HeapOfBoxesVolume(), InitBox(), InitHeapOfBoxes(), InitStatistics(), LoadCSState(), MINIMIZATION_SEARCH, NewBoxProcessed(), NewMaxLevel(), TCuikSystem::orig2sd, PostProcessBox(), PrintBox(), PrintStatistics(), ReduceBox(), REDUCED_BOX_WITH_SOLUTION, SaveCSState(), TCuikSystem::scalar, TCuikSystem::searchMode, TCuikSystem::simp_empty, TCuikSystem::simp_nvariables, SimpleFromOriginal(), TCuikSystem::st, TCuikSystem::systemVar, UpdateCuikSystem(), and TCuikSystem::variables.

Referenced by DealWithCP(), IncrementalSampleCuikSystemInBox(), main(), and SampleCuikSystemInBox().

◆ MPI_SolveCuikSystem()

void MPI_SolveCuikSystem ( Tparameters p,
boolean  restart,
char *  fstate,
Tbox searchSpace,
FILE *  f_out,
TCuikSystem cs 
)

This is the parallel version of SolveCuikSystem. Actually this function is the main scheduler, i.e., the one in charge of managing the boxes to be processes to send them to the child processors. to collec the result, and to deal with them accordingly (bisect, consider solutions, discard if they are empty,...).
The main difference with SolveCuikSystem is that solutions are not included in any list but only stored in a file.

Parameters
pA set of parameters.
restartTRUE is the process has be re-started from a previous execution that was, for some reason, crashed.
fstateName of the file from which to read the state (if restart is TRUE) and where to save the state from time to time (concretely every STATE_PERIOD boxes).
searchSpaceBox defining the search space where to look for the solutions. If null, the global search space is used (the one defined from the user-given variable ranges).
f_outFile where to store the solution boxes and the related information such as the parameters, the compilation flags and the statistics of the solving process (time, number of processed boxes,...).
csThe cuiksystem to solve.
See also
SolveCuikSystem

Definition at line 4572 of file cuiksystem.c.

References AddBox2HeapOfBoxes(), AddFirstElement(), AddList2Heap(), AddNBoxReductions(), Box2Buffer(), BoxFromVariables(), BREADTH_FIRST_SEARCH, Buffer2Box(), CmpBoxBreadthFirst(), CmpBoxDepthFirst(), CmpBoxesEquation(), CT_N_SOLUTIONS, CT_STATE_PERIOD, DeleteBox(), DeleteHeap(), DeleteListOfBoxes(), DeleteStatistics(), DEPTH_FIRST_SEARCH, Error(), ERROR_IN_PROCESS, ExtractMinElement(), FALSE, GetBoxBufferSize(), GetBoxLevel(), GetBoxSize(), GetBoxVolume(), GetNSolutionBoxes(), GetParameter(), Heap2List(), HeapEmpty(), HeapOfBoxesVolume(), HeapSize(), InitBox(), InitHeapOfBoxes(), InitStatistics(), LoadCSState(), MINIMIZATION_SEARCH, MPI_TREAT_BOX_TIMEOUT, NEW, NewBoxProcessed(), NewLostBox(), NewMaxLevel(), TCuikSystem::nvariables, TCuikSystem::orig2sd, PostProcessBox(), PrintBox(), PrintStatistics(), REDUCED_BOX, SaveCSState(), TCuikSystem::scalar, TCuikSystem::searchMode, SimpleFromOriginal(), TCuikSystem::st, TCuikSystem::systemVar, TRUE, UpdateCuikSystem(), and TCuikSystem::variables.

Referenced by main().

◆ MPI_TreatBox()

void MPI_TreatBox ( Tparameters p,
TCuikSystem cs 
)

This is the function executed by the child processors when solving a problem in a multi-processor environment.

Parameters
pA set of parameters.
csThe cuiksystem to solve.
See also
MPI_SolveCuikSystem

Definition at line 4959 of file cuiksystem.c.

References Box2Buffer(), Buffer2Box(), DeleteBox(), DUMMY_VAR, Error(), FALSE, GetBoxBufferSize(), GetNBoxReductions(), InitBox(), NEW, TCuikSystem::nvariables, PrintBox(), ReduceBox(), ResetNBoxReductions(), TCuikSystem::scalar, TCuikSystem::st, TRUE, and UpdateCuikSystem().

Referenced by main().

◆ GenerateInitialBox()

void GenerateInitialBox ( Tbox box,
TCuikSystem cs 
)

Determines the search space for the solutions of a cuiksystem in the form of a box defined from the variable ranges.
This can be seen as a box constructor.

Parameters
boxThe output box with the variable ranges.
csThe cuiksystem.

Definition at line 5052 of file cuiksystem.c.

References BoxFromVariables(), and TCuikSystem::orig_variables.

Referenced by CuikGradient(), CuikGradientInBox(), CuikNewton(), CuikNewtonInBox(), GetWorldInitialBox(), IncrementalSampleCuikSystem(), SampleCuikSystem(), and SampleCuikSystemInBox().

◆ GenerateSimpInitialBox()

void GenerateSimpInitialBox ( Tparameters p,
Tbox box,
TCuikSystem cs 
)

The same as GenerateInitialBox but for the simplified system.

Parameters
pThe set of parameters.
boxThe output box with the variable ranges.
csThe cuiksystem.

Definition at line 5057 of file cuiksystem.c.

References BoxFromVariables(), Error(), TCuikSystem::simp_variables, and UpdateCuikSystem().

Referenced by GetWorldSimpInitialBox().

◆ RegenerateSolution()

boolean RegenerateSolution ( Tparameters p,
Tbox b,
TCuikSystem cs 
)

Generates values for all variables in the box (including dummies and cartesian ones) from the values of the system variables.

In general, solutions only include system variables and for many operations the cartesian/dummy ones are also needed (for plotting, for refining a solution,...). This functions reverses the removal of the non-system variables in a box.

Observe that the box must be given in the original system and with values only for the system variables. This is different of what happens with RegenerateOriginalBox where the input box has values for all variables in the simplified system.

Parameters
pThe set of parameters.
bThe box to regenerate. It must have the correct dimensionality (i.e., the number of variables in the cuiksystem including the system and dummy ones) but with values only for the system variables. At the end of the call the values for dummy/cartesian variables will be also defined.
csThe cuiksystem.
Returns
TRUE if the regeneration process can be compleated without problems and FALSE if during the reconstruction we realize that the input box is and empty box.

Definition at line 5065 of file cuiksystem.c.

References CARTESIAN_VAR, CropEquation(), CT_EPSILON, CT_RHO, DUMMY_VAR, EMPTY_BOX, FALSE, GetParameter(), INF, IsCartesianVariable(), IsCoordEquation(), IsDummyEquation(), IsDummyVariable(), NewInterval(), TCuikSystem::orig_equations, TCuikSystem::orig_nvariables, TCuikSystem::orig_variables, SetBoxInterval(), TRUE, and UpdateCuikSystem().

Referenced by CuikGradientInBox(), CuikNewtonInBox(), and RegenerateSolutionPoint().

◆ RegenerateSolutionPoint()

unsigned int RegenerateSolutionPoint ( Tparameters p,
double *  pt,
double **  rp,
TCuikSystem cs 
)

Defines a solution point including the dummy and cartesian variables from an array with only values for the system variables.

This function is based on RegenerateSolution.

Parameters
pThe set of parameters.
ptValues for the system variables.
rpReconstructed solution with values for all variables. The space for this array is allocated in this function.
csThe cuiksystem
Returns
The number of entries of the output array rp.

Definition at line 5125 of file cuiksystem.c.

References DeleteBox(), Error(), GetBoxInterval(), InitBoxFromPoint(), IntervalCenter(), NEW, TCuikSystem::orig_nvariables, TCuikSystem::orig_systemVar, RegenerateSolution(), and UpdateCuikSystem().

Referenced by ManifoldDimension().

◆ RegenerateOriginalBox()

void RegenerateOriginalBox ( Tparameters p,
Tbox boxS,
Tbox boxO,
TCuikSystem cs 
)

Generates a box in the original cuiksystem from a box of the simplified one.

You can generate a simplified cuiksystem using cuiksimplify and then solve it. To obtain the solution boxes in the un-simplified (or original) system using the cuikunsimplify application that basically relies on this function.

Parameters
pThe set of parameters.
boxSThe input box in the simplified and dummified system.
boxOThe output box in the original system. The box is created insided this function.
csThe cuiksystem to which boxes are supposed to refer to. If this is not so the behavior is undefined.

Definition at line 5166 of file cuiksystem.c.

References BoxFromVariables(), Error(), TCuikSystem::orig2s, TCuikSystem::orig_variables, UpdateCuikSystem(), and UpdateOriginalFromSimple().

Referenced by main().

◆ RegenerateOriginalPoint()

unsigned int RegenerateOriginalPoint ( Tparameters p,
double *  s,
double **  o,
TCuikSystem cs 
)

Defines a point in the original system from a point in the simplified system.

It is like RegenerateOriginalBox but on points and not on boxes and taking points from the simplified system and not the simplified+dummified.

This is basically used from cuikatlas that operates on the simplified system.

Parameters
pThe set of parameters.
sThe point in the simplified system.
oThe output on in the original system. Space allocated internally.
csThe cuiksystem.
Returns
The size of the output array (number of variables in the original system).

Definition at line 5177 of file cuiksystem.c.

References Error(), TCuikSystem::orig2s, TCuikSystem::orig_nvariables, TCuikSystem::orig_variables, PointFromVariables(), UpdateCuikSystem(), and UpdateOriginalPointFromSimple().

Referenced by GetLinkTransformsFromSolutionPoint(), RegenerateWorldOriginalPoint(), WorldForceField(), and WorldPotentialEnergy().

◆ GenerateSimplifiedPoint()

unsigned int GenerateSimplifiedPoint ( Tparameters p,
double *  o,
double **  s,
TCuikSystem cs 
)

Generates a simplified point from an original one. This is the inverse mapping of RegenerateOriginalPoint.

Parameters
pThe set of parameters.
oThe point in the original system.
sThe output in the simplified system. Space allocated internally.
csThe cuiksystem.
Returns
The size of the output array (number of variables in the simplified system).

Definition at line 5191 of file cuiksystem.c.

References Error(), TCuikSystem::orig2s, TCuikSystem::simp_nvariables, SimplePointFromOriginal(), and UpdateCuikSystem().

Referenced by ManifoldDimension(), WorldForceField(), WorldGenerateSimplifiedPoint(), and WorldGenerateSimplifiedPointFromSystem().

◆ SimplifyBooleanArray()

unsigned int SimplifyBooleanArray ( Tparameters p,
boolean bo,
boolean **  bs,
TCuikSystem cs 
)

Transforms an array of booleans that selects a subset of the variables in the original system to a subset of variables in the simplified system. Only the entries for the variables of the original system also used in the simplified system are preserved.

Parameters
pThe set of parameters.
boThe array of booleans in the original system.
bsThe array of boolans in the simplified system. The space for this array is allocated internally and must be deallocated by the caller.
csThe cuiksystem.
Returns
The number of entries in the output array (i.e., the number of variables in the simplified cuiksystem).

Definition at line 5201 of file cuiksystem.c.

References Error(), IsInSimple(), NEW, TCuikSystem::orig2s, TCuikSystem::orig_nvariables, TCuikSystem::simp_nvariables, and UpdateCuikSystem().

Referenced by WorldSimpKinematicVars().

◆ ComputeSplitDim()

unsigned int ComputeSplitDim ( Tparameters p,
Tbox b,
TCuikSystem cs 
)

Determines the dimension for which it is more advisable to split a box. The criterion to determine the split dimension can be selected through the parameters.

Parameters
pA set of parameters.
bThe box to be split.
csThe cuiksystem.
Returns
The dimension along to which the box is to be bisected.

Definition at line 5235 of file cuiksystem.c.

References ComputeSplitDimInt(), DeleteBox(), Error(), GetVarIDInOriginal(), NO_UINT, TCuikSystem::orig2sd, TCuikSystem::scalar, SimpleFromOriginal(), and UpdateCuikSystem().

Referenced by SampleCuikSystemInBox().

◆ PointInSystemBox()

boolean PointInSystemBox ( Tvector v,
Tbox b,
TCuikSystem cs 
)

Determines if a given point is fully included in the system sub-box (i.e., the sub-box fot the system variables). The point is typically one obtained via sampling.

Parameters
vA vector of doubles with one entry for each one of the system variables.
bThe box with the ranges for the variables (including the system ones).
csThe cuiksystem.
Returns
TRUE if the point is fully included in the system sub-box.
See also
SampleCuikSystemInBox SampleCuikSystem

Definition at line 5259 of file cuiksystem.c.

References Error(), GetBoxInterval(), GetBoxNIntervals(), GetVectorElement(), IsDummyVariable(), IsInside(), NVariables(), TCuikSystem::orig_variables, and TRUE.

◆ EvaluateCSEquations()

void EvaluateCSEquations ( double *  p,
double *  r,
TCuikSystem cs 
)

Evaluates the equation set on a point.

Only equalities are evaluated and thus only space for as many ouputs as equalities is needed in r.

Parameters
pThe evaluation point.
rThe array with the evaluation of each equation. The space for this array should be allocated externally.
csThe cuiksystem to query.

Definition at line 5286 of file cuiksystem.c.

References EvaluateEqualityEquations(), FALSE, and TCuikSystem::orig_equations.

Referenced by WorldEvaluateEquations().

◆ EvaluateSimpCSEquations()

void EvaluateSimpCSEquations ( Tparameters pr,
double *  p,
double *  r,
TCuikSystem cs 
)

The same as EvaluateCSEquations but on the simplified system.

The direct access to the simplified equations is needed to obtain an efficient cuikatlas (and associated utilities). If defined on the original systems they will include too many (trivial) equations and fixed variables.

Note that in this case the input point p must be defined on the simplified space.

Parameters
prThe set of parameters.
pThe evaluation point.
rThe array with the evaluation of each equation. The space for this array should be allocated externally.
csThe cuiksystem to query.

Definition at line 5291 of file cuiksystem.c.

References Error(), EvaluateEqualityEquations(), FALSE, TCuikSystem::simp_equations, and UpdateCuikSystem().

Referenced by WorldEvaluateSimpEquations().

◆ EvaluateSubSetSimpCSEquations()

void EvaluateSubSetSimpCSEquations ( Tparameters pr,
boolean se,
double *  p,
double *  r,
TCuikSystem cs 
)

The same as EvaluateSimpCSEquations but on a subset of equations.

This is used to evaluate the independent subset of equations during the atlas construction.

Parameters
prThe set of parameters.
seThe array of booleans selecting the equations to evaluate.
pThe evaluation point.
rThe array with the evaluation of each equation. The space for this array should be allocated externally.
csThe cuiksystem to query.

Definition at line 5299 of file cuiksystem.c.

References Error(), EvaluateSubSetEqualityEquations(), TCuikSystem::simp_equations, and UpdateCuikSystem().

Referenced by WorldEvaluateSubSetSimpEquations().

◆ ErrorInCSEquations()

double ErrorInCSEquations ( Tparameters pr,
double *  p,
TCuikSystem cs 
)

Evaluates the equations on a point and returns the norm of the error. Recall that solution points should have zero error. This is similar to ErrorInSolution but works on points and not on boxes and takes into account all equations and not only system ones.

Parameters
prThe set of parameters.
pThe point on which to evaluate the equations (including values for all variables).
csThe cuiksystem with the equations to evaluate.
Returns
The norm of the error for the given point.

Definition at line 5319 of file cuiksystem.c.

References EvaluateEqualityEquations(), FALSE, NEqualityEquations(), NEW, Norm(), and TCuikSystem::orig_equations.

Referenced by main(), and WorldErrorInEquations().

◆ ErrorInSimpCSEquations()

double ErrorInSimpCSEquations ( Tparameters pr,
double *  p,
TCuikSystem cs 
)

The same as ErrorInCSEquations but in the simplified set of equations.

The direct access to the simplified equations is needed to obtain an efficient cuikatlas (and associated utilities). If defined on the original systems they will include too many (trivial) equations and fixed variables.

Note that in this case the input point p must be defined on the simplified space.

Parameters
prThe set of parameters.
pThe point on which to evaluate the equations (including values for all variables in the simplified system).
csThe cuiksystem with the equations to evaluate.
Returns
The norm of the error for the given point.

Definition at line 5341 of file cuiksystem.c.

References Error(), EvaluateEqualityEquations(), FALSE, NEqualityEquations(), NEW, Norm(), TCuikSystem::simp_equations, and UpdateCuikSystem().

Referenced by CuikNewtonSimp(), ManifoldDimension(), and WorldErrorInSimpEquations().

◆ EvaluateCSCost()

double EvaluateCSCost ( Tparameters p,
boolean  simp,
double *  s,
void *  cs 
)

This interface is provided to use it form T-RRT. The same interface is used for other cost function.

Parameters
pThe set of parameters.
simpTRUE if the solution point is given in the simplified sytem.
sThe solution point
csThe cuiksystem with the equation to evaluate.

Definition at line 5363 of file cuiksystem.c.

References EvaluateWholeEquation().

Referenced by EvaluateWorldCost().

◆ EvaluateCSJacobian()

void EvaluateCSJacobian ( double *  p,
double ***  J,
TCuikSystem cs 
)

Returns the matrix resulting from evaluationg the Jacobian of the system in a given point.

The Jacobian is defined on the original cuiksystem (without simplification nor dummyfications).

Parameters
pThe evaluation point.
JThe Jacobian matrix to be defined.
csThe cuiksystem
See also
GetCSJacobian, DeleteCSJacobian.

Definition at line 5307 of file cuiksystem.c.

References AllocateJacobianEvaluation(), DeleteJacobian(), EvaluateJacobian(), InitJacobian(), TCuikSystem::orig_equations, and TCuikSystem::orig_variables.

Referenced by EvaluateWorldJacobian().

◆ ErrorInSolution()

double ErrorInSolution ( Tbox b,
TCuikSystem cs 
)

Computes the error for the solution represented by a box. The error is computed taking the central point of the box and replacing the values in the equation set.

Only system equality equations are taken into account in the error.

Parameters
bThe solution box.
csThe cuiksystem.
Returns
Maximum error for the equations for the central point of the box.

Definition at line 5381 of file cuiksystem.c.

References Error(), EvaluateEqualityEquations(), GetBoxInterval(), GetBoxNIntervals(), IntervalCenter(), NEqualityEquations(), NEW, Norm(), NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_variables, and TRUE.

Referenced by IncrementalSampleCuikSystemInBox(), main(), and PostProcessBox().

◆ ErrorInInequalities()

double ErrorInInequalities ( Tbox b,
TCuikSystem cs 
)

Computes the error for the solution represented by a box as far as inequalities is concerned. The error is computed taking the central point of the box and replacing the values in the equation set.

This can be seen as a complement of ErrorInSolution when inequalities are also to be taken into account.

Parameters
bThe solution box.
csThe cuiksystem.
Returns
Maximum error for the inequality equations for the central point of the box.

Definition at line 5420 of file cuiksystem.c.

References Error(), EvaluateInequalityEquations(), GetBoxInterval(), GetBoxNIntervals(), IntervalCenter(), MaxVector(), NEW, NInequalityEquations(), NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_nvariables, and TCuikSystem::orig_variables.

Referenced by CuikGradientInBox(), and CuikNewtonInBox().

◆ InequalitiesHoldOnPoint()

boolean InequalitiesHoldOnPoint ( double *  p,
TCuikSystem cs 
)

Checks if all inqualities hold for a given point. For many processes (i.e., continuation, etc) only the equalities are taken into account. Thus, we need a function to check if the inequalities hold.

Parameters
pThe point.
csThe cuiksystem to check.
Returns
TRUE if all the inequalities hold for the given point.

Definition at line 5449 of file cuiksystem.c.

References EvaluateInequalityEquations(), MaxVector(), NEW, NInequalityEquations(), TCuikSystem::orig_equations, and TRUE.

Referenced by WorldInequalitiesHold().

◆ SimpInequalitiesHoldOnPoint()

boolean SimpInequalitiesHoldOnPoint ( Tparameters pr,
double *  p,
TCuikSystem cs 
)

Checks if all inqualities hold for a given point for the simplified system.

Parameters
prthe set of parameters.
pThe point (in the simplified system).
csThe cuiksystem to check.
Returns
TRUE if all the inequalities hold for the given point.
See also
InequalitiesHoldOnPoint

Definition at line 5469 of file cuiksystem.c.

References Error(), EvaluateInequalityEquations(), MaxVector(), NEW, NInequalityEquations(), TCuikSystem::simp_equations, TRUE, and UpdateCuikSystem().

Referenced by WorldSimpInequalitiesHold().

◆ ErrorInSimpInequalitiesOnPoint()

double ErrorInSimpInequalitiesOnPoint ( Tparameters pr,
double *  p,
TCuikSystem cs 
)

Determines the maximum error in the inequalities in the simplified system.

Parameters
prthe set of parameters.
pThe point (in the simplified system).
csThe cuiksystem to check.
Returns
The error in the inequalities in the simplified system.
See also
SimpInequalitiesHoldOnPoint

Definition at line 5492 of file cuiksystem.c.

References Error(), EvaluateInequalityEquations(), MaxVector(), NEW, NInequalityEquations(), TCuikSystem::simp_equations, and UpdateCuikSystem().

Referenced by WorldErrorInSimpInequalities().

◆ ManifoldDimension()

unsigned int ManifoldDimension ( Tparameters pr,
double *  p,
TCuikSystem cs 
)

Computes the dimension of the solution space assuming that the given point 'p' is a regular point.

Parameters
prThe set of parameters.
pThe regular solution point. Given in the original format (not in the simplified one).
csThe cuiksystem to query.
Returns
The dimension of the solution manifold.

Definition at line 5513 of file cuiksystem.c.

References CT_EPSILON, Error(), ErrorInSimpCSEquations(), EvaluateTransposedJacobianInVector(), FindRank(), GenerateSimplifiedPoint(), GetJacobianSize(), GetParameter(), TCuikSystem::J, NEW, RegenerateSolutionPoint(), TCuikSystem::simp_nequations, and UpdateCuikSystem().

Referenced by WorldManifoldDimension().

◆ PrintCuikSystem()

void PrintCuikSystem ( Tparameters p,
FILE *  f,
TCuikSystem cs 
)

Writes the cuiksystem in a file that can be stdout.

Parameters
pA set of parameters.
fThe stream where to write the cuiksystem.
csThe cuiksystem.

Definition at line 5560 of file cuiksystem.c.

References GetVariableNames(), MINIMIZATION_SEARCH, NEW, NVariables(), TCuikSystem::orig_eqMin, TCuikSystem::orig_equations, TCuikSystem::orig_variables, PrintEquations(), PrintMonomials(), PrintVariables(), and TCuikSystem::searchMode.

Referenced by AdjustBioWorldGeometry(), main(), and PrintWorldCS().

◆ PrintCuikSystemWithSimplification()

void PrintCuikSystemWithSimplification ( Tparameters p,
FILE *  f,
TCuikSystem cs 
)

Writes the simplified cuiksystem in a file that can be stdout. If the DEBUG mode is above 1 it first print the original system and then the simplified one (in the same file)

Parameters
pA set of parameters.
fThe stream where to write the simplified cuiksystem.
csThe cuiksystem.
See also
PrintCuikSystem

Definition at line 5585 of file cuiksystem.c.

References CT_SIMPLIFICATION_LEVEL, TCuikSystem::eqMin, TCuikSystem::equations, GetNumNonDynamicVariables(), GetNumSecondaryVariables(), GetNumSystemVariables(), GetNumVelocityVariables(), GetParameter(), GetVariableNames(), MINIMIZATION_SEARCH, NEW, NVariables(), TCuikSystem::orig2sd, TCuikSystem::orig_nvariables, TCuikSystem::orig_variables, PrintEquations(), PrintMapping(), PrintMonomials(), PrintVariables(), TCuikSystem::searchMode, TCuikSystem::simp_nvariables, TCuikSystem::simp_variables, UpdateCuikSystem(), and TCuikSystem::variables.

Referenced by DealWithCP(), and main().

◆ SaveCuikSystemSimplification()

void SaveCuikSystemSimplification ( Tparameters p,
FILE *  f,
TCuikSystem cs 
)

Saves the simplification information associated with a cuiksystem.

Parameters
pA set of parameters.
fThe stream where to write the simplification information.
csThe cuiksystem.

Definition at line 5626 of file cuiksystem.c.

References TCuikSystem::orig2sd, SaveMapping(), and UpdateCuikSystem().

◆ DeleteCuikSystem()