Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

cuiksystem.c File Reference

Implementation of the functions operating on TCuikSystem. More...

#include "cuiksystem.h"
#include "error.h"
#include "boolean.h"
#include "defines.h"
#include "box_list.h"
#include "box_heap.h"
#include "simplex.h"
#include "random.h"
#include "filename.h"
#include "geom.h"
#include <stdlib.h>
#include <gsl/gsl_linalg.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#include <mpi.h>
#include <sys/resource.h>
#include <time.h>
#include <unistd.h>

Go to the source code of this file.

Functions

void DummifyAndAddEquation (Tparameters *p, Tequation *eq, TCuikSystem *cs)
 Adds an equation to the cuiksystem.
void DummifyCuikSystem (Tparameters *p, TCuikSystem *cs)
 Apply the selected dummification level to a cuiksystem.
double EvaluateEqMin (void *b, void *cs)
 Evaluates the equation to minimize in a given box.
unsigned int ReduceBoxEquationWise (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Reduces a box considering one equation at a time.
unsigned int ReduceBox (Tparameters *p, unsigned int varMask, Tbox *b, TCuikSystem *cs)
 Reduces a box as much as possible.
void PostProcessBox (Tparameters *p, unsigned int c, FILE *f_out, Tlist *sol, Theap *boxes, Tbox *b, TCuikSystem *cs)
 Process a box after being reduced.
void CSRemoveUnusedVars (Tparameters *p, TCuikSystem *cs)
 Removes non-used variables.
boolean CSRemoveVarsWithCtRange (Tparameters *p, boolean *replaced, TLinearConstraint *lc, Tbox *borig, TCuikSystem *cs)
 Removes variables with constant range.
boolean CSRemoveLCVars (Tparameters *p, unsigned int level, boolean *changed, boolean *replaced, TLinearConstraint *lc, Tbox *borig, TCuikSystem *cs)
 Removes variables that are linearly dependent on other variables.
boolean SimplifyCuikSystem (Tparameters *p, TCuikSystem *cs)
 Simplifies a cuiksystem.
void ComputeSimpCuikSystemJacobian (TCuikSystem *cs)
 Defines the Jacobian of the simplified CuikSystem.
void DeleteSimpCuikSystemJacobian (TCuikSystem *cs)
 Deletes the Jacobian generated by ComputeSimpCuikSystemJacobian.
boolean UpdateCuikSystem (Tparameters *p, TCuikSystem *cs)
 Updates the cached information for the cuiksystem.
void UnUpdateCuikSystem (TCuikSystem *cs)
 Removes the cached information for the cuiksystem.
unsigned int ComputeSplitDimInt (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Computes the optimal split dimension for a given box.
void SaveCSState (char *fname, Tlist *lb, TCuikSystem *cs)
 Saves internal the cuik solver state information to a file.
void LoadCSState (char *fname, Tlist *lb, TCuikSystem *cs)
 Retrives the internal the cuik solver state information from a file.
void InitCuikSystem (TCuikSystem *cs)
 Constructor.
void CopyCuikSystem (TCuikSystem *cs_dst, TCuikSystem *cs_src)
 Copy constructor.
void CuikSystemMerge (Tparameters *p, TCuikSystem *cs1, TCuikSystem *cs2, TCuikSystem *cs)
 Produces the union of two cuik systems.
boolean CmpBoxesEquation (void *b1, void *b2, void *cs)
 Determines which box to explore first in minimization mode.
void SetCSSearchMode (unsigned int sm, Tequation *eqMin, TCuikSystem *cs)
 Sets the search mode for the cuiksystem.
void AddTerm2SearchCriterion (double w, unsigned int v, double val, TCuikSystem *cs)
 Adds penalty terms to the search criterion.
void AddEquation2CS (Tparameters *p, Tequation *eq, TCuikSystem *cs)
 Adds an equation to the system.
unsigned int AddVariable2CS (Tvariable *v, TCuikSystem *cs)
 Adds a variable to the system.
void GetCSVariables (Tvariables *vs, TCuikSystem *cs)
 Gets the cuiksystem variables.
unsigned int GetCSNumVariables (TCuikSystem *cs)
 Gets the number of variables already in the cuiksystem.
unsigned int GetCSNumNonDummyVariables (TCuikSystem *cs)
 Gets the number of non-dummy variables already in the cuiksystem.
void GetCSVariable (unsigned int n, Tvariable *v, TCuikSystem *cs)
 Gets the a variable from a cuiksystem.
void SetCSVariableRange (unsigned int n, Tinterval *r, TCuikSystem *cs)
 Gets the range of a variable from a cuiksystem.
unsigned int GetCSVariableID (char *name, TCuikSystem *cs)
 Gets the numerical identifier of a variable given its name.
unsigned int GetCSSystemVars (boolean **sv, TCuikSystem *cs)
 Identifies the system variables.
void GetCSEquations (Tequations *eqs, TCuikSystem *cs)
 Gets a copy of the system equations.
void GetCSEquation (unsigned int n, Tequation *eq, TCuikSystem *cs)
 Gets the an equation from a cuiksystem.
unsigned int GetCSNumEquations (TCuikSystem *cs)
 Gets the number of equations already in the cuiksystem.
void GetCuikSystemJacobian (Tequation ***J, TCuikSystem *cs)
 Defines the Jacobian of a CuikSystem.
void DeleteCuikSystemJacobian (Tequation **J, TCuikSystem *cs)
 Deletes the Jacobian generated by GetCuikSystemJacobian.
unsigned int MaxReduction (Tparameters *p, unsigned int varMask, Tbox *b, TCuikSystem *cs)
 Reduces a box as much as possible.
boolean SampleCuikSystem (Tparameters *p, char *fname, Tlist *sb, unsigned int nsamples, unsigned int ntries, unsigned int ndof, TCuikSystem *cs)
 Generates samples for a cuiksystem.
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.
void SolveCuikSystem (Tparameters *p, unsigned int nsols, boolean restart, char *fstate, FILE *f_out, Tlist *sol, TCuikSystem *cs)
 Determines the solution set for a cuiksystem.
void MPI_SolveCuikSystem (Tparameters *p, boolean restart, char *fstate, FILE *f_out, TCuikSystem *cs)
 Determines the solution set for a cuiksystem. Main scheduler.
void MPI_TreatBox (Tparameters *p, TCuikSystem *cs)
 Determines the solution set for a cuiksystem. Child process.
void GenerateInitialBox (Tbox *box, TCuikSystem *cs)
 Gives the search space in the form of a box.
void ReGenerateOriginalBox (Tparameters *p, Tbox *boxS, Tbox *boxO, TCuikSystem *cs)
 Generates a box in the original cuiksystem from a box of the simplified one.
unsigned int ComputeSplitDim (Tparameters *p, Tbox *b, TCuikSystem *cs)
 Determines the best dimensions to split a given box.
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).
double ErrorInSolution (Tbox *b, TCuikSystem *cs)
 Maximum error for a box.
double ErrorInInequalities (Tbox *b, TCuikSystem *cs)
 Maximum inequality error for a box.
boolean CoordInequalitiesHold (Tbox *b, TCuikSystem *cs)
 Tests if all coordenalization inqualities hold for the given variable ranges.
void PrintCuikSystem (Tparameters *p, FILE *f, TCuikSystem *cs)
 Prints a cuiksystem.
void PrintCuikSystemWithSimplification (Tparameters *p, FILE *f, TCuikSystem *cs)
 Prints a cuiksystem.
void SaveCuikSystemSimplification (Tparameters *p, FILE *f, TCuikSystem *cs)
 Saves the simplification information associated with a cuiksystem.
void DeleteCuikSystem (TCuikSystem *cs)
 Destructor.

Detailed Description

Implementation of the functions operating on TCuikSystem.

See also:
TCuikSystem, cuiksystem.h.

Definition in file cuiksystem.c.


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:
p The set of parameters.
eq The equation to add.
cs The cuiksystem where to add the equation.

Definition at line 431 of file cuiksystem.c.

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

Referenced by DummifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void DummifyCuikSystem ( Tparameters p,
TCuikSystem cs 
)

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

Parameters:
p The set of parameters.
cs The cuiksystem where to add the equation.
See also:
DummifyAndAddEquation

Definition at line 691 of file cuiksystem.c.

References CopyEquations(), CT_DUMMIFY, CT_EPSILON, DeleteEquations(), DummifyAndAddEquation(), TCuikSystem::equations, GetEquation(), GetParameter(), InitEquations(), and NEquations().

Referenced by SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
b The box.
cs The TCuikSystem structure storing the equation to use when evaluating
Returns:
The value of the equation to minimize in the given box.

Definition at line 2193 of file cuiksystem.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
b The box to be reduced.
cs The 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 712 of file cuiksystem.c.

References 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, and TRUE.

Referenced by ReduceBox().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
varMask The 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).
b The box to be reduced.
cs The 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 831 of file cuiksystem.c.

References AddEquation2Simplex(), BoxInclusion(), CopyBox(), CT_EPSILON, CT_LR2TM_Q, CT_LR2TM_S, CT_RHO, CT_SAFE_SIMPLEX, CT_SIGMA, CT_SMALL_SIGMA, DeleteBox(), TCuikSystem::empty, 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(), SimplexColEmpty(), SimplexCreate(), SimplexDelete(), SimplexNRows(), TCuikSystem::st, TCuikSystem::systemVar, TRUE, TCuikSystem::updated, TCuikSystem::variables, and TCuikSystem::varType.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
c Output of ReduceBox (EMPTY_BOX, REDUCED_BOX, REDUCED_BOX_WITH_SOLUTION, ERROR_IN_PROCESS).
f_out File where to store solutions. If NULL solutions are to written to any file.
sol List 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.
boxes Set of boxes pending to be processed.
b The processed box.
cs The cuiksystem used to process the box.
See also:
ReduceBox

Definition at line 1058 of file cuiksystem.c.

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

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
cs The cuiksystem to simplify.
See also:
SimplifyCuikSystem

Definition at line 1228 of file cuiksystem.c.

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

Referenced by SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
replaced TRUE if the i-th variable in the original cuiksystem has been replaced.
lc If replaced[i] is TRUE, lc[i] is the linear constraint giving the replacement of variable 'i' in function of the other variables.
borig A 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.
cs The cuiksystem to simplify.
Returns:
TRUE if the cuiksystem still holds.
See also:
SimplifyCuikSystem

Definition at line 1254 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().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean CSRemoveLCVars ( Tparameters p,
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:
p The set of parameters.
changed Is set to TRUE if this function makes any change into the cuiksystem.
level Level (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.
replaced TRUE if the i-th variable in the original cuiksystem has been replaced.
lc If replaced[i] is TRUE, lc[i] is the linear constraint giving the replacement of variable 'i' in function of the other variables.
borig A 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.
cs The cuiksystem to simplify.
Returns:
TRUE if the cuiksystem still holds.
See also:
SimplifyCuikSystem

Definition at line 1339 of file cuiksystem.c.

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

Referenced by SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
cs The cuiksystem to simplify.

Definition at line 1501 of file cuiksystem.c.

References AddCt2LinearConstraint(), AddTerm2LinearConstraint(), BoxFromVariables(), CopyEquations(), CopyVariables(), CSRemoveLCVars(), CSRemoveUnusedVars(), CSRemoveVarsWithCtRange(), CT_EPSILON, 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, PrintEquations(), PrintVariables(), SetOriginalVarRelation(), SetVariableInterval(), TCuikSystem::simp_equations, TCuikSystem::simp_variables, SimpleFromOriginal(), TRUE, and TCuikSystem::variables.

Referenced by UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void ComputeSimpCuikSystemJacobian ( TCuikSystem cs  ) 

Defines the Jacobian of the simplified cuiksystem but only for equality equations.

This is an auxiliary function of UpdateCuikSystem.

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

Note that the space for the derivatives is reserved insided this function and should be freed using DeleteCuikSystemJacobian.

Parameters:
cs The cuik system from where to extract the Jacobian.

Definition at line 2461 of file cuiksystem.c.

References DeriveEquation(), EQU, GetEquation(), GetEquationCmp(), TCuikSystem::J, NEW, TCuikSystem::simp_equations, TCuikSystem::simp_nee, and TCuikSystem::simp_nvariables.

Referenced by UpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteSimpCuikSystemJacobian ( TCuikSystem cs  ) 

Deletes the Jacobian generated by ComputeSimpCuikSystemJacobian.

This is an auxiliary function of UnUpdateCuikSystem.

Parameters:
cs The cuiksystem with the Jacobian to delete.

Definition at line 2481 of file cuiksystem.c.

References DeleteEquation(), Error(), TCuikSystem::J, TCuikSystem::simp_nee, TCuikSystem::simp_nvariables, and TCuikSystem::updated.

Referenced by UnUpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
cs The cuiksystem to be updated.
See also:
UnUpdateCuikSystem SimplifyCuikSystem

Definition at line 1756 of file cuiksystem.c.

References ComputeSimpCuikSystemJacobian(), CT_EPSILON, DEPTH_FIRST_SEARCH, TCuikSystem::empty, TCuikSystem::eqMin, TCuikSystem::equations, Error(), GetNumMonomials(), GetParameter(), GetVariableNames(), GetVariableTypeN(), IsDummyVariable(), IsSystemVariable(), MINIMIZATION_SEARCH, NEqualityEquations(), TCuikSystem::nequations, NEquations(), NEW, TCuikSystem::notDummyVar, TCuikSystem::nvariables, 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(), RewriteEquation(), TCuikSystem::searchMode, TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nequations, TCuikSystem::simp_nvariables, TCuikSystem::simp_variables, SimplifyCuikSystem(), TCuikSystem::systemVar, TRUE, TCuikSystem::updated, TCuikSystem::variables, and TCuikSystem::varType.

Referenced by ComputeSplitDim(), ComputeSplitDimInt(), MaxReduction(), MPI_SolveCuikSystem(), MPI_TreatBox(), PrintCuikSystemWithSimplification(), ReGenerateOriginalBox(), SaveCuikSystemSimplification(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void UnUpdateCuikSystem ( 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 removeing the cached information and the cuiksystem simplification.

Parameters:
cs The cuiksystem to be un-updated.
See also:
UpdateCuikSystem SimplifyCuikSystem

Definition at line 1684 of file cuiksystem.c.

References DeleteEquation(), DeleteEquations(), DeleteMapping(), DeleteSimpCuikSystemJacobian(), DeleteVariables(), TCuikSystem::eqMin, TCuikSystem::equations, FALSE, MINIMIZATION_SEARCH, TCuikSystem::nequations, TCuikSystem::notDummyVar, TCuikSystem::nvariables, TCuikSystem::orig2s, TCuikSystem::orig2sd, TCuikSystem::orig_nequations, TCuikSystem::orig_notDummyVar, TCuikSystem::orig_nvariables, TCuikSystem::orig_systemVar, TCuikSystem::orig_varNames, TCuikSystem::searchMode, TCuikSystem::simp_equations, TCuikSystem::simp_nee, TCuikSystem::simp_nequations, TCuikSystem::simp_nvariables, TCuikSystem::simp_variables, TCuikSystem::systemVar, TCuikSystem::updated, TCuikSystem::variables, and TCuikSystem::varType.

Referenced by AddEquation2CS(), AddVariable2CS(), DeleteCuikSystem(), SampleCuikSystemInBox(), and SetCSVariableRange().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
b The box to be split.
cs The cuiksystem.
Returns:
The preferred split dimension for the box.

Definition at line 1861 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
fname The name of the file where to write the information.
lb The list of boxes pending to be processed.
cs The cuiksystem.
See also:
LoadCSState

Definition at line 1976 of file cuiksystem.c.

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

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
fname The name of the file from where to read the information.
lb The list of boxes pending to be processed.
cs The cuiksystem.
See also:
SaveCSState

Definition at line 2005 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
cs1 The first cuik system merge.
cs2 The second cuiksystem to merge.
cs The output merged cuiksystem.

Definition at line 2149 of file cuiksystem.c.

References AccumulateEquations(), AddEquation2CS(), AddVariable2CS(), CopyEquation(), CopyEquations(), CopyVariables(), TCuikSystem::empty, FALSE, GetEquation(), GetVariable(), InitCuikSystem(), NEquations(), 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::searchMode, TCuikSystem::systemVar, TCuikSystem::updated, and TCuikSystem::varType.

Here is the call graph for this function:

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:
b1 The first box.
b2 The second box.
cs The 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 2237 of file cuiksystem.c.

References EvaluateEqMin().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
sm Search mode: DEPTH_FIRST_SEARCH, BREADTH_FIRST_SEARCH or MINIMIZATION_SEARCH.
eqMin When the search mode is MINIMIZATION_SEARCH, the criterion to be minimized. Otherwise it is not used.
cs The cuiksystem to update.

Definition at line 2242 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
w Weight for the new constraint to add.
v Variable for the new constraint to add.
val Targed value for the new variable. Typically the center of the variable range.
cs The cuiksystem to update.

Definition at line 2262 of file cuiksystem.c.

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

Referenced by GenerateJointRangeEquations().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p A set of parameters.
eq The equation to add.
cs The cuiksystem where to add the equation.

Definition at line 2305 of file cuiksystem.c.

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

Referenced by CuikSystemMerge(), GenerateEquationsFromBranch(), GenerateJointEquations(), GenerateJointRangeEquations(), and GenerateLinkRot().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int AddVariable2CS ( Tvariable v,
TCuikSystem cs 
)

Adds a new variable to the system.

Parameters:
v The variable to add.
cs The 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 2319 of file cuiksystem.c.

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

Referenced by CuikSystemMerge(), GenerateEquationsFromBranch(), GenerateJointEquations(), GenerateJointRangeEquations(), and GenerateLinkRot().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
vs Pointer to the space where to copy the variables.
cs The cuiksystem from where to get the variables.
See also:
CopyVaribles

Definition at line 2337 of file cuiksystem.c.

References CopyVariables(), and TCuikSystem::orig_variables.

Here is the call graph for this function:

unsigned int GetCSNumVariables ( TCuikSystem cs  ) 

Returns the number of variables already in the cuiksystem.

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

Definition at line 2345 of file cuiksystem.c.

References NVariables(), and TCuikSystem::orig_variables.

Referenced by MoveWorld(), and SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
cs The cuiksystem to query.
Returns:
The number of non-dummy variables already in the cuiksystem.

Definition at line 2353 of file cuiksystem.c.

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

Referenced by AnimateWorld().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
n Numerical identifier of the variable to get.
v Place where to store the copy of the variable.
cs The cuiksystem to query.
See also:
CopyVariable

Definition at line 2361 of file cuiksystem.c.

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

Here is the call graph for this function:

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:
n Numerical identifier of the variable to get.
r Place where to store the copy of the interval.
cs The cuiksystem to query.
See also:
CopyInterval

Definition at line 2369 of file cuiksystem.c.

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

Referenced by SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetCSVariableID ( char *  name,
TCuikSystem cs 
)

Returns the numerical identifier of a variable given its name.

Parameters:
name Name of the variable.
cs The cuiksystem to query.
Returns:
The numerical identifier. NO_UINT if there is no variable with the given name in the cuiksystem.

Definition at line 2381 of file cuiksystem.c.

References GetVariableID(), and TCuikSystem::orig_variables.

Referenced by ApplyLinkRot(), GenerateJointEquationsInBranch(), GenerateJointRangeEquations(), GenerateLinkRot(), GetTransform2Link(), and RegenerateJointSolution().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
sv Pointer to the pointer of booleans to be allocated and updated.
cs The cuiksystem to query.
Returns:
The number of system variables in the cuiksystem.

Definition at line 2391 of file cuiksystem.c.

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

Referenced by GenerateWorldEquationSystems(), GetWorldSystemVars(), main(), and SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void GetCSEquations ( Tequations eqs,
TCuikSystem cs 
)

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

Parameters:
eqs Place where to copy the system variables.
cs The cuiksystem to query.
See also:
CopyEquations

Definition at line 2407 of file cuiksystem.c.

References CopyEquations(), and TCuikSystem::orig_equations.

Here is the call graph for this function:

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:
n Numerical identifier of the equation to get.
eq Place where to store the copy of the equation.
cs The cuiksystem to query.
See also:
CopyEquation

Definition at line 2415 of file cuiksystem.c.

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

Here is the call graph for this function:

unsigned int GetCSNumEquations ( TCuikSystem cs  ) 

Returns the number of equations already in the cuiksystem.

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

Definition at line 2423 of file cuiksystem.c.

References NEquations(), and TCuikSystem::orig_equations.

Referenced by SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void GetCuikSystemJacobian ( Tequation ***  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.

Note that the space for the derivatives is reserved insided this function and should be freed using DeleteCuikSystemJacobian.

Parameters:
J Space where to allocate space and store the derivatives.
cs The cuik system from where to extract the Jacobian.

Definition at line 2428 of file cuiksystem.c.

References DeriveEquation(), GetEquation(), NEquations(), NEW, NVariables(), TCuikSystem::orig_equations, and TCuikSystem::orig_variables.

Here is the call graph for this function:

void DeleteCuikSystemJacobian ( Tequation **  J,
TCuikSystem cs 
)

Deletes the Jacobian generated by GetCuikSystemJacobian.

Parameters:
J The Jacobian out of GetCuikSystemJacobian.
cs The cuiksystem from where the Jacobian were generated.

Definition at line 2444 of file cuiksystem.c.

References DeleteEquation(), NEquations(), NVariables(), TCuikSystem::orig_equations, and TCuikSystem::orig_variables.

Here is the call graph for this function:

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

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

Parameters:
p A set of parameters.
varMask The 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).
b The box to be reduced.
cs The cuiksystem with the constraints to use to reduce the box.

Definition at line 2514 of file cuiksystem.c.

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

Referenced by MaxKinematicReduction(), and SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p A set of parameters.
fname Base name for the output files. If NULL, the solutions are not stored in any file.
sb List of boxes where to store the solutions. If NULL, the boxes are not listed.
nsamples The number of samples to generate.
ntries Number 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.
ndof The 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.
cs The 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 2538 of file cuiksystem.c.

References DeleteBox(), GenerateInitialBox(), and SampleCuikSystemInBox().

Here is the call graph for this function:

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:
p A set of parameters.
fname Base name for the output files. If NULL, the solutions are not stored in any file.
sb List of boxes where to store the solutions. If NULL, the boxes are not listed.
nsamples The number of samples to generate.
ntries Number 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.
ndof The 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_box Box where to generate samples.
cs The 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 2554 of file cuiksystem.c.

References AddLastElement(), Advance(), ChangeParameter(), ComputeSplitDim(), CopyBox(), CreateFileName(), CT_EPSILON, 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(), MaxReduction(), NEW, NewInterval(), NO_UINT, NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_variables, PrintBox(), randomInInterval(), SAMPLE_EXT, SetCSVariableRange(), SetVariableInterval(), SOL_EXT, SolveCuikSystem(), SYSTEM_VAR, TRUE, UnUpdateCuikSystem(), TCuikSystem::updated, and UsedVarInEquations().

Referenced by SampleCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void SolveCuikSystem ( Tparameters p,
unsigned int  nsols,
boolean  restart,
char *  fstate,
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:
p A set of parameters.
nsols The number of solution boxes we want. 0 if we want all of them. This is mainly used when sampling when we want a fixed number of samples (i.e., solutions) but in can be used also to limit the execution time for CuikSolve.
restart TRUE is the process has be re-started from a previous execution that was, for some reason, crashed.
fstate Name 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).
f_out File 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).
sol List of boxes where to store the solutions. If NULL, the boxes are not listed.
cs The cuiksystem to solve.
See also:
MPI_SolveCuikSystem

Definition at line 2809 of file cuiksystem.c.

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

Referenced by main(), and SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void MPI_SolveCuikSystem ( Tparameters p,
boolean  restart,
char *  fstate,
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:
p A set of parameters.
restart TRUE is the process has be re-started from a previous execution that was, for some reason, crashed.
fstate Name 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).
f_out File 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,...).
cs The cuiksystem to solve.
See also:
SolveCuikSystem

Definition at line 2966 of file cuiksystem.c.

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

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p A set of parameters.
cs The cuiksystem to solve.
See also:
MPI_SolveCuikSystem

Definition at line 3325 of file cuiksystem.c.

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

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
box The output box with the variable ranges.
cs The cuiksystem.

Definition at line 3417 of file cuiksystem.c.

References BoxFromVariables(), and TCuikSystem::orig_variables.

Referenced by GetGlobalInitialBox(), SampleCuikSystem(), and SampleCuikSystemInBox().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p The set of parameters.
boxS The input box in the simplified system.
boxO The output box in the original system. The box is created insided this function.
cs The cuiksystem to which boxes are supposed to refer to. If this is not so the behavior is undefined.

Definition at line 3422 of file cuiksystem.c.

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

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
p A set of parameters.
b The box to be split.
cs The cuiksystem.
Returns:
The dimension along to which the box is to be bisected.

Definition at line 3440 of file cuiksystem.c.

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

Referenced by SampleCuikSystemInBox(), and SplitGlobalBox().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
v A vector of doubles with one entry for each one of the system variables.
b The box with the ranges for the variables (including the system ones).
cs The cuiksystem.
Returns:
TRUE if the point is fully included in the system sub-box.
See also:
SampleCuikSystemInBox SampleCuikSystem

Definition at line 3461 of file cuiksystem.c.

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

Here is the call graph for this function:

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:
b The solution box.
cs The cuiksystem.
Returns:
Maximum error for the equations for the central point of the box.

Definition at line 3494 of file cuiksystem.c.

References EQU, Error(), EvaluateEquation(), GetBoxInterval(), GetBoxNIntervals(), GetEquation(), GetEquationCmp(), GetEquationType(), GetEquationValue(), IntervalCenter(), NEquations(), NEW, NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_nvariables, TCuikSystem::orig_variables, and SYSTEM_EQ.

Referenced by PostProcessBox().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
b The solution box.
cs The cuiksystem.
Returns:
Maximum error for the inequality equations for the central point of the box.

Definition at line 3534 of file cuiksystem.c.

References Error(), EvaluateEquation(), GEQ, GetBoxInterval(), GetBoxNIntervals(), GetEquation(), GetEquationCmp(), GetEquationValue(), IntervalCenter(), LEQ, NEquations(), NEW, NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_nvariables, and TCuikSystem::orig_variables.

Here is the call graph for this function:

boolean CoordInequalitiesHold ( Tbox b,
TCuikSystem cs 
)

Coordenalization inequalities are used for collision detection. This function tests if all coordenalization inqualities hold for the given variable ranges. If so, the box is collision free. This is a very simple test that, in most of the cases, fails. It is only effective when we select a fix separating plane (maybe sampling in the space of valid parameters for the separating planes). It is also effective when the mechanisms is only composed by spheres and the collision detection is based on computing the distance between the sphere centers. Intuitively, since the sphere radii is constant, this is like having a fix separating plane.

Parameters:
b The box with the variable ranges
cs The cuiksystem with the equations.
Returns:
TRUE if all coordenalization inqualities hold for variable ranges in the given box.

Definition at line 3585 of file cuiksystem.c.

References COORD_EQ, Error(), EvaluateEquationInt(), GEQ, GetBoxIntervals(), GetBoxNIntervals(), GetEquation(), GetEquationCmp(), GetEquationType(), GetEquationValue(), LEQ, LowerLimit(), NEquations(), NVariables(), TCuikSystem::orig_equations, TCuikSystem::orig_variables, TRUE, and UpperLimit().

Here is the call graph for this function:

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

Writes the cuiksystem in a file that can be stdout.

Parameters:
p A set of parameters.
f The stream where to write the cuiksystem.
cs The cuiksystem.

Definition at line 3631 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 PrintWorldCS().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Writes the cuiksystem in a file that can be stdout. This function is like PrintCuikSystem but it prints both the original set of equations and the simplified one, plus the mapping between them.

Parameters:
p A set of parameters.
f The stream where to write the cuiksystem.
cs The cuiksystem.
See also:
PrintCuikSystem

Definition at line 3656 of file cuiksystem.c.

References CT_SIMPLIFICATION_LEVEL, TCuikSystem::eqMin, TCuikSystem::equations, GetParameter(), GetVariableNames(), MINIMIZATION_SEARCH, NEW, NVariables(), TCuikSystem::orig2sd, TCuikSystem::orig_eqMin, TCuikSystem::orig_equations, TCuikSystem::orig_variables, PrintEquations(), PrintMapping(), PrintMonomials(), PrintVariables(), TCuikSystem::searchMode, UpdateCuikSystem(), and TCuikSystem::variables.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Saves the simplification information associated with a cuiksystem.

Parameters:
p A set of parameters.
f The stream where to write the simplification information.
cs The cuiksystem.

Definition at line 3703 of file cuiksystem.c.

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

Here is the call graph for this function:

void DeleteCuikSystem ( TCuikSystem cs  ) 

Deletes a cuiksystem.

Parameters:
cs The cuiksystem to be deleted.

Definition at line 3714 of file cuiksystem.c.

References DeleteEquations(), DeleteStatistics(), DeleteVariables(), TCuikSystem::empty, TCuikSystem::orig_equations, TCuikSystem::orig_variables, TCuikSystem::st, TRUE, and UnUpdateCuikSystem().

Referenced by DeleteWorldCS(), and main().

Here is the call graph for this function:

Here is the caller graph for this function: