LCOV - code coverage report
Current view: top level - builds/barbot/Cosmos/src/Simulator - timeGenBis.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 19 25 76.0 %
Date: 2021-06-16 15:43:28 Functions: 4 4 100.0 %

          Line data    Source code
       1             : #include "timeGenBis.hpp"
       2             : #include "EventsQueue.hpp"
       3             : #include "SPNBase.cpp"
       4             : #include <float.h>
       5             : 
       6             : using namespace std;
       7             : 
       8             : /**
       9             :  * Generate an event based on the type of his distribution
      10             :  * @param E the event to update
      11             :  * @param Id the number of the transition to of the SPN
      12             :  * @param b is the binding of the variable of the SPN for the transition.
      13             :  */
      14             : 
      15             : template<class DEDS>
      16    67059363 : void generateEvent(double ctime,Event& E,size_t Id,const abstractBinding& b,timeGen &TG,DEDS& N) {
      17    67059363 :     double t=ctime;
      18    67059363 :     if (N.Transition[Id].DistTypeIndex != IMMEDIATE) {
      19    65279843 :         N.GetDistParameters(Id,b);
      20    65279843 :         t += fmax(TG.GenerateTime(N.Transition[Id].DistTypeIndex, Id, N.ParamDistr, N.customDistr),0.0);
      21    65279843 :         if(P.verbose > 4){
      22           0 :             cerr << "Sample " << N.Transition[Id].label << ": ";
      23           0 :             cerr << TG.string_of_dist(N.Transition[Id].DistTypeIndex, N.ParamDistr, N.customDistr);
      24           0 :             cerr << endl;
      25             :         }
      26             :     }
      27             :     
      28             :     //The weight of a transition is always distributed exponentially
      29             :     //It is used to solved conflict of two transitions with same time
      30             :     //and same priority.
      31    67059363 :     double w=0.0;
      32    67059363 :     switch (N.Transition[Id].DistTypeIndex){
      33             :         case DETERMINISTIC:
      34             :         case DISCRETEUNIF:
      35             :         case IMMEDIATE:
      36             :         case IMDT:
      37             :         case SYNC:
      38             :         case DISCRETEUSERDEFINE:
      39    13725361 :             N.ParamDistr[0]= N.GetWeight(Id,b);
      40    13725361 :             w = TG.current_weight + TG.GenerateTime(EXPONENTIAL, Id, N.ParamDistr, N.customDistr);
      41    13725361 :             if(P.verbose>4){
      42           0 :                 cerr << "weight : "<< N.ParamDistr[0] << endl;
      43           0 :                 cerr << TG.string_of_dist(EXPONENTIAL, N.ParamDistr, N.customDistr);
      44           0 :                 cerr << endl;
      45             :             }
      46    13725361 :             break;
      47             :         case PARETO:
      48             :         case NORMAL:
      49             :         case GAMMA:
      50             :         case GEOMETRIC:
      51             :         case UNIFORM:
      52             :         case ERLANG:
      53             :         case WEIBULL:
      54             :         case EXPONENTIAL:
      55             :         case LOGNORMAL:
      56             :         case TRIANGLE:
      57             :         case USERDEFINE:
      58             :         case USERDEFINEPOLYNOMIAL:
      59             :         case MASSACTION:
      60             :         case PLAYER1:
      61             :             ;
      62             :     }
      63             :     
      64    67059363 :     E.transition = N.shift+Id;
      65    67059363 :     E.time = t;
      66    67059363 :     E.priority = N.GetPriority(Id,b);
      67    67059363 :     E.weight = w;
      68    67059363 :     E.binding = b;
      69    67059363 : }
      70             : 
      71             : template void generateEvent<SPN_orig<EventsQueue>>(double, Event&, unsigned long, abstractBinding const&, timeGen&, SPN_orig<EventsQueue>&);
      72          87 : template void generateEvent(double ctime,Event& E,size_t Id,const abstractBinding& b,timeGen &,SPN_orig<EventsQueueSet> &);
      73             : 
      74             : /*#include "MarkovChain.hpp"
      75             : template void generateEvent(double ctime,Event& E,size_t Id,const abstractBinding& b,timeGen &,MarkovChain<EventsQueue<vector<Edge>>> &);
      76             : */

Generated by: LCOV version 1.13