Commit 0b37c592 authored by Benoit Barbot's avatar Benoit Barbot

Clean warning

parent baa8c322
Pipeline #1054 failed with stages
in 2 minutes and 44 seconds
......@@ -5,7 +5,7 @@ cmake_minimum_required (VERSION 3.3.1)
find_package(BISON)
find_package(FLEX)
find_package(EXPAT)
find_package(GIT)
find_package(Git)
find_package(Boost 1.55)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
......@@ -20,18 +20,18 @@ OUTPUT_STRIP_TRAILING_WHITESPACE
)
ADD_DEFINITIONS(
-O3
-DGIT_REVISION=\"${GIT_REVISION}\"
-DBOOST_PATH=\"-I${Boost_INCLUDE_DIRS}\"
-DBOOST_LIB=\"${Boost_LIBRARIES}\"
-DCPP_COMPILER=\"g++\"
-DCMAKE_VERSION=\"${CMAKE_VERSION}\"
-O3
-DGIT_REVISION=\"${GIT_REVISION}\"
-DBOOST_PATH=\"-I${Boost_INCLUDE_DIRS}\"
-DBOOST_LIB=\"${Boost_LIBRARIES}\"
-DCPP_COMPILER=\"${CMAKE_CXX_COMPILER}\"
-DCMAKE_VERSION=\"${CMAKE_VERSION}\"
)
add_library(grml src/libgrml/expatmodelparser.cc
src/libgrml/modelwriter.cc)
src/libgrml/modelwriter.cc)
target_link_libraries(grml ${EXPAT_LIBRARY})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/ModelGenerator/Eval/")
BISON_TARGET(EvalParser src/ModelGenerator/Eval/Eval-parser.yy
......@@ -43,6 +43,7 @@ add_library(libeval
${BISON_EvalParser_OUTPUTS}
${FLEX_EvalScanner_OUTPUTS}
src/ModelGenerator/Eval/Eval.cpp)
target_include_directories(libeval PRIVATE "src/ModelGenerator/Eval")
target_include_directories(libeval PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/src/ModelGenerator/Eval)
......@@ -64,6 +65,7 @@ src/ModelGenerator/GspnParser/Gspn-Reader.cpp
src/ModelGenerator/GspnParser/Gspn-Writer.cpp
src/ModelGenerator/GspnParser/Gspn_gmlparser.cpp
)
target_compile_options(libgspn PRIVATE -Wno-format-truncation)
target_link_libraries (libgspn grml libeval)
target_include_directories(libgspn PUBLIC "src/libgrml")
target_include_directories(libgspn PRIVATE "src/ModelGenerator/GspnParser")
......@@ -80,23 +82,24 @@ add_library(liblha
${FLEX_LHAScanner_OUTPUTS}
src/ModelGenerator/LhaParser/Lha-Reader.cpp
src/ModelGenerator/LhaParser/Lha_gmlparser.cpp
)
)
target_compile_options(liblha PRIVATE -Wno-format-truncation)
target_include_directories(liblha PRIVATE "src/ModelGenerator/LhaParser")
target_include_directories(liblha PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/ModelGenerator/LhaParser)
target_link_libraries(liblha libeval libgspn)
add_executable(Cosmos
src/Simulator/BatchR.cpp
src/ModelGenerator/Cosmos.cpp
src/ModelGenerator/HaslFormula.cpp
src/ModelGenerator/expressionStruct.cpp
src/ModelGenerator/result.cpp
src/ModelGenerator/Generator.cpp
src/ModelGenerator/casesWriter.cpp
src/ModelGenerator/parameters.cpp
src/ModelGenerator/SimpleSerializer.cpp
src/ModelGenerator/server.cpp)
src/Simulator/BatchR.cpp
src/ModelGenerator/Cosmos.cpp
src/ModelGenerator/HaslFormula.cpp
src/ModelGenerator/expressionStruct.cpp
src/ModelGenerator/result.cpp
src/ModelGenerator/Generator.cpp
src/ModelGenerator/casesWriter.cpp
src/ModelGenerator/parameters.cpp
src/ModelGenerator/SimpleSerializer.cpp
src/ModelGenerator/server.cpp)
target_include_directories(Cosmos PRIVATE "src/ModelGenerator/GspnParser")
target_include_directories(Cosmos PRIVATE "src/ModelGenerator/LhaParser")
......@@ -106,65 +109,65 @@ install(TARGETS Cosmos DESTINATION bin)
add_library(ClientSimBase
src/ModelGenerator/parameters.cpp
src/ModelGenerator/SimpleSerializer.cpp
src/Simulator/BatchR.cpp
src/Simulator/Event.cpp
src/Simulator/EventsQueue.cpp
src/Simulator/timeGen.cpp
src/Simulator/LHA_orig.cpp
src/Simulator/clientsim.cpp
src/Simulator/Simulator.cpp
src/ModelGenerator/parameters.cpp
src/ModelGenerator/SimpleSerializer.cpp
src/Simulator/BatchR.cpp
src/Simulator/Event.cpp
src/Simulator/EventsQueue.cpp
src/Simulator/timeGen.cpp
src/Simulator/LHA_orig.cpp
src/Simulator/clientsim.cpp
src/Simulator/Simulator.cpp
)
target_include_directories(ClientSimBase PRIVATE "src/ModelGenerator")
install(TARGETS ClientSimBase DESTINATION lib)
add_library(ClientSimMain
src/Simulator/timeGenBis.cpp
src/Simulator/main.cpp
src/Simulator/timeGenBis.cpp
src/Simulator/main.cpp
)
target_include_directories(ClientSimMain PRIVATE "src/ModelGenerator")
install(TARGETS ClientSimMain DESTINATION lib)
add_library(ClientSim
src/Simulator/timeGenBis.cpp
src/Simulator/EventsQueueSet.cpp
src/Simulator/SPNBase.cpp
src/Simulator/NLHA.cpp
src/Simulator/RareEvents/SimulatorRE.cpp
src/Simulator/stateSpace.cpp
src/Simulator/RareEvents/numericalSolver.cpp
src/Simulator/RareEvents/numSolverBB.cpp
src/Simulator/RareEvents/numSolverSH.cpp
src/Simulator/RareEvents/SimulatorBoundedRE.cpp
src/Simulator/RareEvents/foxglynn.cpp
src/Simulator/RareEvents/SimulatorContinuousBounded.cpp
src/Simulator/Simulink/SKTime.cpp
src/Simulator/InstanceSPNSim.cpp
src/Simulator/timeGenBis.cpp
src/Simulator/EventsQueueSet.cpp
src/Simulator/SPNBase.cpp
src/Simulator/NLHA.cpp
src/Simulator/RareEvents/SimulatorRE.cpp
src/Simulator/stateSpace.cpp
src/Simulator/RareEvents/numericalSolver.cpp
src/Simulator/RareEvents/numSolverBB.cpp
src/Simulator/RareEvents/numSolverSH.cpp
src/Simulator/RareEvents/SimulatorBoundedRE.cpp
src/Simulator/RareEvents/foxglynn.cpp
src/Simulator/RareEvents/SimulatorContinuousBounded.cpp
src/Simulator/Simulink/SKTime.cpp
src/Simulator/InstanceSPNSim.cpp
)
target_include_directories(ClientSim PRIVATE "src/ModelGenerator")
install(TARGETS ClientSim DESTINATION lib)
install(FILES src/Simulator/spn.hpp src/Simulator/LHA.hpp src/Simulator/marking.hpp
src/Simulator/Polynome.hpp src/Simulator/markingTemplate.hpp
src/Simulator/DistributionDef.hpp
src/Simulator/timeGen.hpp
src/Simulator/timeGenBis.hpp
src/Simulator/Event.hpp
src/Simulator/EventsQueue.hpp
src/Simulator/BatchR.hpp
src/Simulator/EventsQueueSet.hpp
src/Simulator/Simulator.hpp
src/Simulator/stateSpace.hpp
src/Simulator/MarkovChain.hpp
src/Simulator/SPNBase.hpp
src/Simulator/LHA_orig.hpp
src/Simulator/NLHA.hpp
src/Simulator/clientsim.hpp
src/Simulator/Polynome.hpp src/Simulator/markingTemplate.hpp
src/Simulator/DistributionDef.hpp
src/Simulator/timeGen.hpp
src/Simulator/timeGenBis.hpp
src/Simulator/Event.hpp
src/Simulator/EventsQueue.hpp
src/Simulator/BatchR.hpp
src/Simulator/EventsQueueSet.hpp
src/Simulator/Simulator.hpp
src/Simulator/stateSpace.hpp
src/Simulator/MarkovChain.hpp
src/Simulator/SPNBase.hpp
src/Simulator/LHA_orig.hpp
src/Simulator/NLHA.hpp
src/Simulator/clientsim.hpp
src/Simulator/Simulink/SKTime.hpp
src/ModelGenerator/parameters.hpp
src/ModelGenerator/HaslFormula.hpp
src/ModelGenerator/parameters.hpp
src/ModelGenerator/HaslFormula.hpp
DESTINATION include)
......@@ -188,14 +191,15 @@ SOURCES ${ml_SOURCES}
)
add_executable(testClientSim ${CMAKE_CURRENT_BINARY_DIR}/tmp/spn.cpp ${CMAKE_CURRENT_BINARY_DIR}/tmp/LHA.cpp)
target_compile_options(testClientSim PRIVATE -Wno-return-type)
include_directories("src/Simulator")
add_dependencies(testClientSim Cosmos)
target_link_libraries (testClientSim ClientSimMain ClientSimBase)
enable_testing()
add_test(NAME benchTest
add_test(NAME benchTest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Examples/
COMMAND ocaml bench.ml)
set_tests_properties (benchTest
set_tests_properties (benchTest
PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5")
......@@ -63,6 +63,8 @@ std::string systemStringResult(const char* cmd);
*/
void cleanTmp(void);
void exec_or_die(std::string cmd, std::string error_message);
using namespace std;
string systemStringResult(const char* cmd) {
......@@ -92,6 +94,12 @@ void cleanTmp(void){
}
}
void exec_or_die(std::string cmd, std::string error_message){
if( system(cmd.c_str()) != 0) {
cerr << error_message << endl;
exit(EXIT_FAILURE);
}
}
/**
* Main function
......@@ -206,10 +214,10 @@ int main(int argc, char** argv) {
if(P.MaxRuns == 0 && P.lightSimulator){
auto cmd = "cp "+P.Path+"../src/LightSimulator/*.* "+P.tmpPath;
if(P.verbose>=3)cout << cmd << endl;
system(cmd.c_str());
exec_or_die(cmd, "Fail to copy files");
cmd = "cd "+P.tmpPath+"; ./build.sh";
if(P.verbose>=3)cout << cmd << endl;
system(cmd.c_str());
exec_or_die(cmd, "Fail to copy files");
return EXIT_SUCCESS;
}
......@@ -232,7 +240,7 @@ int main(int argc, char** argv) {
if(P.modelType == External){
auto cmd = "cp "+P.PathGspn +" "+P.tmpPath+"/main.cpp";
if(P.verbose>=3)cout << cmd << endl;
system(cmd.c_str());
exec_or_die(cmd, "Fail to copy files");
}
//Compile the simulator
......
%skeleton "lalr1.cc" /* -*- C++ -*- */
%require "2.4"
%defines
%define parser_class_name "Eval_parser"
%define parser_class_name {Eval_parser}
%code requires {
#include <math.h>
......@@ -30,9 +30,9 @@ using namespace std;
%union
{
double RealVal;
int IntVal;
int IntVal;
std::string *name;
};
%code {
......@@ -44,29 +44,29 @@ using namespace std;
%token END 0 "end of file"
%token <name> str
%token <name> str
%token <RealVal> rval
%token <IntVal> ival
%token <name> MIN
%token <name> MAX
%token <name> FLOOR
%token <name> PLUS
%token <name> MINUS
%token <name> MUL
%token <name> DIV
%token <name> POWER
%token <name> LB
%token <name> RB
%token <name> COMMA
%token <name> DOUBLE
%token <name> FLOOR
%token <name> PLUS
%token <name> MINUS
%token <name> MUL
%token <name> DIV
%token <name> POWER
%token <name> LB
%token <name> RB
%token <name> COMMA
%token <name> DOUBLE
%type<RealVal> exp
%printer { debug_stream () << *$$; } str
%destructor { delete $$; } str
%destructor { delete $$; } str
%printer { debug_stream () << $$; } <IntVal>
%printer { debug_stream () << $$; } <RealVal>
......@@ -81,23 +81,22 @@ using namespace std;
%start ArithmethicExp;
ArithmethicExp:exp {Evaluate.IntResult=(int) $1;Evaluate.RealResult=$1;};
exp:
ival {$$=$1;}
|rval {$$=$1;}
|LB exp RB {$$=$2;}
|str {YYABORT; }
|MINUS exp %prec NEG {$$=-$2;}
|exp PLUS exp{$$=$1+$3;}
|exp MUL exp{$$=$1*$3;}
|exp MINUS exp{$$=$1-$3;}
|DOUBLE exp {$$=double($2);}
|exp DIV exp {if($3==0) {cout<<"Division by zero !";YYABORT;}
else $$=$1/double $3;
}
|exp POWER exp {$$=pow($1,$3);}
|MIN LB exp COMMA exp RB {if($3<=$5) $$=$3; else $$=$5;}
|MAX LB exp COMMA exp RB {if($3>=$5) $$=$3; else $$=$5;}
|FLOOR LB exp RB {$$=floor($3);}
ival {$$=$1;}
|rval {$$=$1;}
|LB exp RB {$$=$2;}
|MINUS exp %prec NEG {$$=-$2;}
|exp PLUS exp{$$=$1+$3;}
|exp MUL exp{$$=$1*$3;}
|exp MINUS exp{$$=$1-$3;}
|DOUBLE exp {$$=double($2);}
|exp DIV exp {if($3==0) {cout<<"Division by zero !";YYABORT;}
else $$=$1/double $3;
}
|exp POWER exp {$$=pow($1,$3);}
|MIN LB exp COMMA exp RB {if($3<=$5) $$=$3; else $$=$5;}
|MAX LB exp COMMA exp RB {if($3>=$5) $$=$3; else $$=$5;}
|FLOOR LB exp RB {$$=floor($3);}
%%
void
......
......@@ -43,13 +43,13 @@
using namespace std;
shared_ptr<GspnType> ParseGSPN() {
// initialize an empty structure for the model.
Gspn_Reader gReader(P);
if (P.verbose > 0)cout << "Start Parsing " << P.PathGspn << endl;
int parseresult;
try {
// Check the extension of the model file to call the correct parser
if (!P.GMLinput
......@@ -69,7 +69,7 @@ shared_ptr<GspnType> ParseGSPN() {
}
P.PathGspn = outspt+".grml";
}
if (P.GMLinput
|| (P.PathGspn.compare(P.PathGspn.length() - 4, 4, "grml") == 0)
|| (P.PathGspn.compare(P.PathGspn.length() - 3, 3, "gml") == 0)) {
......@@ -78,13 +78,13 @@ shared_ptr<GspnType> ParseGSPN() {
parseresult = gReader.parse_file(P.PathGspn);
}
P.nbPlace = gReader.spn->pl;
if(parseresult==1 || !gReader.spn)return nullptr;
//The following code modify the internal representation of the
//SPN according to options.
//When using multimodel with simulink and a gspn add a synchronisation transition to the GSPN
if(P.modelType == GSPN_Simulink){
auto &spn = gReader.spn;
......@@ -101,7 +101,7 @@ shared_ptr<GspnType> ParseGSPN() {
spn->outArcsStruct.insert(make_pair(make_pair(spn->tr-1, outarc->first.second) , outarc->second));
}
}
//Set the isTraced flag for places, transitions and hybrid var
if (P.tracedPlace.count("ALL") == 0 && P.tracedPlace.count("ALLCOLOR")==0 ) {
P.nbPlace = 0;
......@@ -128,7 +128,7 @@ shared_ptr<GspnType> ParseGSPN() {
}
}
}
//Apply Law of mass action for MASSACTION distribution:
for (size_t t = 0; t < gReader.spn->tr; t++) {
ProbabiliteDistribution *trDistr = &gReader.spn->transitionStruct[t].dist;
......@@ -145,7 +145,7 @@ shared_ptr<GspnType> ParseGSPN() {
expr pl = expr(PlaceName, gReader.spn->placeStruct[p].name);
expr mult = expr(Pow, pl, exponent);
expr dist = expr(Times, trDistr->Param[0], mult);
trDistr->Param[0] = dist;
}
}
......@@ -163,16 +163,16 @@ shared_ptr<GspnType> ParseGSPN() {
});
}
}
//Print the internal representation
//Print the internal representation
{ using namespace text_output;
if(P.verbose >=3)cout << *(gReader.spn);}
} catch (GrmlInputException& e) {
cerr << "The following exception append during model import: " << e.what() << endl;
return nullptr;
}
return gReader.spn;
}
......@@ -189,7 +189,7 @@ bool ParseLHA(){
trans.markingDependant = false;
trans.ageMemory = false;
trans.nbServers = 1;
emptyGSPN.transitionStruct.push_back(trans);
emptyGSPN.TransId["DummyTrans"]=0;
return ParseLHA(emptyGSPN);
......@@ -199,16 +199,16 @@ bool ParseLHA(GspnType &spn){
// Intialize an empty structure for the automaton
Lha_Reader lReader(spn, P);
auto &A = lReader.MyLha;
int parseresult;
//Copy name of transition and place required for synchronization.
A.TransitionIndex = spn.TransId;
A.PlaceIndex = spn.PlacesId;
A.ConfidenceLevel = P.Level;
if (P.verbose > 0)cout << "Start Parsing " << P.PathLha << endl;
try {
switch (P.generateLHA) {
case CSL_LHA:
......@@ -239,12 +239,12 @@ bool ParseLHA(GspnType &spn){
case NoGen:
break;
}
//check the type of the LHA file
//First check if it is not C++ code
if (P.PathLha.compare(P.PathLha.length() - 3, 3, "cpp") != 0) {
if (P.PathLha.compare(P.PathLha.length() - 4, 4, "grml") == 0) {
//The LHA is in the GRML file format
parseresult = lReader.parse_gml_file(P);
......@@ -254,11 +254,11 @@ bool ParseLHA(GspnType &spn){
parseresult = lReader.parse_file(P);
if(! A.isDeterministic )P.lhaType= NOT_DET;
}
//Add external HASL formula to the lha.
if (P.externalHASL.compare("") != 0)
lReader.parse(P.externalHASL);
//Set the isTraced flag for variables
if (P.tracedPlace.count("ALL")==0 && P.tracedPlace.count("ALLCOLOR")==0) {
for (size_t i = 0; i < A.NbVar; i++) {
......@@ -269,14 +269,14 @@ bool ParseLHA(GspnType &spn){
}
}
}
//If everythink work correctly, copy the HASL formula and generate the code
if (!parseresult && A.NbLoc > 0) {
P.HaslFormulasname = A.HASLname;
P.HaslFormulas = vector<HaslFormulasTop*>(A.HASLtop);
P.nbAlgebraic = A.Algebraic.size();
P.nbQualitatif = A.FinalStateCond.size();
//If the countTrans option is set then add HASL formula counting the occurance of each transition of the LHA.
if (P.CountTrans) {
for (size_t tr = 0; tr < A.Edge.size(); tr++) {
......@@ -290,22 +290,22 @@ bool ParseLHA(GspnType &spn){
P.HaslFormulas.push_back(new HaslFormulasTop(A.Algebraic.size() + tr));
}
}
//some cleaning:
A.SimplyUsedLinearForm = vector<bool>(A.LinearForm.size(),true);
for( size_t i = 0; i< A.LhaFuncArg.size();++i)
if(A.LhaFuncType[i]!="Last")
A.SimplyUsedLinearForm[A.LhaFuncArg[i]] = false;
//Generate the code for the LHA
lReader.WriteFile(P);
lReader.writeDotFile(P.tmpPath + "/templateLHA.dot");
} else {
return false;
}
//If the LHA is already C++ code just copy it to temporary
//and add external HASL formula
} else if (P.PathLha.compare(P.PathLha.length() - 3, 3, "cpp") == 0) {
......@@ -326,7 +326,7 @@ bool ParseLHA(GspnType &spn){
} else
cerr << "Fail to parse extra Hasl Formula" << endl;
}
//Copy the code into the temporary directory
if( P.PathLha != P.tmpPath + "/LHA.cpp"){
string cmd = "cp " + P.PathLha + " " + P.tmpPath + "/LHA.cpp";
......@@ -341,9 +341,9 @@ bool ParseLHA(GspnType &spn){
cerr << "The following exception append during LHA import: " << e.what() << endl;
return false;
}
string cmd;
if (P.RareEvent) {
//If rareevent handling is require copy the lumping function and table of value to the temporary directory
if (P.BoundedRE == 0)cmd = "cp muFile " + P.tmpPath + "/muFile";
......@@ -351,7 +351,7 @@ bool ParseLHA(GspnType &spn){
if (system(cmd.c_str())) return false;
cmd = "cp lumpingfun.cpp " + P.tmpPath + "/lumpingfun.cpp";
if (system(cmd.c_str())) return false;
//Rewrite part of probabilistic operator to apply Rare event handling
//First case for Continuous bounded rare event.
if (P.BoundedContinuous) {
......@@ -361,7 +361,7 @@ bool ParseLHA(GspnType &spn){
(*it)->TypeOp = RE_Continuous;
(*it)->Value = P.continuousStep;
(*it)->Value2 = P.epsilon;
}
} else { // Second case Unbounded rare event.
vector<HaslFormulasTop*> tmpRE;
......@@ -382,19 +382,19 @@ bool ParseLHA(GspnType &spn){
}
}
}
//generateMain();
return true;
}
void generateMain() {
string loc;
loc = P.tmpPath + "/main.cpp";
ofstream mF(loc.c_str(), ios::out | ios::trunc);
mF << "#include \"BatchR.hpp\"" << endl;
mF << "#include \"clientsim.hpp\"" << endl;
/*mF << "#include \"Simulator.hpp\"" << endl;
......@@ -409,7 +409,7 @@ void generateMain() {
mF << "#include \"SKModel.hpp\"" << endl;
mF << "#include \"multimodel.cpp\"" << endl;
}
mF << "int main(int argc, char** argv) {" << endl;
mF << " signal(SIGHUP, signalHandler);" << endl;
mF << " signal(SIGINT, signalHandler);" << endl;
......@@ -444,10 +444,10 @@ void generateMain() {
mF << "}" << endl;
return;
}
// Instantiate EventQueue
const auto eqt = (P.is_domain_impl_set ? "EventsQueueSet" :"EventsQueue");
// Instantiate DEDS
if (P.BoundedRE > 0 || P.BoundedContinuous) {
mF << " SPN_BoundedRE N(false);" << endl;
......@@ -456,20 +456,20 @@ void generateMain() {
} else {
mF << " SPN_orig<" << eqt << "> N(0);" << endl;
}