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

The CuikSuite Project

cuiksystem.h File Reference

Definition of the TCuikSystem type and the associated functions. More...

#include "equations.h"
#include "boolean.h"
#include "variables.h"
#include "interval.h"
#include "variable_set.h"
#include <stdlib.h>
#include "linear_constraint.h"
#include "box.h"
#include "equation.h"
#include <glpk.h>
#include <Clp/Clp_C_Interface.h>
#include <lp_solve/lp_lib.h>
#include <stdio.h>
#include <time.h>
#include <sys/times.h>
#include "list.h"
#include "box_list.h"
#include "vector.h"
#include "csmapping.h"

Go to the source code of this file.

Data Structures

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

Defines

#define DEPTH_FIRST_SEARCH   1
 Depth first search.
#define BREADTH_FIRST_SEARCH   2
 Breadth first search.
#define MINIMIZATION_SEARCH   3
 Search based on a minimum value of a given equation.
#define CUT_POINT   0.45+0.1*randomDouble()
#define MPI_TREAT_BOX_TIMEOUT(cs)   (cs->nvariables*SIMPLEX_TIMEOUT*10)
 MPI child-process timeout.

Functions

void InitCuikSystem (TCuikSystem *cs)
 Constructor.
void InitCuikSystemFromFile (Tparameters *p, char *filename, TCuikSystem *cs)
 Constructor from a file.
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.
unsigned int AddVariable2CS (Tvariable *v, TCuikSystem *cs)
 Adds a variable to the system.
void AddEquation2CS (Tparameters *p, Tequation *eq, TCuikSystem *cs)
 Adds an equation 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.
unsigned int GetCSNumEquations (TCuikSystem *cs)
 Gets the number of equations already in the cuiksystem.
void GetCSEquation (unsigned int n, Tequation *eq, TCuikSystem *cs)
 Gets the an equation from a 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

Definition of the TCuikSystem type and the associated functions.

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

Definition in file cuiksystem.h.


Define Documentation

#define DEPTH_FIRST_SEARCH   1

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

Definition at line 32 of file cuiksystem.h.

Referenced by InitCuikSystem(), MPI_SolveCuikSystem(), SetCSSearchMode(), SolveCuikSystem(), and UpdateCuikSystem().

#define BREADTH_FIRST_SEARCH   2

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

Definition at line 41 of file cuiksystem.h.

Referenced by MPI_SolveCuikSystem(), SetCSSearchMode(), and SolveCuikSystem().

#define MINIMIZATION_SEARCH   3

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

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

Definition at line 54 of file cuiksystem.h.

Referenced by AddTerm2SearchCriterion(), CopyCuikSystem(), EvaluateEqMin(), MPI_SolveCuikSystem(), PostProcessBox(), PrintCuikSystem(), PrintCuikSystemWithSimplification(), SetCSSearchMode(), SolveCuikSystem(), UnUpdateCuikSystem(), and UpdateCuikSystem().

#define CUT_POINT   0.45+0.1*randomDouble()

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

Definition at line 66 of file cuiksystem.h.

Referenced by PostProcessBox(), and SplitGlobalBox().

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

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

Definition at line 75 of file cuiksystem.h.

Referenced by MPI_SolveCuikSystem().


Function Documentation

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

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

Parameters:
p A set of parameters.
filename The name of the file from which to read the variables and equations.
cs The cuiksystem to initialize.

Referenced by main().

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:

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 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:

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:

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 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:

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: