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

The CuikSuite Project

csmapping.c File Reference

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

#include "csmapping.h"
#include "defines.h"
#include <math.h>

Go to the source code of this file.

Functions

void InitMapping (Tvariables *o, Tvariables *s, Tmapping *m)
 Constructor.
void CopyMapping (Tmapping *m_dst, Tmapping *m_src)
 Copy constructor.
void SetOriginalVarRelation (unsigned int nvo, TLinearConstraint *lc, Tmapping *m)
 Set a relation for a variable in the original set.
void GetOriginalVarRelation (unsigned int nvo, TLinearConstraint *lc, Tmapping *m)
 Gets the relation for a variable in the original set with the variables in the simple set.
unsigned int GetSizeOriginal (Tmapping *m)
 Size of the variable set in the original system.
unsigned int GetSizeSimple (Tmapping *m)
 Size of the variable set in the simplified system.
unsigned int GetVarIDInOriginal (unsigned int v, Tmapping *m)
 Gets the original identifier of a simplified variable.
void SimpleFromOriginal (Tbox *o, Tbox *s, Tmapping *m)
 Gets a simple box from an original one.
void UpdateOriginalFromSimple (Tbox *s, Tbox *o, Tmapping *m)
 Gets a original box from an simplified one.
void PrintMapping (FILE *f, Tmapping *m)
 Prints a mapping.
void LoadMapping (FILE *f, Tmapping *m)
 Constructor. Loads the mapping information from a file.
void SaveMapping (FILE *f, Tmapping *m)
 Saves the mapping information into a file.
void DeleteMapping (Tmapping *m)
 Destructor.

Detailed Description

Implementation of the functions operating on Tmapping.

See also:
Tmapping, csmapping.h.

Definition in file csmapping.c.


Function Documentation

void InitMapping ( Tvariables o,
Tvariables s,
Tmapping m 
)

Generates a trivial mapping between two variable sets. The mapping is defined by checking which variables in one set are also present in the other. We identify variables using their name.
The mapping includes a copy of the variable sets. In this way, posterior modificications of the sets does not affect the mapping. The variable sets, though, are only used to pretty print the mappings.

Parameters:
o Variables in the original system.
s Variables in the simplified system.
m The mapping to initialize.

Definition at line 14 of file csmapping.c.

References AddTerm2LinearConstraint(), CopyVariables(), GetVariable(), GetVariableID(), GetVariableName(), InitLinearConstraint(), Tmapping::lc, NEW, NO_UINT, NVariables(), Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Referenced by SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void CopyMapping ( Tmapping m_dst,
Tmapping m_src 
)

Copies one mapping into another.

Parameters:
m_dst The mapping to create via copy.
m_src The original mapping.

Definition at line 64 of file csmapping.c.

References CopyLinearConstraint(), CopyVariables(), Tmapping::lc, NEW, Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Referenced by CopyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void SetOriginalVarRelation ( unsigned int  nvo,
TLinearConstraint lc,
Tmapping m 
)

Links a variable in the original problem with a variable in the simplified problem via a linear relation

nvo=a*nvs+b
Parameters:
nvo Numerical identifier of the variable in the original set.
lc The linear combination defining the relation.
m The mapping where to store the relation.

Definition at line 100 of file csmapping.c.

References CopyLinearConstraint(), Error(), Tmapping::lc, Tmapping::related, and TRUE.

Referenced by SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void GetOriginalVarRelation ( unsigned int  nvo,
TLinearConstraint lc,
Tmapping m 
)

Returns the linear constraint of variables in the simple set that defines a variable in the original set.

The output linear constraint is defined inside this function.

Parameters:
nvo Numerical identifier of the variable in the original set.
lc The output linear combination defining the relation.
m The mapping to query.

Definition at line 111 of file csmapping.c.

References CopyLinearConstraint(), InitLinearConstraint(), Tmapping::lc, and Tmapping::related.

Referenced by RewriteEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetSizeOriginal ( Tmapping m  ) 

Size of the variable set in the original system.

Parameters:
m The mapping to query.
Returns:
The number of variables in the set of variables in the original system.

Definition at line 119 of file csmapping.c.

References Tmapping::sizeO.

unsigned int GetSizeSimple ( Tmapping m  ) 

Size of the variable set in the simplified system.

Parameters:
m The mapping to query.
Returns:
The number of variables in the set of variables in the simplified system.

Definition at line 124 of file csmapping.c.

References Tmapping::sizeS.

unsigned int GetVarIDInOriginal ( unsigned int  v,
Tmapping m 
)

Gets the numerical identifier in the original set of variables corresponding to a variable in the simplified set (given by its numerical identifier).

Parameters:
v Identifier of the variable in the simplified set.
m The mapping from where to get the relation.
Returns:
The numerical identifier of the variable in the original set corresponding to the given variable identifier in the simplified set.

Definition at line 129 of file csmapping.c.

References NO_UINT, and Tmapping::orig.

Referenced by ComputeSplitDim().

Here is the caller graph for this function:

void SimpleFromOriginal ( Tbox o,
Tbox s,
Tmapping m 
)

Applies the mapping to define a box corresponding to the simple system from a box corresponding to the original system. We simply get the sub-set of the original variables used in the simplified one and join them into a box.

The box s is create inside this function.

Parameters:
o The box in the original system.
s The box in the simplified system.
m The mapping to apply.

Definition at line 137 of file csmapping.c.

References BoxFromVariables(), CopyInterval(), GetBoxInterval(), NO_UINT, Tmapping::orig, Tmapping::simple, and Tmapping::sizeS.

Referenced by ComputeSplitDim(), MaxReduction(), and SimplifyCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void UpdateOriginalFromSimple ( Tbox s,
Tbox o,
Tmapping m 
)

Applies the mapping to define a box corresponding to the original system from a box corresponding to the simple system.
In this case, the values of the box in the simple system override the values of the given box in the original system. The rationale is that if we take care of the simplified box to be defined properly, then we do not need to take care of undoing the mapping.

Variables in the original, not included in the simplification are not changed.

Note the difference with SimpleFromOriginal : here the output box o is just updated and not created from scratch.

Parameters:
s The box in the simplified system.
o The box in the original system.
m The mapping to apply.

Definition at line 159 of file csmapping.c.

References CopyInterval(), EvaluateLinearConstraintInt(), GetBoxInterval(), GetBoxIntervals(), GetLinearConstraintError(), Intersection(), IntervalAdd(), IntervalInvert(), Tmapping::lc, Tmapping::related, and Tmapping::sizeO.

Referenced by MaxReduction(), PostProcessBox(), and ReGenerateOriginalBox().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintMapping ( FILE *  f,
Tmapping m 
)

Prints a the linear relations defining a mapping into a stream, possibly stdout. The mapping is printed in the form

vo=a*vs+b


or

vo=b

where vo is an original variable and vs is a simplifed one.

Parameters:
f The stream where to print the mapping
m The mapping to apply.

Definition at line 184 of file csmapping.c.

References FALSE, GetVariableNames(), Tmapping::lc, NEW, Tmapping::original, PRINT_VARIABLE_NAME, PrintLinearConstraint(), Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Referenced by PrintCuikSystemWithSimplification().

Here is the call graph for this function:

Here is the caller graph for this function:

void LoadMapping ( FILE *  f,
Tmapping m 
)

Loads the mapping information into a file.

Note that the variable sets are load from the file and, thus, the mappings build from a file have no access to the variable names (this is used only for pretty printing the mappings).

Parameters:
f The file from where to read the mapping.
m The mapping to defined.

Definition at line 232 of file csmapping.c.

References InitLinearConstraint(), Tmapping::lc, LoadLinearConstraint(), NEW, Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, Tmapping::sizeO, and Tmapping::sizeS.

Here is the call graph for this function:

void SaveMapping ( FILE *  f,
Tmapping m 
)

Saves the mapping information into a file.

Note that the variable sets are not stored in the files. See LoadMapping for more about the consequences of this.

Parameters:
f The file where to store the mapping.
m The mapping to save.

Definition at line 257 of file csmapping.c.

References Tmapping::lc, Tmapping::orig, Tmapping::related, SaveLinearConstraint(), Tmapping::sizeO, and Tmapping::sizeS.

Referenced by SaveCuikSystemSimplification().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteMapping ( Tmapping m  ) 

Deletes a mapping.

Parameters:
m The mapping to delete.

Definition at line 276 of file csmapping.c.

References DeleteLinearConstraint(), DeleteVariables(), Tmapping::lc, Tmapping::orig, Tmapping::original, Tmapping::related, Tmapping::simple, and Tmapping::sizeO.

Referenced by UnUpdateCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function: