syn_2_ctrlpfx.cpp File Reference
#include "libfaudes.h"

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Tutorial, controllability prefix

/** @file syn_2_ctrlpfx.cpp
Tutorial, controllability prefix
@ingroup Tutorials
@include syn_2_ctrlpfx.cpp
*/
#include "libfaudes.h"
// we make the faudes namespace available to our program
using namespace faudes;
/////////////////
// main program
/////////////////
int main() {
/////////////////////////////////////////////
// Demo of mu/nu fixpoint iterations
// (this is the example used in out IFAC2020 contribution)
/////////////////////////////////////////////
// Read example data from file
System sys("data/syn_2_ctrlpfx.gen");
// Have controllabe events
EventSet sigctrl=sys.ControllableEvents();
// Report to console
std::cout << "################################\n";
std::cout << "# generator \n";
sys.DWrite();
std::cout << "################################\n";
std::cout << std::endl;
// Turn on logging
// Instantiate my operator
CtrlPfxOperator cfxop_Y_X(sys,sigctrl);
// Have the inner mu-iteration
MuIteration cfxop_Y_muX(cfxop_Y_X);
// Have the outer nu--iteration
NuIteration cfxop_nuY_muX(dynamic_cast<StateSetOperator&>(cfxop_Y_muX));
// run
std::cout << "################################\n";
std::cout << "# running nu-mu nested fixpoint iteration: " << cfxop_nuY_muX.Name() << std::endl;
StateSet cfx;
cfxop_nuY_muX.Evaluate(cfx);
std::cout << "# resulting fixpoint: " << std::endl;
cfx.Write();
std::cout << "################################\n";
std::cout << std::endl;
// record result
FAUDES_TEST_DUMP("ifac2020 example",cfx);
/////////////////////////////////////////////
// Demo of implementing SupCon as nu-mu iteration
// (also along the line of our IFAC 2020 contribution)
/////////////////////////////////////////////
// read problem data L and E
System plant("./data/syn_eleplant.gen");
Generator spec("./data/syn_elespec.gen");
EventSet sigall = plant.Alphabet() + spec.Alphabet();
sigctrl = plant.ControllableEvents() + (spec.Alphabet()-plant.Alphabet());
// closded-loop candidate: mark L cap E
Generator sup;
Automaton(spec,sup);
sup.StateNamesEnabled(false);
ParallelLive(plant,sup,sup);
// take controllability prefix
std::cout << "################################\n";
std::cout << "# computing controllability prefix\n";
std::cout << "# state count: " << sup.Size() << std::endl;
CtrlPfxOperator xcfxop_Y_X(sup,sigctrl);
MuIteration xcfxop_Y_muX(xcfxop_Y_X);
NuIteration xcfxop_nuY_muX(dynamic_cast<StateSetOperator&>(xcfxop_Y_muX));
StateSet xcfx;
xcfxop_nuY_muX.Evaluate(xcfx);
std::cout << "# state count of fixpoint: " << xcfx.Size() << std::endl;
// derive supremal closed-loop behaviour
sup.InjectMarkedStates(xcfx);
SupClosed(sup,sup);
Trim(sup);
Parallel(sup,spec,sup);
Parallel(sup,plant,sup);
std::cout << "# closed-loop statistics" << std::endl;
sup.SWrite();
// validate against std SupCon
std::cout << "# validate w.r.t. std implementation of SupCon\n";
Generator ssup;
InvProject(plant,sigall);
plant.SetControllable(sigctrl);
InvProject(spec,sigall);
ssup.StateNamesEnabled(false);
SupCon(plant,spec,ssup);
StateMin(ssup,ssup);
ssup.SWrite();
bool eql=LanguageEquality(ssup,sup);
if(eql)
std::cout << "# closed-loop behaviours match (tast case pass)\n";
else
std::cout << "# closed-loop behaviours do not match (test case FAIL)\n";
std::cout << "################################\n";
std::cout << std::endl;
// record result
FAUDES_TEST_DUMP("elesup",sup);
FAUDES_TEST_DUMP("elessup",ssup);
FAUDES_TEST_DUMP("validate",eql);
// validate
}
#define FAUDES_TEST_DIFF()
Definition: cfl_utils.h:504
#define FAUDES_TEST_DUMP(mes, dat)
Definition: cfl_utils.h:494
static void LogMuNu(bool on)
void DWrite(const Type *pContext=0) const
Definition: cfl_types.cpp:231
void Write(const Type *pContext=0) const
Definition: cfl_types.cpp:145
int main(int argc, char *argv[])
Definition: fts2ftx.cpp:59
IndexSet StateSet
Definition: cfl_indexset.h:273
NameSet EventSet
Definition: cfl_nameset.h:534
Idx Size(void) const
Definition: cfl_baseset.h:1782
vGenerator Generator
TcGenerator< AttributeVoid, AttributeVoid, AttributeCFlags, AttributeVoid > System
void StateMin(const Generator &rGen, Generator &rResGen)
void Trim(vGenerator &rGen)
void Automaton(Generator &rGen, const EventSet &rAlphabet)
bool LanguageEquality(const Generator &rGen1, const Generator &rGen2)
void Parallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
void InvProject(Generator &rGen, const EventSet &rProjectAlphabet)
void SupCon(const Generator &rPlantGen, const EventSet &rCAlph, const Generator &rSpecGen, Generator &rResGen)
Definition: syn_supcon.cpp:757
void ParallelLive(const GeneratorVector &rGenVec, Generator &rResGen)
bool SupClosed(const Generator &rK, Generator &rResult)

Definition in file syn_2_ctrlpfx.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 25 of file syn_2_ctrlpfx.cpp.

libFAUDES 2.33h --- 2025.06.18 --- c++ api documentaion by doxygen