pd_alg_cc.h

Go to the documentation of this file.
00001 /** @file pd_alg_cc.h  Top-Level functions*/
00002 
00003 
00004 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
00005 
00006    Copyright (C) 2013  Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
00007 
00008 */
00009 
00010 
00011 #ifndef FAUDES_PD_ALG_CC_H
00012 #define FAUDES_PD_ALG_CC_H
00013 
00014 #include "corefaudes.h"
00015 #include "pd_pdgenerator.h"
00016 #include "pd_alg_lrm.h"
00017 #include "pd_alg_lrp.h"
00018 #include "pd_alg_nb_sub_a.h"
00019 #include "pd_alg_nb_sub_b.h"
00020 #include "pd_lang_k.h"
00021 #include <sys/time.h>
00022 
00023 namespace faudes {
00024   
00025   /**
00026    * Get all states that are the starting state of a lambda reading transition
00027    * 
00028    * @param pd
00029    *    the generator
00030    * @return
00031    *    the states
00032    */
00033   StateSet Transient(const PushdownGenerator& pd);
00034   
00035   /**
00036    * Remove non-controllable ears from a generator. The initial state must not be an ear.
00037    * Times and Split must have been executed on the generator.
00038    * 
00039    * @param pd
00040    *    the pushdown generator with ears
00041    * @param s
00042    *    the system that was used in the intersection operation to generate the 
00043    * pushdown generator
00044    * @return
00045    *    pushdowngenerator without noncontrollable ears
00046    */
00047   PushdownGenerator Rnce(const PushdownGenerator& pd, const System& s);
00048   
00049   /**
00050    * synchronous product generator of a pushdown generator and a regular generator
00051    * 
00052    * @param reg
00053    *    the regualar generator
00054    * @param pd
00055    *    the pushdown generator
00056    * @return
00057    *    the synchronous product
00058    */
00059   PushdownGenerator Times(const System& reg, const PushdownGenerator& pd);
00060   
00061   /**
00062    * Adds the intersection of events of the first two generators to the 
00063    * result generator. The function considers observability and controllability,
00064    * so observability and controllability attributes will be kept.
00065    * 
00066    * @param s
00067    *    first generator
00068    * @param pd
00069    *    second generator
00070    * @param rPd
00071    *    result generator
00072    */
00073   void IntersectEvents(const System& s, const PushdownGenerator& pd, PushdownGenerator& rPd);
00074   
00075   /**
00076    * Splits the states of a pushdown generator into heads and ears. Each ear is
00077    * associated with a stack symbol.
00078    * 
00079    * Transitions will always be either from ear to head or from head to ear.
00080    * Transitions from ear to head will always pop the stack symbol associated
00081    * with the ear. Transitions from head to ear will always read lambda and 
00082    * pop and push the stack symbol associated with the ear.
00083    * 
00084    * @param pd
00085    *    pushdown generator to be split
00086    * @return
00087    *    the split pushdown generator
00088    */
00089   PushdownGenerator Split(const PushdownGenerator& pd);
00090   
00091   /**
00092    * Make a pushdown generator nonblocking. This will remodel the pushdown generator
00093    * and replace stack symbols with new ones.
00094    * 
00095    * @param pd
00096    *    pushdown generator to make nonblocking
00097    * @param res
00098    *    nonblocking pushdown generator
00099    * @param print
00100    *    temporary debug parameter
00101    */
00102   void PushdownNonblock(const PushdownGenerator& pd, PushdownGenerator& res, bool print = false);
00103   
00104   /**
00105    * Sets controllability and observability flags for a pushdown generator's events to 
00106    * the event flags of another pushdown generator
00107    * 
00108    * @param correctPd
00109    *    pushdown generator with correct flags
00110    * @param pd
00111    *    this generator's event flags will be set to the correctPd's event flags
00112    */
00113   void CorrectEvents(const PushdownGenerator& correctPd, PushdownGenerator& pd);
00114   
00115   /**
00116    * Test a state for reachability.
00117    * 
00118    * @param pd
00119    *    the pushdown generator
00120    * @param state
00121    *    the state to test for reachability
00122    * @return
00123    *    true if the state is reachable, else false
00124    */
00125   bool Ts(const PushdownGenerator& pd, Idx state);
00126   
00127   /**
00128    * Test a transition for reachability.
00129    * 
00130    * @param pd
00131    *    the pushdown generator
00132    * @param trans
00133    *    the transition to test for reachability
00134    * @param pop
00135    *    the pop of the transitions to test for reachability
00136    * @param push
00137    *    the push of the transitions to test for reachability
00138    * @return
00139    *    true if the transition is reachable, else false
00140    */
00141   bool Te(const PushdownGenerator& pd, const Transition& trans, const std::vector<Idx>& pop, const std::vector<Idx>& push);
00142   
00143   
00144   bool Ruls1(Idx state, const PushdownGenerator& pd);
00145   
00146   /**
00147    * Remove useless states of a pushdown generator.
00148    * 
00149    * @param pd
00150    *    the generator, which is required to have passed Split() before
00151    * @return
00152    *    generator that only has useable states.
00153    */
00154   PushdownGenerator Ruls(const PushdownGenerator& pd);
00155   
00156 
00157   
00158   /**
00159    * Construct the accessible part of a pushdown generator
00160    * 
00161    * @param pd
00162    *    pushdown generator to make accessible
00163    * @param res
00164    *    accessible pushdown generator
00165    */
00166   void PushdownAccessible(const PushdownGenerator& pd, PushdownGenerator& res);
00167   
00168   /**
00169    * Single execution of the loop to construct a minimal restrictive sound controller.
00170    * Alphabets of specification and plant are expected to be equal.
00171    * 
00172    * @param contr
00173    *    the controller candidate
00174    * @param plant
00175    *    the plant
00176    * @return
00177    *    product of controller candidate and plant
00178    */
00179   PushdownGenerator Ccs(const PushdownGenerator& contr, const System& plant);
00180   
00181   /**
00182    * Looped exectuion of to construct a minimal restrictive sound controller. Alphabets
00183    * of specification and plant are expected to be equal.
00184    * 
00185    * @param contr
00186    *    the controller candidate
00187    * @param plant
00188    *    the plant
00189    * @param iteration
00190    *    number of iterations of ccl
00191    * @return
00192    *    minimal restrictive controller
00193    */
00194   PushdownGenerator Ccl(const PushdownGenerator& contr, const System& plant, Idx iteration = 0);
00195   
00196   /**
00197    * Construct a minimal restrictive sound controller. Alphabets of specification and
00198    * plant are expected to be equal.
00199    * 
00200    * @param spec
00201    *    the specification
00202    * @param plant
00203    *    the plant
00204    * @param res
00205    *    the result
00206    * @return
00207    */
00208   void PushdownConstructController(const PushdownGenerator& spec, const System& plant, PushdownGenerator& res);
00209   
00210   /**
00211    * from http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html
00212    * Calculates time difference x - y. For debugging and time measurement.
00213    * 
00214    * @param result
00215    *    the time difference is stored here
00216    * @param x
00217    *    the time x
00218    * @param y
00219    *    the time y
00220    * @return
00221    *    1 if x - y is negative, else 0
00222    */
00223   int timeval_subtract (timeval* result, timeval* x, timeval* y);
00224 
00225 
00226 
00227 
00228 } // namespace faudes
00229 
00230 #endif

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen