Detailed Description

Linear relation on R^n.

This class is a container to hold matrices A1 and A2 and a vector B to represent the relation

{(x1,x2) | A1 x1 + A2 x2 <= B}.

Effectively, a linear relation on R^n is a polyhedron on R^(2n). For an alternative parametrisation for a linear relation consider an affine map "x -> C x + d" and a subsequent bloat by a polyhedral offset "F x <= E", to obtain:

{(x1,x2) | F ( x2 - (C x1 + D) ) <= E}.

to convert the second from to the first, we have the correspondence

A1 = -F C; A2 = F; B = E + F D ;

The class maintains a flags to indicate the special cases {(x1,x2) | x2 = C x1 + D } and {(x1,x2) | x2 = x1 }. These flags, however, are purely syntatic, i.e., they need to be set by using the respective initialisers.

To facilitate the ussage of an external library that implements transformations on polyhedra, the Relation container can record untyped user data in a (void*) entry. See hyb_compute.cpp for a PLL based implemenation of a reachability analysis.

The token format is as follows:

% general relation
<A1Matrix>
...
</A1Matrix>
<A2Matrix>
...
</A2Matrix>
<BVector>
...
</BVector>
bool Relation(void) const
Test for data format.
% affine map
<CMatrix>
...
</CMatrix>
<DVector>
...
</DVector>
% identity
<Relation dimension="2"/>

Definition at line 970 of file hyb_parameter.h.

#include <hyb_parameter.h>

Public Member Functions

 LinearRelation (void)
 Default constructor. More...
 
 LinearRelation (int dim)
 Constructor by dimension. More...
 
 LinearRelation (const LinearRelation &rSrc)
 Copy-constructor. More...
 
 LinearRelation (const std::string &rFileName)
 Construct from file. More...
 
virtual ~LinearRelation (void)
 Destructor. More...
 
virtual const std::string & Name (void) const
 Object name. More...
 
virtual void Name (const std::string &name)
 Object name. More...
 
void Clear (void)
 Clear all. More...
 
Idx Size (void) const
 Get size. More...
 
int Dimension (void) const
 Get dimension. More...
 
void Dimension (int dim)
 Set dimension. More...
 
bool Relation (void) const
 Test for data format. More...
 
bool Map (void) const
 Test for data format. More...
 
bool Identity (void) const
 Test for data format. More...
 
const MatrixA1 (void) const
 Get A1 matrix. More...
 
const MatrixA2 (void) const
 Get A2 matrix. More...
 
const VectorB (void) const
 Get B vector. More...
 
const MatrixC (void) const
 Get C matrix. More...
 
const VectorD (void) const
 Get D vector. More...
 
void Relation (const Matrix &rA1, const Matrix &rA2, const Vector &rB)
 Set by A1, A2 and B. More...
 
void Map (const Matrix &rC, const Vector &rD)
 Set to affine map Cx+D. More...
 
void Identity (int dim)
 Set to identity. More...
 
void UserData (Type *data) const
 Set user data. More...
 
TypeUserData (void) const
 Get user data. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Protected Types

enum  TCase { R , M , I }
 Case enum. More...
 

Protected Member Functions

virtual LinearRelationDoAssign (const LinearRelation &rSrc)
 Assign from other polyhedron. More...
 
virtual bool DoEqual (const LinearRelation &rOther) const
 Test equality. More...
 
virtual void DoWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see Type::Write for public wrappers. More...
 
virtual void DoSWrite (TokenWriter &tw) const
 Write statistic info to TokenWriter, see Type::SWrite for public wrapper. More...
 
virtual void DoRead (TokenReader &tr, const std::string &rLabel="", const Type *pContext=0)
 Read from TokenReader, see Type::Read for public wrappers. More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

std::string mName
 have a name More...
 
TCase mCase
 Case flag. More...
 
Matrix mA1
 LinearRelation: data. More...
 
Matrix mA2
 
Vector mB
 
Matrix mC
 
Vector mD
 
TypempUserData
 User data. More...
 

Member Enumeration Documentation

◆ TCase

Case enum.

Enumerator

Definition at line 1186 of file hyb_parameter.h.

Constructor & Destructor Documentation

◆ LinearRelation() [1/4]

LinearRelation::LinearRelation ( void  )

Default constructor.

Sets dimension to 0 and the relation to be the identity map.

Definition at line 806 of file hyb_parameter.cpp.

◆ LinearRelation() [2/4]

LinearRelation::LinearRelation ( int  dim)

Constructor by dimension.

Sets the relation to be the identity map.

Parameters
dimDimension

Definition at line 819 of file hyb_parameter.cpp.

◆ LinearRelation() [3/4]

LinearRelation::LinearRelation ( const LinearRelation rSrc)

Copy-constructor.

Definition at line 839 of file hyb_parameter.cpp.

◆ LinearRelation() [4/4]

LinearRelation::LinearRelation ( const std::string &  rFileName)

Construct from file.

Definition at line 853 of file hyb_parameter.cpp.

◆ ~LinearRelation()

LinearRelation::~LinearRelation ( void  )
virtual

Destructor.

Definition at line 868 of file hyb_parameter.cpp.

Member Function Documentation

◆ A1()

const Matrix & LinearRelation::A1 ( void  ) const

Get A1 matrix.

Definition at line 948 of file hyb_parameter.cpp.

◆ A2()

const Matrix & LinearRelation::A2 ( void  ) const

Get A2 matrix.

Definition at line 953 of file hyb_parameter.cpp.

◆ B()

const Vector & LinearRelation::B ( void  ) const

Get B vector.

Definition at line 958 of file hyb_parameter.cpp.

◆ C()

const Matrix & LinearRelation::C ( void  ) const

Get C matrix.

Note: this is only defined for the cases Map and Identity.

Definition at line 963 of file hyb_parameter.cpp.

◆ Clear()

void LinearRelation::Clear ( void  )
virtual

Clear all.

Sets dimension to 0 with identity

Reimplemented from faudes::Type.

Definition at line 900 of file hyb_parameter.cpp.

◆ D()

const Vector & LinearRelation::D ( void  ) const

Get D vector.

Note: this is only defined for the cases Map and Identity.

Definition at line 968 of file hyb_parameter.cpp.

◆ Dimension() [1/2]

void LinearRelation::Dimension ( int  dim)

Set dimension.

Defaults to identity map.

Parameters
dimNew dimension

Definition at line 912 of file hyb_parameter.cpp.

◆ Dimension() [2/2]

int LinearRelation::Dimension ( void  ) const

Get dimension.

Returns
Dimension

Definition at line 923 of file hyb_parameter.cpp.

◆ DoAssign()

LinearRelation & LinearRelation::DoAssign ( const LinearRelation rSrc)
protectedvirtual

Assign from other polyhedron.

Parameters
rSrcSource to copy from
Returns
Ref to this polyhedron

Definition at line 874 of file hyb_parameter.cpp.

◆ DoEqual()

bool LinearRelation::DoEqual ( const LinearRelation rOther) const
protectedvirtual

Test equality.

Note: this test refers to the paramtrisation as oposed to the actual relation.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 888 of file hyb_parameter.cpp.

◆ DoRead()

void LinearRelation::DoRead ( TokenReader tr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Read from TokenReader, see Type::Read for public wrappers.

The method invokes TokenReader::ReadBegin() to seek the specified section, reads subsequent symbols, and calls matching TokenReader::ReadEnd(). If no section is specified, the section is assumed to start at the current position of the token stream. If the current position is no begin token, the section "LinearRelation" is read.

Parameters
trReference to TokenReader
rLabelLabel to read, defaults to current begin label or else "LinearRelation"
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 1)
  • token mismatch (id 50)

Reimplemented from faudes::Type.

Definition at line 1120 of file hyb_parameter.cpp.

◆ DoSWrite()

void LinearRelation::DoSWrite ( TokenWriter tw) const
protectedvirtual

Write statistic info to TokenWriter, see Type::SWrite for public wrapper.

Parameters
twReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 1106 of file hyb_parameter.cpp.

◆ DoWrite()

void LinearRelation::DoWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write to TokenWriter, see Type::Write for public wrappers.

Parameters
twReference to TokenWriter
rLabelLabel of the section to write, defaults to name of set or "LinearRelation"
pContextWrite context to provide contextual information (ignores)
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 1081 of file hyb_parameter.cpp.

◆ Identity() [1/2]

void LinearRelation::Identity ( int  dim)

Set to identity.

Parameters
dimdimension

Definition at line 1040 of file hyb_parameter.cpp.

◆ Identity() [2/2]

bool LinearRelation::Identity ( void  ) const

Test for data format.

True only if initialsed Identity.

Definition at line 931 of file hyb_parameter.cpp.

◆ Map() [1/2]

void LinearRelation::Map ( const Matrix rC,
const Vector rD 
)

Set to affine map Cx+D.

Parameters
rCC matrix
rBD vector
Exceptions
Exception
  • dimension missmatch (id 700);

Definition at line 1000 of file hyb_parameter.cpp.

◆ Map() [2/2]

bool LinearRelation::Map ( void  ) const

Test for data format.

True when initialsed via Map or Identity. When initialised by Relation, the map data format is not available.

Definition at line 937 of file hyb_parameter.cpp.

◆ Name() [1/2]

virtual void faudes::LinearRelation::Name ( const std::string &  name)
inlinevirtual

Object name.

Parameters
nameSet to specifies name

Reimplemented from faudes::Type.

Definition at line 1022 of file hyb_parameter.h.

◆ Name() [2/2]

virtual const std::string& faudes::LinearRelation::Name ( void  ) const
inlinevirtual

Object name.

Returns
name

Reimplemented from faudes::Type.

Definition at line 1014 of file hyb_parameter.h.

◆ Relation() [1/2]

void LinearRelation::Relation ( const Matrix rA1,
const Matrix rA2,
const Vector rB 
)

Set by A1, A2 and B.

Parameters
rA1A1 matrix
rA2A2 matrix
rBB vector
Exceptions
Exception
  • dimension missmatch (id 700);

Definition at line 973 of file hyb_parameter.cpp.

◆ Relation() [2/2]

bool LinearRelation::Relation ( void  ) const

Test for data format.

The current implementation allway sets up the matrices A1, A2 and B and, hence, allways returns true.

Definition at line 943 of file hyb_parameter.cpp.

◆ Size()

Idx LinearRelation::Size ( void  ) const

Get size.

Number of inequalities.

Returns
Eq count

Definition at line 906 of file hyb_parameter.cpp.

◆ UserData() [1/2]

void LinearRelation::UserData ( Type data) const

Set user data.

The relation takes ownership of the provided memory. On write access on the defining parameters the user data gets invalidated by means of "delete". The internal pointer is then set to NULL.

Definition at line 1068 of file hyb_parameter.cpp.

◆ UserData() [2/2]

Type * LinearRelation::UserData ( void  ) const

Get user data.

Returns
Pointer to user data, or NULL if no internal data available

Definition at line 1075 of file hyb_parameter.cpp.

Member Data Documentation

◆ mA1

Matrix faudes::LinearRelation::mA1
protected

LinearRelation: data.

Definition at line 1192 of file hyb_parameter.h.

◆ mA2

Matrix faudes::LinearRelation::mA2
protected

Definition at line 1193 of file hyb_parameter.h.

◆ mB

Vector faudes::LinearRelation::mB
protected

Definition at line 1194 of file hyb_parameter.h.

◆ mC

Matrix faudes::LinearRelation::mC
protected

Definition at line 1195 of file hyb_parameter.h.

◆ mCase

TCase faudes::LinearRelation::mCase
protected

Case flag.

Definition at line 1189 of file hyb_parameter.h.

◆ mD

Vector faudes::LinearRelation::mD
protected

Definition at line 1196 of file hyb_parameter.h.

◆ mName

std::string faudes::LinearRelation::mName
protected

have a name

Definition at line 1183 of file hyb_parameter.h.

◆ mpUserData

Type* faudes::LinearRelation::mpUserData
protected

User data.

Definition at line 1199 of file hyb_parameter.h.


The documentation for this class was generated from the following files:

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen