mirror of
http://172.16.200.102/MOISE/Timed-Altarica-To-Fiacre-Translator.git
synced 2026-04-14 14:27:40 +02:00
Initial commit.
This commit is contained in:
70
src/console/CMakeLists.txt
Normal file
70
src/console/CMakeLists.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
# This file is part of EPOCH.
|
||||
# File: CMakeLists.txt
|
||||
# Author: Florent Teichteil-Königsbuch
|
||||
# Contact: florent.teichteil@onera.fr
|
||||
#
|
||||
# EPOCH is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# EPOCH is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with EPOCH. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
FIND_PACKAGE(LibXML++ REQUIRED)
|
||||
set(LIBS ${LIBS} ${LibXML++_LIBRARIES})
|
||||
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LibXML++_INCLUDE_DIRS} ${UMFPACK_INCLUDES})
|
||||
|
||||
SET (EPOCH_CONSOLE_LIBRARIES)
|
||||
LIST (APPEND EPOCH_CONSOLE_LIBRARIES
|
||||
epoch-altarica
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${LAPACK_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
SET (IAEPOCH_LIBRARIES)
|
||||
LIST (APPEND IAEPOCH_LIBRARIES
|
||||
epoch-altarica
|
||||
# epoch-solvers
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${UMFPACK_LIBRARIES})
|
||||
|
||||
ADD_EXECUTABLE (epochnogui
|
||||
epochmain.cc
|
||||
ParsingDriverConsoleReporter.cc
|
||||
epochconsolealtarica.cc
|
||||
)
|
||||
TARGET_LINK_LIBRARIES (epochnogui ${EPOCH_CONSOLE_LIBRARIES})
|
||||
|
||||
ADD_EXECUTABLE (iaepoch
|
||||
iaepochmain.cc
|
||||
ParsingDriverConsoleReporter.cc)
|
||||
TARGET_LINK_LIBRARIES (iaepoch ${IAEPOCH_LIBRARIES} # epoch-prism
|
||||
${Boost_TIMER_LIBRARY}
|
||||
${Boost_CHRONO_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY})
|
||||
|
||||
ExternalProject_Get_Property(buddy-2.4 install_dir)
|
||||
INCLUDE_DIRECTORIES(${install_dir}/include)
|
||||
|
||||
#SET (SYMEPOCH_LIBRARIES)
|
||||
#LIST (APPEND SYMEPOCH_LIBRARIES
|
||||
# epoch-altarica
|
||||
# epoch-symbolic
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
||||
|
||||
#ADD_EXECUTABLE (symepoch
|
||||
# symepochmain.cc
|
||||
# ParsingDriverConsoleReporter.cc)
|
||||
#TARGET_LINK_LIBRARIES (symepoch ${SYMEPOCH_LIBRARIES})
|
||||
42
src/console/ParsingDriverConsoleReporter.cc
Normal file
42
src/console/ParsingDriverConsoleReporter.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2016 ONERA.
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include "console/ParsingDriverConsoleReporter.hh"
|
||||
#include <iostream>
|
||||
|
||||
namespace epoch {
|
||||
namespace console {
|
||||
|
||||
ParsingDriverConsoleReporter::ParsingDriverConsoleReporter() {
|
||||
}
|
||||
|
||||
void ParsingDriverConsoleReporter::Append(const std::string& msg) {
|
||||
std::cerr << msg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
src/console/ParsingDriverConsoleReporter.hh
Normal file
42
src/console/ParsingDriverConsoleReporter.hh
Normal file
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2016 ONERA.
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PARSING_DRIVER_CONSOLE_REPORTER_HH
|
||||
#define PARSING_DRIVER_CONSOLE_REPORTER_HH
|
||||
|
||||
#include "grammars/parsingdriverbase.hh"
|
||||
|
||||
namespace epoch {
|
||||
namespace console {
|
||||
|
||||
class ParsingDriverConsoleReporter : public epoch::ParsingDriverReporter {
|
||||
public :
|
||||
ParsingDriverConsoleReporter();
|
||||
virtual void Append(const std::string& msg);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
200
src/console/bddepochmain.cc
Normal file
200
src/console/bddepochmain.cc
Normal file
@@ -0,0 +1,200 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab) et de
|
||||
* l'IRT AESE (IRT Saint Exupéry).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab) and of
|
||||
* the IRT AESE (IRT Saint Exupéry).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Xavier Pucel (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "epochconsolealtarica.hh"
|
||||
|
||||
#include "grammars/altarica/AltaricaGenerator.hh"
|
||||
#include "grammars/altarica/Assignment.hh"
|
||||
#include "grammars/altarica/Event.hh"
|
||||
#include "grammars/altarica/MemberAccess.hh"
|
||||
#include "grammars/altarica/Synchronisation.hh"
|
||||
#include "grammars/altarica/Transition.hh"
|
||||
#include "grammars/altarica/Variable.hh"
|
||||
|
||||
//using namespace epoch;
|
||||
|
||||
int main(int ac, char* av[]) {
|
||||
unsigned int verbosity; // verbosity level
|
||||
std::string modelFile;
|
||||
std::string initFile;
|
||||
bool ds;
|
||||
bool printFlow;
|
||||
bool printNULL;
|
||||
bool printDomain;
|
||||
|
||||
try {
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help", "produce help message")
|
||||
("ds",
|
||||
boost::program_options::value<bool>(&ds)->default_value(false),
|
||||
"print semantic debug messages for discrete models")
|
||||
("file",
|
||||
boost::program_options::value<std::string>(&modelFile)->default_value(""),
|
||||
"model file (either .alt (altartica) or [.prism|.nm|.pm|.sm] (prism)")
|
||||
("init",
|
||||
boost::program_options::value<std::string>(&initFile)->default_value(""),
|
||||
"init file")
|
||||
("pf",
|
||||
boost::program_options::value<bool>(&printFlow)->default_value(false),
|
||||
"print flow vars")
|
||||
("pn",
|
||||
boost::program_options::value<bool>(&printNULL)->default_value(false),
|
||||
"print null values")
|
||||
("pd",
|
||||
boost::program_options::value<bool>(&printDomain)->default_value(false),
|
||||
"print var domains")
|
||||
;
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("file", 1);
|
||||
|
||||
|
||||
namespace options_style_ns = boost::program_options::command_line_style;
|
||||
int options_style = options_style_ns::allow_short
|
||||
| options_style_ns::short_allow_adjacent
|
||||
| options_style_ns::short_allow_next
|
||||
| options_style_ns::allow_long
|
||||
| options_style_ns::long_allow_adjacent
|
||||
| options_style_ns::long_allow_next
|
||||
| options_style_ns::allow_sticky
|
||||
| options_style_ns::allow_dash_for_short;
|
||||
boost::program_options::variables_map vm;
|
||||
// boost::program_options::store(
|
||||
// boost::program_options::parse_command_line(ac, av, desc, options_style),
|
||||
// vm);
|
||||
boost::program_options::store
|
||||
(boost::program_options::command_line_parser(ac,av).options(desc).
|
||||
positional(p).style(options_style).run(),
|
||||
vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
std::cout << desc << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
epoch::console::ParsingDriverConsoleReporter pdr;
|
||||
epoch::altarica::AltaricaGenerator gen(modelFile, pdr);
|
||||
gen.amodel_->setDebugSemantics(ds);
|
||||
|
||||
// if (initFile.compare("") != 0)
|
||||
// gen.amodel_->setInitInfo(initFile);
|
||||
|
||||
if (ds)
|
||||
{
|
||||
std::cout << std::endl << "MODEL STATS:" << std::endl;
|
||||
|
||||
std::cout << "number of state vars: "
|
||||
<< gen.amodel_->getNStateVars()
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "number of _different_ flow vars: "
|
||||
<< gen.amodel_->getNFlowVars()
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "number of atomic events: "
|
||||
<< gen.amodel_->getNEvents()
|
||||
<< std::endl
|
||||
<< std::endl;
|
||||
|
||||
std::cout << std::endl << "FLOW VARS" << std::endl;
|
||||
for(auto &v : gen.amodel_->getFlowVars()) {
|
||||
std::cout << v->getMA()->toString()
|
||||
<< " : "
|
||||
<< v->getDomain()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl << "STATE VARS" << std::endl;
|
||||
for(auto &v : gen.amodel_->getFlowVars()) {
|
||||
std::cout << v->getMA()->toString()
|
||||
<< " : "
|
||||
<< v->getDomain()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl << "ATOMIC EVTS" << std::endl;
|
||||
for(auto &e : gen.amodel_->getAtomicEvents()) {
|
||||
std::cout << e->getMA()->toString()
|
||||
<< " : "
|
||||
<< std::endl;
|
||||
if(e->getTrans()->size() > 0)
|
||||
for(auto &t : *e->getTrans()) {
|
||||
std::cout << " pre : "
|
||||
<< t->getPrecond()->toString()
|
||||
<< std::endl;
|
||||
if(t->getAssigns()->size() > 0) {
|
||||
std::cout << " post: ";
|
||||
for(auto &a : *t->getAssigns()) {
|
||||
std::cout << " "
|
||||
<< a->getVar()->getMA()->toString()
|
||||
<< a->getMA()->toString()
|
||||
<< " := "
|
||||
<< a->getExpr()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << "SYNCS" << std::endl;
|
||||
for(auto &s: gen.amodel_->getSyncs()) {
|
||||
std::cout << s->toString();
|
||||
if(s->getMA() != NULL)
|
||||
std::cout << s->getMA()->toString() << std::endl;
|
||||
if(s->getMandatoryEvents()->size() > 0) {
|
||||
std::cout << " Mandatory events:" << std::endl;
|
||||
for(auto &e : *s->getMandatoryEvents())
|
||||
std::cout << " " << e->getMA()->toString() << std::endl;
|
||||
}
|
||||
if(s->getOptionalEvents()->size() > 0) {
|
||||
std::cout << " Optional events:" << std::endl;
|
||||
for(auto &e : *s->getOptionalEvents())
|
||||
std::cout << " " << e->getMA()->toString() << std::endl;
|
||||
}
|
||||
std::cout << " Constraint type: " << s->getConstraintType() << std::endl;
|
||||
std::cout << " Numerical constant: "
|
||||
<< s->getNumericalConstant()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (const boost::program_options::error& error) {
|
||||
std::cerr << error.what() << std::endl;
|
||||
return -1;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << boost::diagnostic_information(error) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
316
src/console/epochconsolealtarica.cc
Normal file
316
src/console/epochconsolealtarica.cc
Normal file
@@ -0,0 +1,316 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2016 ONERA.
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Florent Teichteil-Königsbuch (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
//#include "algorithms/EmptyStateVisitor.hh"
|
||||
//#include "algorithms/DotStateVisitor.hh"
|
||||
#include "grammars/altarica/FiacreTranslator.hh"
|
||||
//#include "solvers/epochsolver.hh"
|
||||
//#include "solvers/altaricaLogic.hh"
|
||||
#include "console/ParsingDriverConsoleReporter.hh"
|
||||
|
||||
#include "grammars/altarica/Assignment.hh"
|
||||
#include "grammars/altarica/AltaricaGenerator.hh"
|
||||
#include "grammars/altarica/Event.hh"
|
||||
#include "grammars/altarica/MemberAccess.hh"
|
||||
#include "grammars/altarica/Synchronisation.hh"
|
||||
#include "grammars/altarica/Transition.hh"
|
||||
#include "grammars/altarica/Variable.hh"
|
||||
|
||||
#include "grammars/altarica/Event.hh"
|
||||
#include "grammars/altarica/Assertion.hh"
|
||||
|
||||
|
||||
namespace epoch {
|
||||
namespace console {
|
||||
void printStates(int ps, int maxDepth, epoch::altarica::AltaricaState* s, epoch::altarica::AltaricaModel* m) {
|
||||
|
||||
std::cerr << "\ndepth = "<< maxDepth-ps << std::endl;
|
||||
std::cerr << s->toString(true, true, true, true);
|
||||
if (ps == 0) {
|
||||
delete s;
|
||||
std::cerr << "\n!!!!!!!!!!!! GOING UP the tree\n"<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<epoch::altarica::MetaEvent*> * mev = m->getEnabledMetaEventsAll(s);
|
||||
std::cerr<<"\n # metaEvents: "<< mev->size() << std::endl;
|
||||
for (int i=0; i<mev->size(); ++i) {
|
||||
std::cerr << " MEV " << i << ": " << (*mev)[i]->toString() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
for (int i=0; i<mev->size(); ++i) {
|
||||
std::cerr << "\ndoing MEV " << i << ": " << (*mev)[i]->toString() << std::endl;
|
||||
epoch::altarica::AltaricaState *s2 = m->getNextState(s,(*mev)[i]);
|
||||
m->evaluateFlowVars(s2);
|
||||
printStates(ps-1, maxDepth, s2, m);
|
||||
}
|
||||
|
||||
// std::vector<epoch::altarica::Event*> ev = m->getAtomicEvents();
|
||||
// std::cerr<<"\n # Events: "<< ev.size() << std::endl;
|
||||
// for (int i=0; i<ev.size(); ++i) {
|
||||
// std::cerr << " EV " << i << ": " << ev[i]->toString() << std::endl;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string print_pre (const epoch::altarica::AltaricaModel *amodel_, const std::vector<epoch::altarica::Event*> *ev, int n, std::ostringstream * sout) {
|
||||
|
||||
std::ostringstream sret;
|
||||
std::string s ;
|
||||
if (n < 0)
|
||||
return sout->str() + "\n";
|
||||
|
||||
// for (int i = ev->size(); i > 0; --i) {
|
||||
|
||||
// ss << "\tEvent" << i-1;
|
||||
unsigned j = 0;
|
||||
for (auto &ti : *(ev->at(n)->getTrans()) ) {
|
||||
std::ostringstream ss;
|
||||
ss << sout->str() << ti->getPrecond()->toString( ti->getNode(), amodel_);
|
||||
if ( n != 0 )
|
||||
ss << " and ";
|
||||
//ss << sout->str() << "\tE" << n << "T" << j++;
|
||||
sret << print_pre(amodel_, ev, n-1, &ss);
|
||||
|
||||
|
||||
// const std::vector<epoch::altarica::Assignment*>* effects = ti->getAssigns();
|
||||
// if(effects->size() > 0) {
|
||||
// for(auto &a : *effects) {
|
||||
// std::cout << "\tpost : "
|
||||
// << a->getVar()->toFiacre()
|
||||
// //<< a->getMA()->toString()
|
||||
// << " := "
|
||||
// << a->getExpr()->toString( a->getNode() )
|
||||
// << ";" << std::endl;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
return sret.str();
|
||||
}
|
||||
|
||||
|
||||
bool DoAltarica(const std::string& modelFile, const std::string& initFile, const std::string& var1, const std::string& value1, const std::string& var2, const std::string& value2,bool ds, int ps, bool invert_comp1, bool invert_comp2,
|
||||
int ac, char* av[], int algo, int hess, int blas, double threshold, unsigned int dtimebound, double ctimebound, bool printfunction, const std::string& printGraph) {
|
||||
epoch::console::ParsingDriverConsoleReporter pdr;
|
||||
epoch::altarica::AltaricaGenerator gen(modelFile, pdr);
|
||||
gen.amodel_->setDebugSemantics(ds);
|
||||
|
||||
// if (initFile.compare("") != 0)
|
||||
if (initFile.length() >= 4 &&
|
||||
0 == initFile.compare(initFile.length() - 4, 4, ".xml"))
|
||||
gen.amodel_->setInitInfoXML(initFile);
|
||||
else if (initFile.length() >= 5 &&
|
||||
0 == initFile.compare(initFile.length() - 4, 4, ".json"))
|
||||
gen.amodel_->setInitInfoJSON(initFile);
|
||||
|
||||
epoch::altarica::AltaricaState * i = gen.amodel_->initialState();
|
||||
gen.amodel_->evaluateFlowVars(i);
|
||||
// std::cerr << i->toString(true,true,true,true);
|
||||
std::cerr << std::endl << "MODEL STATS:" << std::endl;
|
||||
std::cerr << "number of state vars: " << gen.amodel_->getNStateVars() << std::endl;
|
||||
std::cerr << "number of _different_ flow vars: " << gen.amodel_->getNFlowVars() << std::endl;
|
||||
std::cerr << "number of atomic events: " << gen.amodel_->getNEvents() << std::endl;
|
||||
|
||||
|
||||
//// Debug printing start ////
|
||||
|
||||
if (gen.amodel_->getDebugSemantics())
|
||||
{
|
||||
std::cout << std::endl << "FLOW VARS" << std::endl;
|
||||
|
||||
for(auto &v : gen.amodel_->getFlowVars()) {
|
||||
|
||||
std::cout << v->getFullName() <<
|
||||
" : " <<
|
||||
v->getDomain()->toString() <<
|
||||
std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl << "STATE VARS" << std::endl;
|
||||
for(auto &v : gen.amodel_->getStateVars()) {
|
||||
std::cout << v->getFullName()
|
||||
<< " : "
|
||||
<< v->getDomain()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl << "ATOMIC EVTS" << std::endl;
|
||||
for(auto &e : gen.amodel_->getAtomicEvents()) {
|
||||
std::cout << e->getMA()->toString()
|
||||
<< " : "
|
||||
<< std::endl;
|
||||
if(e->getTrans()->size() > 0)
|
||||
for(auto &t : *e->getTrans()) {
|
||||
std::cout << " pre : "
|
||||
<< t->getPrecond()->toString()
|
||||
<< std::endl;
|
||||
if(t->getAssigns()->size() > 0) {
|
||||
std::cout << " post : ";
|
||||
for(auto &a : *t->getAssigns()) {
|
||||
std::cout << " "
|
||||
// << a->getVar()->toFiacre() //getVar()->getMA()->toString()
|
||||
<< a->getMA()->toString()
|
||||
<< " := "
|
||||
<< a->getExpr()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get Syncs //
|
||||
unsigned nev=0, ne = 0;
|
||||
for(auto &sy :gen.amodel_->getSyncs())
|
||||
std::cout << sy->toString()<< std::endl;
|
||||
|
||||
std::cout << std::endl << "SYNCS" << std::endl;
|
||||
// for(auto &sy :gen.amodel_->getSyncs())
|
||||
// std::cout << sy->toString()<< std::endl;
|
||||
unsigned n=0;
|
||||
for(auto &sy :gen.amodel_->getMetaEvents()) {
|
||||
std::cout << "Meta event" << n++ << std::endl;
|
||||
if (sy->getEvents()->size() != 0) {
|
||||
for (std::vector<epoch::altarica::Event*>::iterator i = sy->getEvents()->begin();
|
||||
i!=sy->getEvents()->end(); ++i) {
|
||||
ne = 0;
|
||||
for (auto &t : *(*i)->getTrans()) {
|
||||
std::cout << nev << "." << ne++ << ". pre : " << t->getPrecond()->toString( t->getNode(), gen.amodel_) << std::endl;
|
||||
|
||||
if(t->getAssigns()->size() > 0) {
|
||||
for(auto &a : *(t->getAssigns())) {
|
||||
std::cout << "\tpost : "
|
||||
<< a->getVar()->toFiacre()
|
||||
//<< a->getMA()->toString()
|
||||
<< " := "
|
||||
<< a->getExpr()->toString( a->getNode(), gen.amodel_ )
|
||||
<< ";" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
++nev;
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cout << " NO EVENT";
|
||||
}
|
||||
|
||||
////////
|
||||
std::cout << std::endl << "SYNCS" << std::endl;
|
||||
|
||||
nev=0; ne = 0;
|
||||
for(auto &sy :gen.amodel_->getMetaEvents()) {
|
||||
std::cout << std::endl << "Meta event" << nev++ << std::endl;
|
||||
if (sy->getEvents()->size() != 0) {
|
||||
|
||||
std::ostringstream ss("init ");
|
||||
|
||||
int num = sy->getEvents()->size()-1;
|
||||
|
||||
std::cout << print_pre(gen.amodel_, sy->getEvents() , num, &ss );
|
||||
|
||||
}
|
||||
else
|
||||
std::cout << " NO EVENT";
|
||||
}
|
||||
std::cout << std::endl << "ATOMIC DIRAC EVTS" << std::endl;
|
||||
for(auto &e : gen.amodel_->getAtomicDiracEvents()) {
|
||||
std::cout << e->getMA()->toString()
|
||||
<< " : "
|
||||
<< std::endl;
|
||||
if(e->getTrans()->size() > 0)
|
||||
for(auto &t : *e->getTrans()) {
|
||||
std::cout << " pre : "
|
||||
<< t->getPrecond()->toString()
|
||||
<< std::endl;
|
||||
if(t->getAssigns()->size() > 0) {
|
||||
std::cout << " post: ";
|
||||
for(auto &a : *t->getAssigns()) {
|
||||
std::cout << " "
|
||||
// << a->getVar()->toFiacre() //getVar()->getMA()->toString()
|
||||
<< a->getMA()->toString()
|
||||
<< " := "
|
||||
<< a->getExpr()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << "ASSERTIONS" << std::endl;
|
||||
|
||||
for(auto &e : gen.amodel_->getAsserts()) {
|
||||
size_t et = (size_t)(e);
|
||||
std::cout << et << " "<< e->getExpr()->toString()<< std::endl;
|
||||
}
|
||||
}
|
||||
//////// Debug printing end ///////
|
||||
|
||||
|
||||
if (ps >= 0) {
|
||||
// Makes a FIACRE model
|
||||
std::cerr << "\n!!!!!!!!!!!! Printing FIACRE model\n\n"<< std::endl;
|
||||
|
||||
epoch::altarica::FiacreTranslator f(gen.amodel_);
|
||||
f.printFiacre();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
// A partir d'ici : algorithme
|
||||
//const epoch::altarica::Node& mainNode = *(gen.amodel_->findNodeByName("main"));
|
||||
|
||||
|
||||
|
||||
// Formule f1 : tout est ok
|
||||
/* epoch::solvers::AltaricaLogic* f1;
|
||||
|
||||
|
||||
if (strcmp(var1.c_str(), "") != 0)
|
||||
f1 = new epoch::solvers::AltaricaLogicF2(gen.amodel_,var1,value1, invert_comp1);
|
||||
else
|
||||
f1 = new epoch::solvers::AltaricaLogicF1();
|
||||
|
||||
epoch::solvers::AltaricaLogicF2 f2(gen.amodel_,var1,value1, invert_comp1);
|
||||
epoch::altarica::AltaricaGenerator::State is(i);
|
||||
|
||||
if (printGraph.empty()) {
|
||||
return epoch::solvers::MySolver<epoch::solvers::AltaricaLogic, epoch::altarica::AltaricaGenerator, epoch::algorithm::EmptyStateVisitor>::solve(ac, av,
|
||||
algo, hess, blas, threshold, dtimebound, ctimebound,
|
||||
printfunction, epoch::algorithm::EmptyStateVisitor(),
|
||||
gen, is, *f1, f2);
|
||||
} else {
|
||||
return epoch::solvers::MySolver<epoch::solvers::AltaricaLogic, epoch::altarica::AltaricaGenerator, epoch::algorithm::DotStateVisitor>::solve(ac, av,
|
||||
algo, hess, blas, threshold, dtimebound, ctimebound,
|
||||
printfunction, epoch::algorithm::DotStateVisitor(printGraph),
|
||||
gen, is, *f1, f2);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
106
src/console/epochconsolealtarica.hh
Normal file
106
src/console/epochconsolealtarica.hh
Normal file
@@ -0,0 +1,106 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2016 ONERA.
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Florent Teichteil-Königsbuch (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef EPOCH_CONSOLE_ALTARICA_HH
|
||||
#define EPOCH_CONSOLE_ALTARICA_HH
|
||||
|
||||
//#include "grammars/altarica/altarica_driver.hh"
|
||||
//#include "grammars/altarica/AltaricaState.hh"
|
||||
#include "grammars/altarica/AltaricaGenerator.hh"
|
||||
#include "grammars/altarica/expressions/Expressions.hh"
|
||||
|
||||
|
||||
#include "console/ParsingDriverConsoleReporter.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace epoch {
|
||||
namespace console {
|
||||
typedef std::auto_ptr<epoch::altarica::Expression> MyExpressionPtr;
|
||||
|
||||
/*struct AltaricaLogic {
|
||||
const epoch::altarica::Node& m_rMainNode;
|
||||
MyExpressionPtr m_pExpression;
|
||||
std::auto_ptr<epoch::altarica::OpenValue> m_pConstantTrue;
|
||||
|
||||
AltaricaLogic(const epoch::altarica::Node& n, MyExpressionPtr e);
|
||||
|
||||
bool holds(const epoch::altarica::AltaricaGenerator::State& s) const;
|
||||
};
|
||||
|
||||
AltaricaLogic::AltaricaLogic(const epoch::altarica::Node& n, MyExpressionPtr e)
|
||||
: m_rMainNode(n), m_pExpression(e) {
|
||||
m_pConstantTrue = std::auto_ptr<epoch::altarica::OpenValue>(new epoch::altarica::OpenBool(true, false));
|
||||
}
|
||||
|
||||
bool AltaricaLogic::holds(const epoch::altarica::AltaricaGenerator::State& s) const {
|
||||
epoch::altarica::OpenValue* v = m_pExpression->evaluate(s.as_, &m_rMainNode);
|
||||
bool r = v->equals(m_pConstantTrue.get());
|
||||
delete v;
|
||||
return r;
|
||||
}*/
|
||||
|
||||
// template <class T>
|
||||
// bool from_string(T& t,
|
||||
// const std::string& s,
|
||||
// std::ios_base& (*f)(std::ios_base&))
|
||||
// {
|
||||
// std::istringstream iss(s);
|
||||
// return !(iss >> f >> t).fail();
|
||||
// }
|
||||
|
||||
void printStates(int ps, int maxDepth, epoch::altarica::AltaricaState* s, epoch::altarica::AltaricaModel* m);
|
||||
|
||||
// struct AltaricaLogic {
|
||||
// virtual ~AltaricaLogic() {}
|
||||
// virtual bool holds(const epoch::altarica::AltaricaGenerator::State& s) const =0;
|
||||
// };
|
||||
|
||||
// struct AltaricaLogicF1 : public AltaricaLogic {
|
||||
// virtual ~AltaricaLogicF1() {}
|
||||
// inline virtual bool holds(const epoch::altarica::AltaricaGenerator::State& s) const {return true;}
|
||||
// };
|
||||
|
||||
// struct AltaricaLogicF2 : public AltaricaLogic {
|
||||
// epoch::altarica::AltaricaModel* m_pModel;
|
||||
// std::auto_ptr<epoch::altarica::Value> m_pConstant;
|
||||
// std::string varName;
|
||||
// bool invert;
|
||||
|
||||
// virtual ~AltaricaLogicF2() {}
|
||||
|
||||
// AltaricaLogicF2(epoch::altarica::AltaricaModel* model, std::string vn, std::string value, bool invert_comp);
|
||||
|
||||
// virtual bool holds(const epoch::altarica::AltaricaGenerator::State& s) const;
|
||||
// };
|
||||
|
||||
bool DoAltarica(const std::string& modelFile, const std::string& initFile, const std::string& var1, const std::string& value1, const std::string& var2, const std::string& value2, bool ds, int ps, bool invert_comp1, bool invert_comp2,
|
||||
int ac, char* av[], int algo, int hess, int blas, double threshold, unsigned int dtimebound, double ctimebound, bool printfunction, const std::string& printGraph);
|
||||
} // namespace console
|
||||
} // namespace epoch
|
||||
|
||||
#endif // EPOCH_CONSOLE_ALTARICA_HH
|
||||
146
src/console/epochmain.cc
Normal file
146
src/console/epochmain.cc
Normal file
@@ -0,0 +1,146 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2016 ONERA.
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Florent Teichteil-Königsbuch (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
|
||||
#include "epochconsolealtarica.hh"
|
||||
|
||||
//using namespace epoch;
|
||||
|
||||
int main (int ac, char* av[])
|
||||
{
|
||||
unsigned int verbosity; // verbosity level
|
||||
std::string modelFile;
|
||||
std::string initFile;
|
||||
double threshold;
|
||||
unsigned int dtimebound;
|
||||
double ctimebound;
|
||||
std::string var1, var2 ;
|
||||
std::string value1, value2;
|
||||
std::string f1;
|
||||
std::string f2;
|
||||
bool invert_comp1 = false;
|
||||
bool invert_comp2 = false;
|
||||
int algo, hess, blas;
|
||||
bool ds;
|
||||
int ps;
|
||||
bool printfunction = false;
|
||||
std::string printGraph;
|
||||
try {
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help", "produce help message")
|
||||
("ds", boost::program_options::value<bool>(&ds)->default_value(false), "print semantic debug messages for discrete models")
|
||||
("ps", boost::program_options::value<int>(&ps)->default_value(-1), "print states up to specified depth (0 for initial state only )")
|
||||
|
||||
("file", boost::program_options::value<std::string>(&modelFile)->default_value(""), "model file (either .alt (altartica) or [.prism|.nm|.pm|.sm] (prism)")
|
||||
("init", boost::program_options::value<std::string>(&initFile)->default_value(""), "init file")
|
||||
("algo", boost::program_options::value<int>(&algo)->default_value(5), "algo:\n -1 => all\n 0 => exact infinite\n 1 => iterative infinite\n 2 => bounded exact infinite\n 3 => bounded iterative infinite\n 4 => finite\n 5 => bounded finite\n 6 => coutinuous exact\n 7 => continuous bounded\nINFINITE HORIZON + EXACT COMPUTATION + MARKOV CHAIN WITH INFINITE NUMBER OF STATES => STACK OVERFLOW")
|
||||
("hess", boost::program_options::value<int>(&hess)->default_value(0), "hess:\n 0 => triangular Hessenberg matrices\n 1 => banded Hessenberg matrices\n 2 => dense Hessenberg matrices")
|
||||
("blas", boost::program_options::value<int>(&blas)->default_value(0), "blas:\n 0 => Ublas Standard\n 1 => Ublas BLAS bindings (use system's BLAS implementation)")
|
||||
("verbosity", boost::program_options::value<unsigned int>(&verbosity)->default_value(0), "verbosity level")
|
||||
("thres", boost::program_options::value<double>(&threshold)->default_value(0.001), "threshold for P(f1 U f2) >= t")
|
||||
("dhor", boost::program_options::value<unsigned int>(&dtimebound)->default_value(10), "discrete horizon time")
|
||||
("chor", boost::program_options::value<double>(&ctimebound)->default_value(100.0), "continuous horizon time")
|
||||
("var1", boost::program_options::value<std::string>(&var1)->default_value(""), "var1 to check (left side of until)")
|
||||
("value1", boost::program_options::value<std::string>(&value1)->default_value("false"),"value for variable1 (false -> var1 = false)")
|
||||
("var2", boost::program_options::value<std::string>(&var1)->default_value(""), "var2 to check ( right side of until)")
|
||||
("value2", boost::program_options::value<std::string>(&value1)->default_value("false"),"value for variable2 (false -> var2 = false)")
|
||||
("f1", boost::program_options::value<std::string>(&f1)->default_value("true"), "left-hand side formula of strong until operator")
|
||||
("f2", boost::program_options::value<std::string>(&f2)->default_value("true"), "right-hand side formula of strong until operator")
|
||||
("neg1", " replaces = with != for left side of until")
|
||||
("neg2", "replaces = with != for right side of until")
|
||||
("pfunc", "print continuous probability function")
|
||||
("pg", "print the search graph in a dot file")
|
||||
;
|
||||
|
||||
namespace options_style_ns = boost::program_options::command_line_style;
|
||||
int options_style = options_style_ns::allow_short | options_style_ns::short_allow_adjacent | options_style_ns::short_allow_next
|
||||
| options_style_ns::allow_long | options_style_ns::long_allow_adjacent | options_style_ns::long_allow_next
|
||||
| options_style_ns::allow_sticky | options_style_ns::allow_dash_for_short;
|
||||
boost::program_options::variables_map vm;
|
||||
boost::program_options::store(boost::program_options::parse_command_line(ac, av, desc, options_style), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
std::cout << desc << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (vm.count("neg1")) {
|
||||
invert_comp1 = true;
|
||||
}
|
||||
|
||||
if (vm.count("neg2")) {
|
||||
invert_comp2 = true;
|
||||
}
|
||||
|
||||
if (vm.count("pfunc")) {
|
||||
printfunction = true;
|
||||
}
|
||||
|
||||
|
||||
// if (!var2.empty()) {
|
||||
// if (var1.empty())
|
||||
// f1 = "true";
|
||||
// else
|
||||
// f1 = var1 + ((!invert_comp1)?(" = "):(" != ")) + value1;
|
||||
// f2 = var2 + ((!invert_comp2)?(" = "):(" != ")) + value2;
|
||||
// std::cout << "f2: (" << f2 << ")" << std::endl;
|
||||
// } else {
|
||||
// std::cout << "f1: " << f1 << std::endl;
|
||||
// std::cout << "f2: " << f2 << std::endl;
|
||||
// }
|
||||
// std::cout << "for finite time algos, dtimebound = " << dtimebound<<std::endl;
|
||||
// std::cout << "threshold for property ="<<threshold<<std::endl;
|
||||
|
||||
// Get file path
|
||||
boost::filesystem::path filepath(modelFile);
|
||||
|
||||
if (vm.count("pg")) {
|
||||
printGraph = filepath.stem().generic_string() + "_" + boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time());
|
||||
}
|
||||
|
||||
if (!filepath.has_extension()) {
|
||||
std::cerr << "File '" << filepath << "' has no extension!" << std::endl;
|
||||
return -1;
|
||||
} else if (filepath.extension().generic_string() == ".alt") { // altarica file
|
||||
return epoch::console::DoAltarica(modelFile, initFile, var1, value1, var2, value2, ds, ps, invert_comp1, invert_comp2,
|
||||
ac, av, algo, hess, blas, threshold, dtimebound, ctimebound, printfunction, printGraph);
|
||||
}
|
||||
}
|
||||
catch (const boost::program_options::error& error) {
|
||||
std::cerr << error.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
catch (const std::exception& error) {
|
||||
std::cerr << boost::diagnostic_information(error) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
233
src/console/iaepochmain.cc
Normal file
233
src/console/iaepochmain.cc
Normal file
@@ -0,0 +1,233 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab) et de
|
||||
* l'IRT AESE (IRT Saint Exupéry).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab) and of
|
||||
* the IRT AESE (IRT Saint Exupéry).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Florent Teichteil-Königsbuch (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
|
||||
#include "grammars/altarica/altarica_lexer.h"
|
||||
#include "epochconsolealtarica.hh"
|
||||
//#include "epochconsoleprism.hh"
|
||||
|
||||
#include "grammars/altarica/AltaricaGenerator.hh"
|
||||
#include "grammars/altarica/AltaricaJson.hh"
|
||||
#include "grammars/altarica/AltaricaInitInfoXML2.hh"
|
||||
#include "grammars/altarica/AltaricaInteractive.hh"
|
||||
//#include "algorithms/incrTarjan.hh"
|
||||
// #include "algorithms/LinearSystemExactParametricSolver.hh"
|
||||
#include "grammars/details/parsingdriverbaseimpl.hh"
|
||||
// #include "solvers/altaricaLogic.hh"
|
||||
#include <ios>
|
||||
|
||||
//using namespace epoch;
|
||||
|
||||
int main (int ac, char* av[])
|
||||
{
|
||||
unsigned int verbosity; // verbosity level
|
||||
std::string modelFile;
|
||||
std::string jsonFile;
|
||||
bool ds;
|
||||
bool printFlow;
|
||||
bool printNULL;
|
||||
bool printDomain;
|
||||
try {
|
||||
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help", "produce help message")
|
||||
("ds", boost::program_options::value<bool>(&ds)->default_value(false), "print semantic debug messages for discrete models")
|
||||
("file", boost::program_options::value<std::string>(&modelFile)->default_value(""), "model file (either .alt (altartica) or [.prism|.nm|.pm|.sm] (prism)")
|
||||
("json", boost::program_options::value<std::string>(&jsonFile)->default_value(""), "json file (init, testcases)")
|
||||
("pf", boost::program_options::value<bool>(&printFlow)->default_value(false), "print flow vars")
|
||||
("pn", boost::program_options::value<bool>(&printNULL)->default_value(false), "print null values")
|
||||
("pd", boost::program_options::value<bool>(&printDomain)->default_value(false), "print var domains")
|
||||
;
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("file", 1);
|
||||
|
||||
|
||||
namespace options_style_ns = boost::program_options::command_line_style;
|
||||
int options_style = options_style_ns::allow_short | options_style_ns::short_allow_adjacent | options_style_ns::short_allow_next
|
||||
| options_style_ns::allow_long | options_style_ns::long_allow_adjacent | options_style_ns::long_allow_next
|
||||
| options_style_ns::allow_sticky | options_style_ns::allow_dash_for_short;
|
||||
boost::program_options::variables_map vm;
|
||||
// boost::program_options::store(boost::program_options::parse_command_line(ac, av, desc, options_style), vm);
|
||||
boost::program_options::store(boost::program_options::command_line_parser(ac,av).options(desc).positional(p).style(options_style).run(), vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
std::cout << desc << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
epoch::console::ParsingDriverConsoleReporter pdr;
|
||||
|
||||
|
||||
boost::filesystem::path filepath(modelFile);
|
||||
if (!filepath.has_extension()) {
|
||||
std::cerr << "File '" << filepath << "' has no extension!" << std::endl;
|
||||
return -1;
|
||||
} else if (filepath.extension().generic_string() == ".alt") { // altarica
|
||||
epoch::altarica::AltaricaGenerator gen(modelFile, pdr);
|
||||
gen.amodel_->setDebugSemantics(ds);
|
||||
std::cout << std::endl << "MODEL STATS:" << std::endl;
|
||||
std::cout << "number of state vars: " << gen.amodel_->getNStateVars() << std::endl;
|
||||
std::cout << "number of _different_ flow vars: " << gen.amodel_->getNFlowVars() << std::endl;
|
||||
std::cout << "number of atomic events: " << gen.amodel_->getNEvents() << std::endl <<std::endl;
|
||||
|
||||
|
||||
epoch::altarica::AltaricaJson * aj;
|
||||
if (jsonFile.compare("") != 0) {
|
||||
aj = gen.amodel_->setInitInfoJSON(jsonFile);
|
||||
std::cout << aj->toString() <<std::endl;
|
||||
}
|
||||
|
||||
epoch::altarica::AltaricaState * cstate = gen.amodel_->initialState();
|
||||
std::cout << "Initial State:\n";
|
||||
if (printFlow)
|
||||
gen.amodel_->evaluateFlowVars(cstate);
|
||||
std::cout << cstate->toString(true,printFlow,printNULL,printDomain);
|
||||
|
||||
if (jsonFile.compare("") != 0) {
|
||||
if (aj->hasEvents())
|
||||
return aj->runTestCase(cstate);
|
||||
}
|
||||
if (jsonFile.compare("") == 0 || !aj->hasEvents())
|
||||
epoch::altarica::interactiveExecute(cstate, gen.amodel_,printFlow, printNULL, printDomain);
|
||||
|
||||
|
||||
|
||||
// epoch::altarica::interactiveExecute(gen.amodel_->initialState(), gen.amodel_,true, false, false);
|
||||
|
||||
// typedef epoch::algorithm::IncrTarjan<epoch::solvers::AltaricaLogic,
|
||||
// epoch::altarica::AltaricaGenerator,
|
||||
// epoch::graph::HashTable,
|
||||
// epoch::graph::List,
|
||||
// epoch::algorithm::LinearSystemExactParametricSolver> myTarjanAlt;
|
||||
// myTarjanAlt mt(gen);
|
||||
// epoch::solvers::AltaricaLogicF1 f1;
|
||||
// epoch::solvers::AltaricaLogicF2 f2(gen.amodel_, "main.s", "s9", false);
|
||||
|
||||
// mt.launch(gen.amodel_->initialState(), f1, f2);
|
||||
// delete gen.amodel_;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*** removing PRISM extension ****
|
||||
|
||||
else if (filepath.extension().generic_string() == ".prism" ||
|
||||
filepath.extension().generic_string() ==".nm" ||
|
||||
filepath.extension().generic_string() == ".pm" ||
|
||||
filepath.extension().generic_string() == ".sm") { // prism file
|
||||
epoch::prism::ParsingDriver parser(epoch::prism::ParsingDriver::PARSE_MODULES, pdr, modelFile);
|
||||
parser.context().setType(epoch::prism::Context::PRISM_TYPE_DTMC);
|
||||
parser.Parse();
|
||||
parser.context().setType(epoch::prism::Context::PRISM_TYPE_DTMC);
|
||||
epoch::prism::Generator<epoch::prism::Context::PRISM_TYPE_DTMC> gen(parser.context());
|
||||
typedef
|
||||
epoch::algorithm::IncrTarjan<epoch::solvers::PrismLogic,
|
||||
epoch::prism::Generator<epoch::prism::Context::PRISM_TYPE_DTMC>,
|
||||
epoch::graph::HashTable,
|
||||
epoch::graph::List,
|
||||
epoch::algorithm::LinearSystemExactParametricSolver> myTarjanPrism;
|
||||
myTarjanPrism mt(gen);
|
||||
|
||||
typename epoch::prism::Generator<epoch::prism::Context::PRISM_TYPE_DTMC>::State is(parser.context());
|
||||
for (epoch::prism::Context::BooleanVariableMap::const_iterator bi = parser.context().getBooleanVariables().begin() ; bi != parser.context().getBooleanVariables().end() ; ++bi) {
|
||||
if (!(bi->second->isInitialValueSpecified())) {
|
||||
std::cerr << "Initial value not specified for variable '" << *(bi->first) << "': assuming lowest value of its range" << std::endl;
|
||||
}
|
||||
is.m_BooleanVariables[bi->second->getIndex()] = bi->second->getInitialValue();
|
||||
}
|
||||
for (epoch::prism::Context::IntegerVariableMap::const_iterator ii = parser.context().getIntegerVariables().begin() ; ii != parser.context().getIntegerVariables().end() ; ++ii) {
|
||||
if (!(ii->second->isInitialValueSpecified())) {
|
||||
std::cerr << "Initial value not specified for variable '" << *(ii->first) << "': assuming lowest value of its range" << std::endl;
|
||||
}
|
||||
is.m_IntegerVariables[ii->second->getIndex()] = ii->second->getInitialValue();
|
||||
}
|
||||
for (epoch::prism::Context::DecimalVariableMap::const_iterator di = parser.context().getDecimalVariables().begin() ; di != parser.context().getDecimalVariables().end() ; ++di) {
|
||||
if (!(di->second->isInitialValueSpecified())) {
|
||||
std::cerr << "Initial value not specified for variable '" << *(di->first) << "': assuming lowest value of its range" << std::endl;
|
||||
}
|
||||
is.m_DecimalVariables[di->second->getIndex()] = di->second->getInitialValue();
|
||||
}
|
||||
for (epoch::prism::Context::ModuleMap::const_iterator mi = parser.context().getModules().begin() ; mi != parser.context().getModules().end() ; ++mi) {
|
||||
for (epoch::prism::Context::BooleanVariableMap::const_iterator bi = mi->second->getBooleanVariables().begin() ; bi != mi->second->getBooleanVariables().end() ; ++bi) {
|
||||
if (!(bi->second->isInitialValueSpecified())) {
|
||||
std::cerr << "Initial value not specified for variable '" << *(bi->first) << "': assuming lowest value of its range" << std::endl;
|
||||
}
|
||||
is.m_BooleanVariables[bi->second->getIndex()] = bi->second->getInitialValue();
|
||||
}
|
||||
for (epoch::prism::Context::IntegerVariableMap::const_iterator ii = mi->second->getIntegerVariables().begin() ; ii != mi->second->getIntegerVariables().end() ; ++ii) {
|
||||
if (!(ii->second->isInitialValueSpecified())) {
|
||||
std::cerr << "Initial value not specified for variable '" << *(ii->first) << "': assuming lowest value of its range" << std::endl;
|
||||
}
|
||||
is.m_IntegerVariables[ii->second->getIndex()] = ii->second->getInitialValue();
|
||||
}
|
||||
for (epoch::prism::Context::DecimalVariableMap::const_iterator di = mi->second->getDecimalVariables().begin() ; di != mi->second->getDecimalVariables().end() ; ++di) {
|
||||
if (!(di->second->isInitialValueSpecified())) {
|
||||
std::cerr << "Initial value not specified for variable '" << *(di->first) << "': assuming lowest value of its range" << std::endl;
|
||||
}
|
||||
is.m_DecimalVariables[di->second->getIndex()] = di->second->getInitialValue();
|
||||
}
|
||||
}
|
||||
epoch::solvers::PrismLogic F1("", parser.context(),pdr);
|
||||
epoch::solvers::PrismLogic F2("", parser.context(),pdr);
|
||||
|
||||
mt.launch(is, F1, F2);
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// epoch::altarica::AltaricaInitInfoXML2 *aix2 = new epoch::altarica::AltaricaInitInfoXML2(jsonFile, gen.amodel_);
|
||||
// std::cout << aix2->toString();
|
||||
// exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (const boost::program_options::error& error) {
|
||||
std::cerr << error.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
catch (const std::exception& error) {
|
||||
std::cerr << boost::diagnostic_information(error) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
211
src/console/symepochmain.cc
Normal file
211
src/console/symepochmain.cc
Normal file
@@ -0,0 +1,211 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015-2017 ONERA and IRT AESE (IRT Saint Exupéry).
|
||||
* Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab) et de
|
||||
* l'IRT AESE (IRT Saint Exupéry).
|
||||
* Tous droits réservés.
|
||||
*
|
||||
* Ce programme et les éléments qui l'accompagnent sont mis à disposition
|
||||
* aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
|
||||
* au droit français et respectant les principes de diffusion des logiciels libres.
|
||||
* Vous pouvez utiliser, modifier et/ou redistribuer ce programme
|
||||
* sous les conditions de la licence CeCILL-C (http://www.cecill.info).
|
||||
|
||||
* This software is property of ONERA (the French Aerospace Lab) and of
|
||||
* the IRT AESE (IRT Saint Exupéry).
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under
|
||||
* the terms of the CeCILL-C license under French law and
|
||||
* abiding by the rules of distribution of free software.
|
||||
* You can use, modify and/ or redistribute the software under the terms of
|
||||
* the CeCILL-C license (http://www.cecill.info).
|
||||
*
|
||||
* Contributeurs/contributors:
|
||||
* Xavier Pucel (ONERA - Centre de Toulouse) - initial API and implementation
|
||||
* Alexandre Albore (IRT Saint-Exupéry) - Altarica/Fiacre translation
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
|
||||
#include "epochconsolealtarica.hh"
|
||||
|
||||
#include "grammars/altarica/AltaricaGenerator.hh"
|
||||
#include "grammars/altarica/Assignment.hh"
|
||||
#include "grammars/altarica/Event.hh"
|
||||
#include "grammars/altarica/MemberAccess.hh"
|
||||
#include "grammars/altarica/Node.hh"
|
||||
#include "grammars/altarica/Synchronisation.hh"
|
||||
#include "grammars/altarica/Transition.hh"
|
||||
#include "grammars/altarica/Variable.hh"
|
||||
|
||||
#include "symbolic/SymModel.hh"
|
||||
//using namespace epoch;
|
||||
|
||||
int main(int ac, char* av[]) {
|
||||
unsigned int verbosity; // verbosity level
|
||||
std::string modelFile;
|
||||
std::string initFile;
|
||||
bool ds;
|
||||
bool printFlow;
|
||||
bool printNULL;
|
||||
bool printDomain;
|
||||
|
||||
// try {
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help", "produce help message")
|
||||
("ds",
|
||||
boost::program_options::value<bool>(&ds)->default_value(false),
|
||||
"print semantic debug messages for discrete models")
|
||||
("file",
|
||||
boost::program_options::value<std::string>(&modelFile)-> default_value(""),
|
||||
"model file (either .alt (altartica) or [.prism|.nm|.pm|.sm] (prism)")
|
||||
("init",
|
||||
boost::program_options::value<std::string>(&initFile)->default_value(""),
|
||||
"init file")
|
||||
("pf",
|
||||
boost::program_options::value<bool>(&printFlow)->default_value(false),
|
||||
"print flow vars")
|
||||
("pn",
|
||||
boost::program_options::value<bool>(&printNULL)->default_value(false),
|
||||
"print null values")
|
||||
("pd",
|
||||
boost::program_options::value<bool>(&printDomain)->default_value(false),
|
||||
"print var domains")
|
||||
;
|
||||
|
||||
boost::program_options::positional_options_description p;
|
||||
p.add("file", 1);
|
||||
|
||||
|
||||
namespace options_style_ns = boost::program_options::command_line_style;
|
||||
int options_style = options_style_ns::allow_short
|
||||
| options_style_ns::short_allow_adjacent
|
||||
| options_style_ns::short_allow_next
|
||||
| options_style_ns::allow_long
|
||||
| options_style_ns::long_allow_adjacent
|
||||
| options_style_ns::long_allow_next
|
||||
| options_style_ns::allow_sticky
|
||||
| options_style_ns::allow_dash_for_short;
|
||||
boost::program_options::variables_map vm;
|
||||
// boost::program_options::store
|
||||
// (boost::program_options::parse_command_line(ac, av, desc, options_style),
|
||||
// vm);
|
||||
boost::program_options::store
|
||||
(boost::program_options::command_line_parser(ac,av).options(desc).
|
||||
positional(p).style(options_style).run(),
|
||||
vm);
|
||||
boost::program_options::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
std::cout << desc << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
epoch::console::ParsingDriverConsoleReporter pdr;
|
||||
epoch::altarica::AltaricaGenerator gen(modelFile, pdr);
|
||||
gen.amodel_->setDebugSemantics(ds);
|
||||
|
||||
// if (initFile.compare("") != 0)
|
||||
// gen.amodel_->setInitInfo(initFile);
|
||||
|
||||
// std::cout << std::endl << "MODEL STATS:" << std::endl;
|
||||
|
||||
// std::cout << "number of state vars: "
|
||||
// << gen.amodel_->getNStateVars()
|
||||
// << std::endl;
|
||||
|
||||
// std::cout << "number of _different_ flow vars: "
|
||||
// << gen.amodel_->getNFlowVars()
|
||||
// << std::endl;
|
||||
|
||||
// std::cout << "number of atomic events: "
|
||||
// << gen.amodel_->getNEvents()
|
||||
// << std::endl
|
||||
// << std::endl;
|
||||
|
||||
std::cout << std::endl << "FLOW VARS" << std::endl;
|
||||
for(auto &v : gen.amodel_->getFlowVars()) {
|
||||
std::cout << v->getFullName() << " : "
|
||||
<< v->getDomain()->toString()
|
||||
// << std::endl
|
||||
// << "var at " << v->getIndex()
|
||||
// << " is "
|
||||
// << gen.amodel_->getFlowVar(v->getIndex())->getFullName()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl << "STATE VARS" << std::endl;
|
||||
for(auto &v : gen.amodel_->getStateVars()) {
|
||||
std::cout << v->getFullName()
|
||||
<< " : "
|
||||
<< v->getDomain()->toString()
|
||||
// << std::endl
|
||||
// << "var at " << v->getIndex()
|
||||
// << " is "
|
||||
// << gen.amodel_->getStateVar(v->getIndex())->getFullName()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl << "ATOMIC EVTS" << std::endl;
|
||||
for(auto &e : gen.amodel_->getAtomicEvents()) {
|
||||
std::cout << e->getFullName()
|
||||
<< " : "
|
||||
<< std::endl;
|
||||
if(e->getTrans()->size() > 0)
|
||||
for(auto &t : *e->getTrans()) {
|
||||
std::cout << " pre : "
|
||||
<< t->getPrecond()->toString()
|
||||
<< std::endl;
|
||||
if(t->getAssigns()->size() > 0) {
|
||||
std::cout << " post: " << std::endl;
|
||||
for(auto &a : *t->getAssigns()) {
|
||||
std::cout << " "
|
||||
<< a->getVar()->toString()
|
||||
<< " := "
|
||||
<< a->getExpr()->toString()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << "SYNCS" << std::endl;
|
||||
for(auto &s: gen.amodel_->getSyncs()) {
|
||||
if(s->getMA() != NULL)
|
||||
std::cout << s->toString() << std::endl;
|
||||
if(s->getMandatoryEvents()->size() > 0) {
|
||||
std::cout << " Mandatory events:" << std::endl;
|
||||
for(auto &e : *s->getMandatoryEvents())
|
||||
std::cout << " " << e->getFullName() << std::endl;
|
||||
}
|
||||
if(s->getOptionalEvents()->size() > 0) {
|
||||
std::cout << " Optional events:" << std::endl;
|
||||
for(auto &e : *s->getOptionalEvents())
|
||||
std::cout << " " << e->getFullName() << std::endl;
|
||||
}
|
||||
if(s->getNumericalConstant() >= 0) {
|
||||
std::cout << " Constraint type: " << s->getConstraintType() << std::endl;
|
||||
std::cout << " Numerical constant: "
|
||||
<< s->getNumericalConstant()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
epoch::symbolic::SymModel bddmodel(gen.amodel_);
|
||||
|
||||
// }
|
||||
// catch (const boost::program_options::error& error) {
|
||||
// std::cerr << error.what() << std::endl;
|
||||
// return -1;
|
||||
// } catch (const epoch::altarica::AltaricaException& error) {
|
||||
// std::cerr << error.what() << std::endl;
|
||||
// return -1;
|
||||
// } catch (const std::exception& error) {
|
||||
// std::cerr << boost::diagnostic_information(error) << std::endl;
|
||||
// return -1;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user