cuiksystem.c File Reference

Detailed Description

Implementation of the functions operating on TCuikSystem.

See Also
TCuikSystem, cuiksystem.h.

Definition in file cuiksystem.c.

Functions

void DummifyAndAddEquation (Tparameters *p, Tequation *eq, TCuikSystem *cs)
 Adds an equation to the cuiksystem. More...
 
void DummifyCuikSystem (Tparameters *p, TCuikSystem *cs)
 Apply the selected dummification level to a cuiksystem. More...
 
double EvaluateEqMin (void *b, void *cs)
 Evaluates the equation to minimize in a given box. More...
 
unsigned int ReduceBoxEquationWise (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Reduces a box considering one equation at a time. More...
 
unsigned int ReduceBox (Tparameters *p, unsigned int varMask, Tbox *b, TCuikSystem *cs)
 Reduces a box as much as possible. More...
 
void PostProcessBox (Tparameters *p, unsigned int c, FILE *f_out, Tlist *sol, Theap *boxes, Tbox *b, TCuikSystem *cs)
 Process a box after being reduced. More...
 
void CSRemoveUnusedVars (Tparameters *p, TCuikSystem *cs)
 Removes non-used variables. More...
 
boolean CSRemoveVarsWithCtRange (Tparameters *p, boolean *replaced, TLinearConstraint *lc, Tbox *borig, TCuikSystem *cs)
 Removes variables with constant range. More...
 
boolean CSRemoveLCVars (Tparameters *p, unsigned int simplificationLevel, unsigned int level, boolean *changed, boolean *replaced, TLinearConstraint *lc, Tbox *borig, TCuikSystem *cs)
 Removes variables that are linearly dependent on other variables. More...
 
boolean SimplifyCuikSystem (Tparameters *p, TCuikSystem *cs)
 Simplifies a cuiksystem. More...
 
void AddJacobianEquationsInt (Tparameters *p, boolean *selectedVars, TJacobian *J, TCuikSystem *cs)
 Adds linear a linear combination of the Jacobian to the system. More...
 
boolean UpdateCuikSystem (Tparameters *p, TCuikSystem *cs)
 Updates the cached information for the cuiksystem. More...
 
void UnUpdateCuikSystem (TCuikSystem *cs)
 Removes the cached information for the cuiksystem. More...
 
unsigned int ComputeSplitDimInt (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Computes the optimal split dimension for a given box. More...
 
void SaveCSState (char *fname, Tlist *lb, TCuikSystem *cs)
 Saves internal the cuik solver state information to a file. More...
 
void LoadCSState (char *fname, Tlist *lb, TCuikSystem *cs)
 Retrives the internal the cuik solver state information from a file. More...
 
void InitCuikSystem (TCuikSystem *cs)
 Constructor. 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...
 
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...
 
unsigned int AddVariable2CS (Tvariable *v, TCuikSystem *cs)
 Adds a variable 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 GetCSNumNonDummyVariables (TCuikSystem *cs)
 Gets the number of non-dummy variables already in the cuiksystem. 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...
 
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 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...
 
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...
 
unsigned int GetCSNumEquations (TCuikSystem *cs)
 Gets the number of equations already in the cuiksystem. 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...
 
void GetSimpCSJacobian (Tparameters *p, TJacobian *J, TCuikSystem *cs)
 Defines the Jacobian 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 AddSimplifiedJacobianEquations (Tparameters *p, boolean *selectedVars, TCuikSystem *cs)
 Adds linear a linear combination of the Jacobian to the system. More...
 
unsigned int MaxReduction (Tparameters *p, unsigned int varMask, double *reduction, 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...
 
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 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...
 
void EvaluateCSJacobian (double *p, double ***J, TCuikSystem *cs)
 Evaluates the Jacobian of the system in a given point. More...
 
double ErrorInCSEquations (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...
 
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...
 
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...
 

Function Documentation

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

Adds an equation to the cuiksystem taking into account the dummification level selected by the user when fixing the parameters. In the extreme dummification level, all quadratic and bilinear terms in the equations are replaced by a new (dummy) variable and the corresponding equation parabola or saddle equation is added to the system. In the other extreme (i.e., not to dummify anything) equations are added as given by the user to the system.
In any case, adding an equation with a degree higher than 2 produdes an error.

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

Definition at line 422 of file cuiksystem.c.

References AddCt2Monomial(), AddEquation(), AddMonomial(), AddVariable(), AddVariable2Monomial(), CircleEquation(), CT_DUMMIFY, DeleteEquation(), DeleteMonomial(), DeleteVariable(), DUMMY_EQ, DUMMY_VAR, EQU, TCuikSystem::equations, Error(), GetEquationCmp(), GetEquationOrder(), GetEquationType(), GetEquationValue(), GetEquationVariables(), GetMonomial(), GetMonomialCt(), GetMonomialVariables(), GetNumMonomials(), GetParameter(), GetVariable(), GetVariableFunctionN(), GetVariableID(), GetVariableInterval(), GetVariableN(), GetVariableName(), GetVariablePowerN(), InitEquation(), InitMonomial(), IntervalPow(), IntervalProduct(), LinearEquation(), NEW, NewVariable(), NFUN, NO_UINT, NVariables(), ParabolaEquation(), SaddleEquation(), SetEquationCmp(), SetEquationType(), SetEquationValue(), SetVariableInterval(), SphereEquation(), TRUE, TCuikSystem::variables, and VariableSetSize().

Referenced by DummifyCuikSystem().

void DummifyCuikSystem ( Tparameters p,
TCuikSystem cs 
)

Dummify all equations in the cuiksystem according to the parameters given by the user.

Parameters
pThe set of parameters.
csThe cuiksystem where to add the equation.
See Also
DummifyAndAddEquation

Definition at line 695 of file cuiksystem.c.

References CopyEquations(), DeleteEquations(), DummifyAndAddEquation(), TCuikSystem::equations, GetEquation(), InitEquations(), NEquations(), and TCuikSystem::scalar.

Referenced by SimplifyCuikSystem().

double EvaluateEqMin ( void *  b,
void *  cs 
)

Evaluates the equation to minimize when the search mode is set to MINIMIZATION_SEARCH. In any other search mode the output is 0.

Note that the input box is a box in the simplified system since, for efficiency, the equation to minimize is re-written into this system too.

Parameters
bThe box.
csThe TCuikSystem structure storing the equation to use when evaluating
Returns
The value of the equation to minimize in the given box.

Definition at line 2369 of file cuiksystem.c.

References Error(), EvaluateEquationInt(), EvaluateWholeEquation(), GetBoxInterval(), GetBoxIntervals(), GetEquationValue(), IntervalCenter(), IntervalOffset(), MINIMIZATION_SEARCH, NEW, and NVariables().

Referenced by CmpBoxesEquation(), PostProcessBox(), and SolveCuikSystem().

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

Reduces the ranges of a box considering one equation at a time. Linear equations are cropped directly and non-linear equations are linearized. Special treatement is implement for parabola, circle, sphere, and saddle equations since they appear frequently and the non-linear cropping is stronger than the one obtained via linearization.
Note that considering only one equation at a time we only obtaion local consistancy.

Parameters
pThe set of parameters.
bThe box to be reduced.
csThe cuiksystem with the equations to use.
Returns
The status of the box after the reduction (EMPTY_BOX, REDUCED_BOX)
See Also
ReduceRange

Definition at line 714 of file cuiksystem.c.

References ANY_TYPE_VAR, CopyBox(), CropEquation(), CT_EPSILON, CT_RHO, CT_SMALL_SIGMA, DeleteBox(), EMPTY_BOX, TCuikSystem::equations, FALSE, GetBoxInterval(), GetBoxSize(), GetBoxVolume(), GetParameter(), IntervalSize(), TCuikSystem::nvariables, PrintBox(), REDUCED_BOX, TCuikSystem::systemVar, TRUE, and TCuikSystem::variables.

Referenced by ReduceBox().

unsigned int ReduceBox ( Tparameters p,
unsigned int  varMask,
Tbox b,
TCuikSystem cs 
)

Reduces the ranges of a box as much as possible applying first an equation-wise crop and then a simplex-based reduction. If the reduction is significative (i.e., the reduction ratio is above paramter RHO) and the box is not smaller than SMALL_SIGMA, the reduction process is iterated.
Observe that SMALL_SIGMA can be much smaller that SIGMA (the parameter to accept a box as a solution). The idea here is that if a box contains a punctual solution it will be shrink till it has a size below SMALL_SIGMA and, if the box bounds a patch of a continuous solution set, the box will not be smaller more than SIGMA.
If the reduced box is fully included in the original box, then we can certify that the box has a solution.

Parameters
pThe 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).
bThe box to be reduced.
csThe cuiksystem with the equations to use.
Returns
The status of the box after the reduction (EMPTY_BOX, REDUCED_BOX, REDUCED_BOX_WITH_SOLUTION, ERROR_IN_PROCESS).
See Also
ReduceBoxEquationWise ReduceRange

Definition at line 833 of file cuiksystem.c.

References AddEquation2Simplex(), BoxInclusion(), TCuikSystem::consistent, CopyBox(), CT_EPSILON, CT_LR2TM_Q, CT_LR2TM_S, CT_RHO, CT_SAFE_SIMPLEX, CT_SMALL_SIGMA, DeleteBox(), EMPTY_BOX, TCuikSystem::equations, Error(), ERROR_IN_PROCESS, FALSE, GetBoxInterval(), GetBoxSize(), GetBoxVolume(), GetParameter(), IntervalSize(), NewBoxReduction(), TCuikSystem::notDummyVar, TCuikSystem::nvariables, PrintBox(), ReduceBoxEquationWise(), REDUCED_BOX, REDUCED_BOX_WITH_SOLUTION, ReduceRange(), ResetSimplex(), TCuikSystem::simp_nequations, SimplexColEmpty(), SimplexCreate(), SimplexDelete(), SimplexNRows(), TCuikSystem::st, TCuikSystem::systemVar, TRUE, TCuikSystem::updated, TCuikSystem::variables, and TCuikSystem::varType.

Referenced by MaxReduction(), MPI_TreatBox(), and SolveCuikSystem().

void PostProcessBox ( Tparameters p,
unsigned int  c,
FILE *  f_out,
Tlist sol,
Theap boxes,
Tbox b,
TCuikSystem cs 
)

After box reduction we have to decide what to do with the box. If it empty, we just discart it. If is small enough (smaller than SIGMA) we consider it as a solution. Finally, non-empty, non-small boxes are bisected and added to the list of boxes pending to be processed.

Parameters
pThe set of parameters.
cOutput of ReduceBox (EMPTY_BOX, REDUCED_BOX, REDUCED_BOX_WITH_SOLUTION, ERROR_IN_PROCESS).
f_outFile where to store solutions. If NULL solutions are to written to any file.
solList where to store solutions. If NULL solutions are not listed. Be aware that it makes few sense to solve a problem and use f_out=NULL and sol=NULL since there will be no way to know the solutions.
boxesSet of boxes pending to be processed.
bThe processed box.
csThe cuiksystem used to process the box.
See Also
ReduceBox

Definition at line 1059 of file cuiksystem.c.

References AddBox2HeapOfBoxes(), AddLastElement(), BoxFromVariables(), ComputeSplitDimInt(), CONVERGED_IN_BOX, CONVERGED_IN_GLOBAL, CopyBox(), CT_EPSILON, CT_MAX_NEWTON_ITERATIONS, CT_SIGMA, CuikNewtonInBox(), CUT_POINT, DeleteBox(), EMPTY_BOX, ERROR_IN_PROCESS, ErrorInSolution(), EvaluateEqMin(), GetBoxDiagonal(), GetBoxLevel(), GetBoxSize(), GetBoxVolume(), GetElapsedTime(), GetNSolutionBoxes(), GetParameter(), MINIMIZATION_SEARCH, NEW, NewEmptyBox(), NewRBError(), NewSolutionBox(), NewSplittedBox(), TCuikSystem::orig2sd, TCuikSystem::orig_notDummyVar, TCuikSystem::orig_nvariables, TCuikSystem::orig_systemVar, TCuikSystem::orig_variables, TCuikSystem::orig_varNames, PrintBox(), PrintBoxSubset(), REDUCED_BOX_WITH_SOLUTION, TCuikSystem::searchMode, SplitBox(), TCuikSystem::st, TCuikSystem::systemVar, and UpdateOriginalFromSimple().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

void CSRemoveUnusedVars ( Tparameters p,
TCuikSystem cs 
)

Remove the variables that do not appear in the equation set.
This is one of the steps executed in the cuiksystem simplification.

Parameters
pThe set of parameters.
csThe cuiksystem to simplify.
See Also
SimplifyCuikSystem

Definition at line 1260 of file cuiksystem.c.

References CT_EPSILON, DUMMY_VAR, TCuikSystem::equations, GetEquationVariables(), GetParameter(), GetVariableTypeN(), NVariables(), TCuikSystem::orig_eqMin, RemoveEquationsWithVar(), RemoveVariable(), SYSTEM_VAR, UsedVarInEquations(), UsedVarInNonDummyEquations(), TCuikSystem::variables, and VarIncluded().

Referenced by SimplifyCuikSystem().

boolean CSRemoveVarsWithCtRange ( Tparameters p,
boolean replaced,
TLinearConstraint lc,
Tbox borig,
TCuikSystem cs 
)

Variables with punctual range are constants that can be removed from the equations. If the variables was previously used to replace another variable in the cuiksystem then the replaced variable also becomes constant.
This is one of the steps executed in the cuiksystem simplification. The simplification is the process of defining a new set of equations and variables from those given by the user but eliminating variables with trivial values or variables that are linearly related with other variables. In this process, all variable indexes are referred to those in the original cuiksystem (since the simplified one is still in construction).

Parameters
pThe set of parameters.
replacedTRUE if the i-th variable in the original cuiksystem has been replaced.
lcIf replaced[i] is TRUE, lc[i] is the linear constraint giving the replacement of variable 'i' in function of the other variables.
borigA box with the ranges for the variables in the original system. Those ranges are updated as simplifications are introduce. At the end, the ranges are used to set the ranges for the variables in the simplified system.
csThe cuiksystem to simplify.
Returns
TRUE if the cuiksystem still holds.
See Also
SimplifyCuikSystem

Definition at line 1286 of file cuiksystem.c.

References AddCt2LinearConstraint(), CT_EPSILON, DeleteLinearConstraint(), TCuikSystem::equations, Error(), FALSE, GetBoxInterval(), GetParameter(), GetVariable(), GetVariableID(), GetVariableName(), GetVariableNames(), InitLinearConstraint(), IntervalSize(), LowerLimit(), NEW, NO_UINT, NVariables(), TCuikSystem::orig_variables, PrintEquations(), PrintVariables(), RemoveVariable(), ReplaceVariableInEquations(), TRUE, and TCuikSystem::variables.

Referenced by SimplifyCuikSystem().

boolean CSRemoveLCVars ( Tparameters p,
unsigned int  simplificationLevel,
unsigned int  level,
boolean changed,
boolean replaced,
TLinearConstraint lc,
Tbox borig,
TCuikSystem cs 
)

Detects equations of the form

\[ \sum_{i=1}{n} a_i\:x_i = c \]

From where a variable replacement can be defined

\[ x_j=\frac{1}{a_j}\left(\sum_{i \neq j} a_i\:x_i - c\right) \]

Note that if $x_j$ was used to replace another variable, $z$, the elimination of $x_j$ has to be propagated to the linear constraint replacing $z$.

This is one of the steps executed in the cuiksystem simplification. The simplification is the process of defining a new set of equations and variables from those given by the user but eliminating variables with trivial values or variables that are linearly related with other variables. In this process, all variable indexes are referred to those in the original cuiksystem (since the simplified one is still in construction).

Parameters
pThe set of parameters.
simplificationLevelThe simplification level.
changedIs set to TRUE if this function makes any change into the cuiksystem.
levelLevel (or complexity) of the simplification. Maximum number of terms in the linear combination used to replace the variable. It makes sense to first replace variables assigned to constants and then variables assigned to another variable and so on. Therefore, this function is used with increasing values of n.
replacedTRUE if the i-th variable in the original cuiksystem has been replaced.
lcIf replaced[i] is TRUE, lc[i] is the linear constraint giving the replacement of variable 'i' in function of the other variables.
borigA box with the ranges for the variables in the original system. Those ranges are updated as simplifications are introduce. At the end, the ranges are used to set the ranges for the variables in the simplified system.
csThe cuiksystem to simplify.
Returns
TRUE if the cuiksystem still holds.
See Also
SimplifyCuikSystem

Definition at line 1371 of file cuiksystem.c.

References AddCt2LinearConstraint(), AddLinearConstraints(), AddTerm2LinearConstraint(), ANY_TYPE_VAR, CopyLinearConstraint(), CropLinearConstraint(), CT_EPSILON, DeleteBox(), DeleteLinearConstraint(), TCuikSystem::equations, Error(), FALSE, GetEquation(), GetLinearConstraintCoefficient(), GetLinearConstraintError(), GetLinearConstraintVariable(), GetNumTermsInLinearConstraint(), GetParameter(), GetVariable(), GetVariableID(), GetVariableInterval(), GetVariableName(), GetVariableNames(), InitBox(), IntervalCenter(), IntervalSize(), IsSimplificable(), IsSystemVariable(), LinearConstraintIncludes(), NEquations(), NEW, NO_UINT, NVariables(), TCuikSystem::orig_variables, PrintEquations(), PrintLinearConstraint(), PrintVariables(), RemoveTermFromLinearConstraint(), RemoveVariable(), ReplaceVariableInEquations(), ScaleLinearConstraint(), SetBoxInterval(), TRUE, TCuikSystem::variables, and ZERO.

Referenced by SimplifyCuikSystem().

boolean SimplifyCuikSystem ( Tparameters p,
TCuikSystem cs 
)

Generate a simplified version of a cuiksystem by eliminating variables with constant values from the equations and by replacing variables by other variables if there is a linear dependency between them.
Note that this is an iterative process (when a variable becomes constant it can trigger further simplifications). In extremely large systems this can be slow.

Simplifications can introduce numerical issues. For instance to replace a variable that appear in a equation like

\[ a x = b, \]

we have to operate b/a and this can introduce perturbations in the system due to floating point rounding. We try to do our best to avoid problems (for instance we only apply the above simplification if a=1) but small perturbation are unavoidable in general and for particularly ill-conditioned problems they can lead to simplified systems with a different set of solutions than the original system. If you encounter such a problem it would be safer to operate directly with the original system and not with the simplified one. This can be done, setting the SIMPLIFICATION_LEVEL parameter to 0.

Parameters
pThe set of parameters.
csThe cuiksystem to simplify.

Definition at line 1539 of file cuiksystem.c.

References AddCt2LinearConstraint(), AddTerm2LinearConstraint(), BoxFromVariables(), CopyEquations(), CopyVariables(), CSRemoveLCVars(), CSRemoveUnusedVars(), CSRemoveVarsWithCtRange(), CT_SIMPLIFICATION_LEVEL, DeleteBox(), DeleteLinearConstraint(), DummifyCuikSystem(), TCuikSystem::equations, FALSE, GaussianElimination(), GetBoxInterval(), GetLinearConstraintCoefficient(), GetLinearConstraintError(), GetLinearConstraintVariable(), GetNumTermsInLinearConstraint(), GetParameter(), GetVariable(), GetVariableID(), GetVariableName(), GetVariableNames(), InitLinearConstraint(), InitMapping(), IntervalCenter(), MAX_TERMS_SIMP, NEW, NVariables(), TCuikSystem::orig2s, TCuikSystem::orig2sd, TCuikSystem::orig_equations, TCuikSystem::orig_variables, PolynomialEquations(), PrintEquations(), PrintVariables(), TCuikSystem::scalar, SetOriginalVarRelation(), SetVariableInterval(), TCuikSystem::simp_equations, TCuikSystem::simp_variables, SimpleFromOriginal(), TRUE, and TCuikSystem::variables.

Referenced by UpdateCuikSystem().

void AddJacobianEquationsInt ( Tparameters p,
boolean selectedVars,
TJacobian J,
TCuikSystem cs 
)

This is the common part of AddJacobianEquations and AddSimplifiedJacobianEquations. It basically operates on a given Jacobian, independently of where this Jacobian comes from.

Note that the new equations are to be added to the original system and therefore the input Jacobian MUST be expressed in this system of equations. For instance, when adding equations from the simplified system we have to first re-write the equations in terms of the original variables.

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

Definition at line 2695 of file cuiksystem.c.

References AccumulateEquations(), AddEquation2CS(), AddVariable2CS(), CopyEquation(), DeleteEquation(), DeleteVariable(), EQU, Error(), GenerateGeneralNormEquation(), GetJacobianEquation(), GetJacobianSize(), InitEquation(), NEW, NewInterval(), NewVariable(), TCuikSystem::scalar, SetEquationCmp(), SetEquationType(), SetVariableInterval(), SYSTEM_EQ, SYSTEM_VAR, and VarScaleEquation().

Referenced by AddJacobianEquations(), and AddSimplifiedJacobianEquations().

boolean UpdateCuikSystem ( Tparameters p,
TCuikSystem cs 
)

The cuiksystem stores some cached information about variables and equations. This information has to be re-computed everytime the cuiksystem is modified.
This functions takes care of re-computing the cached information.
Additionally, this functions triggers the cuiksystem simplification since we cache information both for the original and the simplified systems.

Parameters
pThe set of parameters.
csThe cuiksystem to be updated.
See Also
UnUpdateCuikSystem SimplifyCuikSystem

Definition at line 1844 of file cuiksystem.c.

References TCuikSystem::consistent, CT_EPSILON, DEPTH_FIRST_SEARCH, TCuikSystem::empty, TCuikSystem::eqMin, TCuikSystem::equations, Error(), FALSE, GetNumMonomials(), GetParameter(), GetVariableNames(), GetVariablesTopology(), GetVariableTypeN(), InitJacobian(), IsDummyVariable(), IsSecondaryVariable(), IsSystemVariable(), TCuikSystem::J, MINIMIZATION_SEARCH, NEqualityEquations(), TCuikSystem::nequations, NEquations(), NEW, 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::orig_varNames, ResetEquation(), RewriteEquation2Simp(), TCuikSystem::searchMode, TCuikSystem::simp_empty, TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nequations, TCuikSystem::simp_nvariables, TCuikSystem::simp_tp, TCuikSystem::simp_variables, SimplifyCuikSystem(), TCuikSystem::systemVar, TOPOLOGY_R, TRUE, TCuikSystem::updated, TCuikSystem::variables, and TCuikSystem::varType.

Referenced by AddJacobianEquations(), AddSimplifiedJacobianEquations(), ComputeSplitDim(), ComputeSplitDimInt(), CuikNewtonInBox(), CuikNewtonSimp(), ErrorInSimpCSEquations(), ErrorInSimpInequalitiesOnPoint(), EvaluateSimpCSEquations(), EvaluateSubSetSimpCSEquations(), GenerateSimpInitialBox(), GenerateSimplifiedPoint(), GetSimpCSJacobian(), GetSimpCSTopology(), IncrementalSampleCuikSystemInBox(), IsSystemVarInSimpCS(), MaxReduction(), MPI_SolveCuikSystem(), MPI_TreatBox(), PrintCuikSystemWithSimplification(), RegenerateOriginalBox(), RegenerateOriginalPoint(), RegenerateSolution(), RegenerateSolutionPoint(), SaveCuikSystemSimplification(), SimpInequalitiesHoldOnPoint(), SolveCuikSystem(), and VerifyCuikSystem().

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

Selects and optimal split dimension for a given box.
The selection depent on the split policy determined by the user. If parameter SPLIT_ERROR is TRUE, we take select as split dimension the variable that introduces a higher linearization error for the different equations (i.e., the variable with a largest contribution to the linearization error). Otherwise, we split dimension is the argest box side.
Only dimensions corresponding to system variables are selected as split dimensions.

Parameters
pThe set of parameters.
bThe box to be split.
csThe cuiksystem.
Returns
The preferred split dimension for the box.

Definition at line 1972 of file cuiksystem.c.

References CT_EPSILON, CT_SPLIT_TYPE, TCuikSystem::equations, Error(), GetBoxIntervals(), GetParameter(), INF, IntervalSize(), TCuikSystem::nequations, NEW, NO_UINT, TCuikSystem::nvariables, randomMax(), TCuikSystem::systemVar, UpdateCuikSystem(), UpdateSplitWeight(), and Warning().

Referenced by ComputeSplitDim(), and PostProcessBox().

void SaveCSState ( char *  fname,
Tlist lb,
TCuikSystem cs 
)

While solving a problem, every STATE_PERIOD processed boxes we store the solver state into a file. In this way if the process crashes, we can re-start the solver from the last saved state.
The save information includes the solver statistics and the list of boxes pending to be processed. In the case of a parallel execution this last list includes also the boxes already send to the children processors but that are still in process.
If STATE_PERIOD is set to 0 no state information is saved.

Parameters
fnameThe name of the file where to write the information.
lbThe list of boxes pending to be processed.
csThe cuiksystem.
See Also
LoadCSState

Definition at line 2093 of file cuiksystem.c.

References Error(), GetElapsedTime(), NEW, SaveListOfBoxes(), SaveStatistics(), and TCuikSystem::st.

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

void LoadCSState ( char *  fname,
Tlist lb,
TCuikSystem cs 
)

Retrives the internal the cuik solver state information from a file previously saved by SaveCSState. This allows to init the solving process from a intermediate point (and not from scratch) after, for intance, a power failure.

Parameters
fnameThe name of the file from where to read the information.
lbThe list of boxes pending to be processed.
csThe cuiksystem.
See Also
SaveCSState

Definition at line 2122 of file cuiksystem.c.

References Error(), First(), GetBoxNIntervals(), GetCurrent(), GetTime(), InitIterator(), LoadListOfBoxes(), LoadStatistics(), TCuikSystem::nvariables, SetInitialTime(), and TCuikSystem::st.

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

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 2194 of file cuiksystem.c.

References Error(), and UpdateCuikSystem().

Referenced by main().

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 2320 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.

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 2413 of file cuiksystem.c.

References EvaluateEqMin().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

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 2418 of file cuiksystem.c.

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

Referenced by 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 2438 of file cuiksystem.c.

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

Referenced by GenerateJointRangeEquations().

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

Adds a new equation to the system. The equation must use the variables already added to the system. Repeated equations are not added to the system.

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

Definition at line 2481 of file cuiksystem.c.

References AddEquation(), TCuikSystem::orig_equations, UnUpdateCuikSystem(), and TCuikSystem::updated.

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

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 2490 of file cuiksystem.c.

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

Referenced by GenerateEquationsFromBranch().

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 2511 of file cuiksystem.c.

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

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

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 2529 of file cuiksystem.c.

References CopyVariables(), and TCuikSystem::orig_variables.

Referenced by GenerateWorldEquations().

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 2534 of file cuiksystem.c.

References GetVariableNames(), and TCuikSystem::orig_variables.

Referenced by AdjustBioWorldGeometry(), and GetWorldVarNames().

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 2544 of file cuiksystem.c.

References NVariables(), and TCuikSystem::orig_variables.

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

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 2549 of file cuiksystem.c.

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

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

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 2558 of file cuiksystem.c.

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

Referenced by AnimateWorld().

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 2566 of file cuiksystem.c.

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

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 2574 of file cuiksystem.c.

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

Referenced by GetSCpSystem(), and SampleCuikSystemInBox().

unsigned int GetCSVariableID ( char *  name,
TCuikSystem cs 
)
char* GetCSVariableName ( unsigned int  id,
TCuikSystem cs 
)

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

Parameters
idThe identifier 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 2591 of file cuiksystem.c.

References TCuikSystem::orig_variables, and VariableName().

Referenced by GetLinkPoseSimpVars().

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 2596 of file cuiksystem.c.

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

Referenced by GetLinkPoseSimpVars().

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 and secondary variables.

In coherence with the definition of the orig_systemVar field of TCuikSystem, here we identify system and secondary varibles. Internally, though, we differentiate between them (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 system variables in the cuiksystem.

Definition at line 2614 of file cuiksystem.c.

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

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

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 2627 of file cuiksystem.c.

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

Referenced by GetWorldVarTopology().

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 2635 of file cuiksystem.c.

References CopyEquations(), and TCuikSystem::orig_equations.

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 2643 of file cuiksystem.c.

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

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 2651 of file cuiksystem.c.

References TCuikSystem::orig_equations, and PolynomialEquations().

Referenced by IsWorldPolynomial().

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 2656 of file cuiksystem.c.

References TCuikSystem::scalar.

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 2664 of file cuiksystem.c.

References NEquations(), and TCuikSystem::orig_equations.

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

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 2669 of file cuiksystem.c.

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

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

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 2674 of file cuiksystem.c.

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

Referenced by GetWorldSimpTopology().

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 2683 of file cuiksystem.c.

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

Referenced by GetWorldSimpJacobian().

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 2758 of file cuiksystem.c.

References AddJacobianEquationsInt(), CopyCuikSystem(), DeleteCuikSystem(), DeleteJacobian(), Error(), GetCSJacobian(), GetJacobianSize(), UnUpdateCuikSystem(), and UpdateCuikSystem().

Referenced by main().

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. Origianl 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 2788 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(), RewriteEquation2Orig(), TCuikSystem::scalar, TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nvariables, TCuikSystem::simp_variables, TRUE, UnUpdateCuikSystem(), UpdateCuikSystem(), and VariableName().

Referenced by GenerateWorldTWSEquations().

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 2908 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().

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 2941 of file cuiksystem.c.

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

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 2960 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().

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 3218 of file cuiksystem.c.

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

Referenced by main().

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 3238 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().

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 3571 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().

unsigned int CuikNewtonInBox ( Tparameters p,
Tbox box,
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.

Note that parameter box is used both for input and for output. As an input it defienes the box from where to drawn the initial point for the Newton method. As an output it is a small box around the last point of the Newton iteration (the solution if the process converged).

Parameters
pA set of parameters.
boxThe 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 3667 of file cuiksystem.c.

References ArrayPi2Pi(), BoxFromVariables(), 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().

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 3905 of file cuiksystem.c.

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

Referenced by main(), and NewtonInWorld().

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 3926 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().

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 4103 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().

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 4490 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().

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 4583 of file cuiksystem.c.

References BoxFromVariables(), and TCuikSystem::orig_variables.

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

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 4588 of file cuiksystem.c.

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

Referenced by GetWorldSimpInitialBox().

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 4596 of file cuiksystem.c.

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

Referenced by CuikNewtonInBox(), and 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 4660 of file cuiksystem.c.

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

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 4701 of file cuiksystem.c.

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

Referenced by main().

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 4712 of file cuiksystem.c.

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

Referenced by GetLinkTransformsFromSolutionPoint(), and RegenerateWorldOriginalPoint().

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 4725 of file cuiksystem.c.

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

Referenced by WorldGenerateSimplifiedPoint().

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 4742 of file cuiksystem.c.

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

Referenced by SampleCuikSystemInBox().

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 4766 of file cuiksystem.c.

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

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 4793 of file cuiksystem.c.

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

Referenced by WorldEvaluateEquations().

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 4798 of file cuiksystem.c.

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

Referenced by WorldEvaluateSimpEquations().

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 4806 of file cuiksystem.c.

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

Referenced by WorldEvaluateSubSetSimpEquations().

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 4814 of file cuiksystem.c.

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

Referenced by EvaluateWorldJacobian().

double ErrorInCSEquations ( 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
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 4826 of file cuiksystem.c.

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

Referenced by main(), and WorldErrorInEquations().

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 4845 of file cuiksystem.c.

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

Referenced by CuikNewtonSimp(), and WorldErrorInSimpEquations().

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 4867 of file cuiksystem.c.

References EvaluateWholeEquation().

Referenced by EvaluateWorldCost().

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 4885 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().

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 4924 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 CuikNewtonInBox().

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 4953 of file cuiksystem.c.

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

Referenced by WorldInequalitiesHold().

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 4973 of file cuiksystem.c.

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

Referenced by WorldSimpInequalitiesHold().

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 4996 of file cuiksystem.c.

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

Referenced by WorldErrorInSimpInequalities().

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 5022 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().

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 5047 of file cuiksystem.c.

References CT_SIMPLIFICATION_LEVEL, TCuikSystem::eqMin, TCuikSystem::equations, GetNumSecondaryVariables(), GetNumSystemVariables(), GetParameter(), GetVariableNames(), MINIMIZATION_SEARCH, NEW, NVariables(), TCuikSystem::orig2sd, TCuikSystem::orig_eqMin, TCuikSystem::orig_equations, 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().

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 5102 of file cuiksystem.c.

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