8#define __SIMLIB__ 0x0309
9#define SIMLIB_VERSION "3.09"
11#define SIMLIB_COPYRIGHT "(c) Petr Peringer, 1991-2022"
43# error "Use C++ compiler, please."
46#if (__cplusplus < 201103L)
47# error "Use C++11 (or newer) compiler, please."
68# error "MSDOS not supported - please, use older version of SIMLIB"
70#elif defined(__linux__) && defined(__GNUC__)
72# define SIMLIB_SYSTEM "Linux"
73# define SIMLIB_COMPILER "GNU C++"
75#elif defined(__WIN32__)
77# define SIMLIB_SYSTEM "WIN32"
78# if defined(__BCPLUSPLUS__)
79# define SIMLIB_COMPILER "Borland C++"
80# elif defined(__GNUC__)
81# define SIMLIB_COMPILER "GNU C++"
84#elif defined(__FreeBSD__) && defined(__GNUC__)
86# define SIMLIB_SYSTEM "FreeBSD"
87# define SIMLIB_COMPILER "GNU C++"
90# warning "SIMLIB is not tested on this system/compiler"
98unsigned long Debug(
unsigned long mode=~0UL);
162extern const double &
Time;
182 extern void SIMLIB_Init(
double t0,
double t1,
unsigned version);
193void SetStep(
double dtmin,
double dtmax);
215[[noreturn]]
void Error(
const char *fmt, ...);
219int Print(
const char *fmt, ...);
222int _Print(
const char *fmt, ...);
226int Print(
const double x);
230int Print(
const double x,
const double y);
235int Print(
const double x,
const double y,
const double z);
264double Beta(
double th,
double fi,
double min,
double max);
266double Erlang(
double alfa,
int beta);
270double Gamma(
double alfa,
double beta);
274double Logar(
double mi,
double delta);
276int NegBin(
double q,
int k);
279double Normal(
double mi,
double sigma);
282double Rayle(
double delta);
285double Uniform(
double l,
double h);
287double Weibul(
double lambda,
double alfa);
313 void *
operator new(
size_t size);
314 void operator delete(
void *ptr);
315 void *
operator new[](
size_t size) =
delete;
316 void operator delete[](
void *ptr) =
delete;
320 virtual std::string
Name()
const;
322 void SetName(
const std::string &name);
325 virtual void Output()
const;
415 virtual void Out()
override;
419 virtual void _Run() noexcept = 0;
442 virtual void _Run() noexcept override;
461 virtual void Output()
const override;
462 virtual std::string
Name()
const override;
464 virtual void Activate(
double t)
override;
466 virtual void Wait(
double dtime);
468#ifdef I_REALLY_KNOW_HOW_TO_USE_WAITUNTIL
470# define WaitUntil(condition) while(_WaitUntil(condition)) ;
489 virtual void _Run()
noexcept override;
495 virtual void Output()
const override;
496 virtual std::string
Name()
const override;
498 virtual void Activate(
double t)
override;
516 Sampler(
void (*pf)(),
double dt=0.0);
518 virtual void Output()
const override;
545 aStat(
const char *name);
547 virtual void Clear() = 0;
549 virtual void operator () (
double x) = 0;
550 virtual void Record(
double x) = 0;
552 virtual double MeanValue() = 0;
553 double Min()
const {
return min; }
554 double Max()
const {
return max; }
555 unsigned long NumberOfRecords()
const {
return n; }
556 virtual void Output()
const override;
572 explicit Stat(
const char *name);
574 virtual void Clear();
578 virtual void Output()
const override;
606 explicit TStat(
double initval=0.0);
607 explicit TStat(
const char *name,
double initval=0.0);
609 virtual void Clear(
double initval=0.0);
610 virtual void Output()
const override;
657 explicit List(
const char *_name);
659 virtual void Output()
const override;
694 explicit Queue(
const char *_name);
697 virtual void Output()
const override;
736 virtual void Output()
const override;
739 virtual void Clear();
762 explicit Facility(
const char *_name);
766 virtual void Output()
const override;
770 bool Busy()
const {
return in!=
nullptr; }
776 virtual void Clear();
794 explicit Store(
unsigned long _capacity);
795 Store(
const char *_name,
unsigned long _capacity);
797 Store(
const char *_name,
unsigned long _capacity,
Queue *queue);
799 virtual void Output()
const override;
811 virtual void Leave(
unsigned long rcap);
813 virtual void Clear();
839 virtual void _Eval();
882#define RegisterReference(aContiBlockPtr)
883#define UnRegisterReference(aContiBlockPtr)
953 double Value()
override;
990 static std::list<Integrator*> *
Instance(
void);
1025 static std::list<Status*>*
Instance(
void);
1064 std::list<IntegrationMethod*>::iterator
ItList;
1109 virtual void Resize(
size_t cs);
1119 virtual void Resize(
size_t size);
1124 static void SetMethod(
const char* name);
1129 static void InitStep(
double step_frag);
1130 static void FunCall(
double step_frag);
1174 static void SetStarter(
const char* name,
const char* slave_name);
1176 virtual void SetStarter(
const char* slave_name);
1178 static const char*
GetStarter(
const char* name);
1180 virtual void TurnOff(
void)
override;
1229 virtual void TurnOff(
void)
override;
1305 void Init(
double initvalue);
1307 void Set(
double value);
1312 void Eval()
override;
1313 double Value()
override;
1346 void Init(
double initvalue);
1348 void Set(
double value);
1349 virtual void Eval()
override;
1350 virtual double Value()
override;
1374 virtual void Eval()
override;
1392 virtual void Eval()
override;
1408 double y1,
double y2);
1409 virtual void Eval()
override;
1454 double (*
f)(double);
1457 virtual double Value()
override;
1468 double (*
f)(double,double);
1471 virtual double Value()
override;
1496 static bool isAny();
1510 virtual void Init()
override;
1513 virtual bool Test()
override;
1561 Lim(
Input in,
double l,
double h,
double tga=1.0);
1562 virtual void _Eval()
override;
1563 virtual double Value()
override;
1578 Insv(
Input in,
double l,
double h,
double tga=1.0,
double tgb=1.0);
1579 virtual void _Eval()
override;
1580 virtual double Value()
override;
1595 virtual void _Eval()
override;
1596 virtual double Value()
override;
1611 Frict(
Input in,
double l,
double h,
double tga=1.0);
1612 virtual void _Eval()
override;
1613 virtual double Value()
override;
1630 Rline(
Input in,
int num,
double *X,
double *Y);
1633 virtual void _Eval()
override;
1634 virtual double Value()
override;
1658 double t_min,
double t_max,
double t0);
1659 void Set(
double eps,
unsigned long max_it,
1660 double t_min,
double t_max,
double t0);
1661 void Set(
double eps,
unsigned long max_it,
1662 double t_min,
double t_max);
1674 double t_min,
double t_max,
double t0):
1675 AlgLoop(i, eps, max_it, t_min, t_max, t0)
1677 virtual double Value()
override;
1688 double t_min,
double t_max):
1689 AlgLoop(i, eps, max_it, t_min, t_max, t_min)
1691 virtual double Value()
override;
1703 double t_min,
double t_max):
1704 AlgLoop(i, eps, max_it, t_min, t_max, t_min),
1707 virtual double Value()
override;
1720 double t_min,
double t_max,
double t0):
1721 AlgLoop(i, eps, max_it, t_min, t_max, t0),
1725 virtual double Value()
override;
1766 virtual void Output()
const override;
1784 Barrier(
const char *_name,
unsigned N);
1789 virtual bool Wait();
1790 virtual int Break();
1792 virtual void Output()
const override;
abstract base for algebraic loop solvers
void Set(double eps, unsigned long max_it, double t_min, double t_max, double t0)
synchronization tool for processes
virtual bool Wait()
wait for barrier break (Current)
unsigned n
current number of waiting entities
void Init()
initialization
void ChangeHeight(unsigned new_maxn)
change size
virtual void Enter(Entity *e)
wait for barrier break TODO: remove/rename
Entity ** waiting
array of waiting entities (fixed size)
virtual int Break()
activate all waiting entities
virtual void Output() const override
print status
virtual ~Barrier()
destructor
void Clear()
initialization
unsigned maxn
barrier height/size
unsigned Height() const
barrier size
solve using bisection method
Bisect(Input i, double eps, unsigned long max_it, double t_min, double t_max)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
nonlinear block - backlash
virtual void Eval() override
evaluate without loop detection
bool Test() override
Condition::operator ()
bool Test() override
Condition::operator ()
change detector - Boolean version (int)
Input SetInput(Input inp)
virtual void SetNewStatus() override
update
bool Value()
boolean state of condition
virtual bool Test() override
Condition::operator ()
unsigned char ccl
old state
virtual void Init() override
initialize
block: constant (value can not be changed)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
abstract base class for active entities (Process, Event) instances of derived classes provide Behavio...
EventNotice * GetEventNotice()
virtual void _Run() noexcept=0
run the Behavior() function
EntityPriority_t Priority_t
bool Idle()
entity activation is not scheduled in calendar
void Activate()
activate now
virtual ~Entity()
destructor
EventNotice * _evn
points to calendar item, iff scheduled
Priority_t Priority
priority of the entity (scheduling,queues)
unsigned long _RequiredCapacity
static unsigned long _Number
current number of entities
void Cancel()
end Behavior() and remove entity
virtual void Terminate()=0
end Behavior() and remove entity
double ActivationTime()
get activation time of entity - iff scheduled it is here, because Entity has no knowledge of calend...
ServicePriority_t _SPrio
priority of service in Facility
friend void SIMLIB_DoActions()
virtual void Out() override
remove entity from queue
virtual void Passivate()
deactivation
unsigned long _Ident
unique identification number of entity
abstract base class for events Event behavior is simple function (can not be interrupted)
virtual void Output() const override
print object to default output
virtual void Behavior()=0
behavior description
void Activate()
activate now
virtual ~Event()
destructor
virtual void Terminate() override
passivate event, it will be destroyed if not activated later in Behavior() Should not be used.
virtual std::string Name() const override
name of object
virtual void _Run() noexcept override
activation method, called from simulation control algorithm
(SOL-like) facility Facility with exclusive access and service priority
virtual void QueueIn2(Entity *e)
virtual void QueueIn(Entity *e, ServicePriority_t sp)
bool Busy() const
in service
virtual void Seize(Entity *e, ServicePriority_t sp=DEFAULT_PRIORITY)
virtual void Release(Entity *e)
unsigned char _Qflag
true if facility is owner of input queue
virtual void Clear()
initialize
TStat tstat
usage statistics
virtual void Output() const override
print statistics
Queue * Q2
Interrupted requests queue.
Entity * in
Entity currently in service.
bool OwnQueue() const
test for default queue
void SetQueue(Queue *queue1)
change input queue
unsigned QueueLen() const
Entity * In() const
current entity or nullptr
nonlinear block: friction
virtual void _Eval() override
evaluate block (with loop detection)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
block parametrized by function with single argument
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
Function1 & operator=(const Function1 &)=delete
Function1(const Function1 &)=delete
block parametrized by function with two arguments
double(* f)(double, double)
Function2(const Function2 &)=delete
Function2 & operator=(const Function2 &)=delete
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
unsigned operator[](unsigned i) const
void operator()(double x)
virtual void Output() const override
print to default output
void Init(double low, double step, unsigned count)
nonlinear block - hysteresis
virtual void Eval() override
evaluate without loop detection
nonlinear block: dead zone
virtual void _Eval() override
evaluate block (with loop detection)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
static const size_t page_size
std::list< Memory * >::iterator it_list
virtual ~Memory()
free dynamic data, remove object from list of memories
Memory(const Memory &)=delete
double & operator[](size_t ind)
virtual void Resize(size_t cs)
change size of array to cs, content will be undefined!
std::list< Memory * > * ListPtr
Memory & operator=(const Memory &)=delete
IntegrationMethod - Abstract base class for integration methods.
virtual void Resize(size_t size)
resize all the memories to the given size
static std::list< Memory * > * PtrMList
static IntegrationMethod * CurrentMethodPtr
pointer to the method currently used "rke" is a predefined method (historical reasons,...
virtual bool IsSingleStep(void)=0
static void Summarize(void)
set up new state after execution of integration step
static Iterator LastIntegrator(void)
virtual void Integrate(void)=0
virtual void TurnOff(void)
turn off integration method: flush memories etc...
static void SetErrNo(int num)
static void Iterate(void)
compute new values of state blocks in model without integrators
virtual ~IntegrationMethod()
destroy integration method (remove from list)
IntegrationMethod(IntegrationMethod &)
static bool IsEndStepEvent
static int GetErrNo(void)
static const char * GetMethod(void)
static bool Prepare(void)
initialize integration step
IntegrationMethod & operator=(const IntegrationMethod &)=delete
static void InitStep(double step_frag)
initialize step
IntegrationMethod(const IntegrationMethod &)=delete
static IntegrationMethod * SearchMethod(const char *name)
search method in the list of registrated methods
IntegratorContainer::iterator Iterator
static std::list< IntegrationMethod * > * MthLstPtr
static bool StateCond(void)
check on changes of state conditions
virtual bool PrepareStep(void)
prepare object for integration step
static bool IsConditionFlag(void)
static void IntegrationDone(void)
static void SetMethod(const char *name)
set method which will be used
static void SetOptStep(double opt_step)
static void StepSim(void)
step of numerical integration method
std::list< Memory * > MList
static void SetStepSize(double step_size)
static Iterator FirstIntegrator(void)
std::list< IntegrationMethod * >::iterator ItList
static void FunCall(double step_frag)
IntegratorContainer - internal container of integrators (singleton)
static iterator Insert(Integrator *ptr)
static void Erase(iterator it)
static void EvaluateAll()
static std::list< Integrator * > * ListPtr
list of integrators
static iterator End(void)
static iterator Begin(void)
std::list< Integrator * >::iterator iterator
static std::list< Integrator * > * Instance(void)
block for numerical integration input is derivative, output is state
double Value() override
the state of integrator
void SetOldState(double s)
Input SetInput(Input inp)
set integrator input block expression
double initval
initial value: y(t0)
void Set(double value)
set the integrator status value (step change)
Integrator()
constructor for special cases (arrays of integrators) Input can be set using method Integrator::Set
void SetOldDiff(double d)
double InputValue()
current input value
IntegratorContainer::iterator it_list
position in list of integrators
Input input
input expression: f(t,y)
void Eval() override
evaluate integrator input
~Integrator()
destructor removes integrator from list
void Init()
use preset initial value
Integrator & operator=(const Integrator &x)=delete
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
Iterations(Input i, double eps, unsigned long max_it, double t_min, double t_max, double t0)
nonlinear block: limitation
virtual void _Eval() override
evaluate block (with loop detection)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
base class for all double-linked list items item can be at single place only (identified by where()...
List * head
pointer to List (if any)
virtual bool isInQueue()
present in queue
Link * succ
next object in List
List * Where()
where is linked
virtual void Out()
remove from list
Link * pred
previous object in List
virtual void Into(List *l)
insert last
iterator(const iterator &x)
iterator & operator=(const iterator &x)
bool operator==(iterator q) const
bool operator!=(iterator q) const
list of Link* items, uses data from Link
virtual Link * Get(iterator pos)
remove at position
Link * GetLast()
remove last
void PredIns(Link *e, iterator pos)
static Link * next(Link *p)
void PostIns(Link *e, iterator pos)
virtual void Output() const override
print object to default output
static Link * previous(Link *p)
Link * GetFirst()
remove first
base for multi-step integration method
SingleStepMethod * Slave_Ptr
SingleStepMethod * SlavePtr(void)
return pointer to the starting method (initialize it also)
static const char * GetStarter(const char *name)
obtain the name of the starting method of given method
static void SetStarter(const char *name, const char *slave_name)
set starting method for given multi-step method
virtual void TurnOff(void) override
turn off integration method and its slave (starter)
virtual bool PrepareStep(void) override
prepare the object for the step of integration
virtual bool IsSingleStep(void) override
~MultiStepMethod()
free dynamic data
solve using modified Newton's method
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
Newton(Input i, double eps, unsigned long max_it, double t_min, double t_max, double t0)
block: parameter (can not be changed during simulation run)
Parameter & operator=(double x)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
Abstract base class for all simulation processesProcess behavior is specified by Behavior method and ...
void Leave(Store &s, unsigned long ReqCap=1)
return some capacity
bool _WaitUntil(bool test)
wait for condition (slow!)
virtual void Terminate() override
kill process
ProcessStatus_t
possible process status values
virtual void Wait(double dtime)
wait for dtime interval
void Release(Facility &f)
release facility
void Activate()
activate now
void Seize(Facility &f, ServicePriority_t sp=0)
seize facility
bool isTerminated() const
virtual void Into(Queue &q)
insert process into queue
virtual void Passivate() override
process deactivation (sleep)
virtual void _Run() noexcept override
Process dispatch method.
virtual void Output() const override
print object to default output
enum simlib3::Process::ProcessStatus_t _status
bool isInterrupted() const
void Enter(Store &s, unsigned long ReqCap=1)
acquire some capacity
void * _context
process context pointer
void Interrupt()
test of WaitUntil list, allow running others
virtual void Behavior()=0
behavior description
virtual std::string Name() const override
name of object
virtual ~Process()
Process destructor Sets state to TERMINATED and removes process from queue/calendar/waituntil list.
nonlinear block: quantizer
virtual void _Eval() override
evaluate block (with loop detection)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
virtual void Output() const override
print statistics
virtual Entity * Get(iterator pos)
remove at position
void PredIns(Entity *e, iterator pos)
virtual void Insert(Entity *e)
void PostIns(Entity *e, iterator pos)
solve using regula falsi method
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
RegulaFalsi(Input i, double eps, unsigned long max_it, double t_min, double t_max)
Relay this implementation detects exact time of switch.
virtual void Eval() override
block evaluation
nonlinear block: function defined by given table of values
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
virtual void _Eval() override
evaluate block (with loop detection)
objects of this class call global function periodically (typicaly used for output of continuous model...
void(* function)()
function to call periodically
double SetStep(double dt=0.0)
change step
static void InitAll()
initialize all samplers (Init)
double step
step of sampling
double last
last sample time – prevents sample duplication
virtual void Output() const override
print object to default output
void Start()
start + sample
virtual void Behavior() override
behavior description
static void ActivateAll()
start all samplers (Run)
void Sample()
performs sample (function call)
double GetStep() const
get current step
basic synchronization tool for processes simplified implementation
virtual void V()
V operation.
virtual void Output() const override
print object to default output
virtual void P()
P operation.
void Clear()
initialization
Base class for almost all SIMLIB classes.
bool TestAndSetFlag(bool new_value, unsigned n)
internal method for flag manipulation is used for algebraic loop checking in continuous blocks
@ _CLEAR_ALL_FLAGS
internal flags (bitmasks: 1bit set)
virtual void Output() const
print object to default output
unsigned _flags
bool flags for internal use (TODO bitfield?)
void SetName(const std::string &name)
assign the name
virtual std::string Name() const
get object name
SimObject(const SimObject &)=delete
disable copy operation
SimObject & operator=(const SimObject &)=delete
disable assign operation
virtual ~SimObject()
virtual destructor
base for single-step integration methods
virtual bool IsSingleStep(void) override
void SetStartMode(bool start_mode)
SingleStepMethod(const char *name)
class for statistical information gathering
unsigned long Number() const
virtual void Clear()
initialize
void operator()(double x)
record the value
virtual void Output() const override
print statistics
StatusContainer - internal container of status variables (singleton)
static std::list< Status * > * Instance(void)
static iterator Insert(Status *ptr)
static iterator Begin(void)
std::list< Status * >::iterator iterator
static void EvaluateAll()
static std::list< Status * > * ListPtr
list of status variables
static iterator End(void)
static void ClearAllValueOK()
static void Erase(iterator it)
StatusMemory(const StatusMemory &)=delete
StatusMemory(std::list< Memory * > *PtrList=PtrStatusMList)
void operator=(const StatusMemory &)=delete
Abstract base class for integration methods with status auxiliary memories.
static void StoreState(Memory &di, Memory &si, StatusMemory &xi)
store state of integrators and status variables
static StatusIterator LastStatus(void)
StatusMethod(const StatusMethod &)=delete
StatusContainer::iterator StatusIterator
std::list< Memory * > StatusMList
static std::list< Memory * > * PtrStatusMList
virtual void StatusResize(size_t size)
resize status memories to the given size
static void RestoreState(double dthlf, Memory &di, Memory &si, StatusMemory &xi)
restore state of integrators and status variables
virtual void TurnOff(void) override
turn off integration method: flush memories etc...
static void GoToState(Memory &di, Memory &si, StatusMemory &xi)
move startpoint to given state
virtual bool PrepareStep(void) override
prepare object for integration step
static StatusIterator FirstStatus(void)
State variables (memory) base for blocks with internal state (Relay, ...)
virtual void Eval() override
evaluate without loop detection
void SetOldState(double s)
void Set(double value)
set state variable value (step change)
virtual double Value() override
value of state variable
double stl
status from previous step
double initval
initial value
StatusContainer::iterator it_list
position in list of status variables
(SOL-like) store store capacity can be changed dynamically
void SetQueue(Queue *queue)
change input queue
void SetCapacity(unsigned long _capacity)
change the capacity
unsigned char _Qflag
true if store is owner of input queue
unsigned long Capacity() const
max capacity
bool Full() const
store is full
virtual void Output() const override
print statistics
virtual void Leave(unsigned long rcap)
deallocate capacity
unsigned long capacity
Capacity of store.
virtual void Enter(Entity *e, unsigned long rcap)
allocate capacity
bool OwnQueue() const
OwnQueue.
unsigned long Free() const
free capacity
TStat tstat
usage statistics
bool Empty() const
store is empty
unsigned long Used() const
used capacity
unsigned QueueLen() const
virtual void Clear()
initialize
unsigned long used
Currently used capacity.
virtual void QueueIn(Entity *e, unsigned long c)
insert entity into queue
virtual void operator()(double x)
record the value
virtual void Clear(double initval=0.0)
initialize
virtual void Output() const override
print object to default output
unsigned long Number() const
block: variable (value can be changed)
virtual double Value() override
get block output value this method should be defined in classes derived from aContiBlock
Variable & operator=(double x)
abstract base class for all blocksblocks/SimObject have not copy semantics (TODO: add move semantics)
abstract base class for all state-condition blocks State event in combined model is executed at the t...
static aCondition * First
aCondition(const aCondition &)=delete
virtual void Action()=0
state event description
virtual bool Test()=0
test of the condition
virtual void SetNewStatus()=0
update
virtual void Init()=0
initialize
void operator=(const aCondition &)=delete
base for continuous blocks with single input and algebraic loop check
base for continuous blocks with two inputs
base for continuous blocks vith three inputs and algebraic loop check
abstract base for continuous blocks with single output suitable for expression-tree building and eval...
virtual double Value()=0
get block output value this method should be defined in classes derived from aContiBlock
virtual void Eval()
evaluate without loop detection
virtual void _Eval()
evaluate block (with loop detection)
void SetStarter(const char *name, const char *slave_name)
set the method which will be used to start given multistep method
const char * GetStarter(void)
get the name of the method which is used to start currently used multistep method
void InstallBreak(void(*f)())
InstallBreak — set function for checking if user breaks simulation.
const char * GetMethod(void)
get the name of the method which is used
void SetMethod(const char *name)
select the integration method
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
void Activate(Entity *e)
activate entity e
const double & Time
model time (is NOT the block)
const double & StepSize
actual integration step
void Stop()
stop current simulation run
const double & NextTime
next-event time
Input Max(Input x, Input y)
double Gamma(double alfa, double beta)
Gamma distribution generator.
void DebugOFF()
stop debugging output
void Abort()
end simulation program
double Rayle(double delta)
const double & StartTime
time of simulation start
Input operator-(Input a, Input b)
block operator -
Input Min(Input x, Input y)
const double & RelativeError
max. rel. error
aContiBlock & T
simulation time block reference
const unsigned SIMLIB_version
library version
std::string GetName(SimObject &o)
get name of object
void Passivate(Entity *e)
passivate entity e
void SetAccuracy(double _abserr, double _relerr)
set max.
Input operator+(Input a, Input b)
block operator +
void SetStep(double _dtmin, double _dtmax)
Set integration step interval.
const double & MaxStep
maximal integration step
double Triag(double mod, double min, double max)
const double & AbsoluteError
max. abs. error of integration
void DebugON()
start debugging output
void SetOutput(const char *name)
redirects Output(), Print() to file
double Beta(double th, double fi, double min, double max)
Beta distribution generator.
const double & EndTime
time of simulation end
void SetCalendar(const char *name)
choose calendar implementation default is list
double Uniform(double l, double h)
Uniform distribution generator.
void RemoveName(SimObject &o)
remove name
int NegBinM(double p, int m)
double Weibul(double lambda, double alfa)
Weibul distribution generator.
Input operator*(Input a, Input b)
block operator *
Input ATan2(Input y, Input x)
unsigned char ServicePriority_t
Service priority (see Facility::Seize)
unsigned long Debug(unsigned long mode)
Input Pow(Input x, Input y)
int _Print(const char *fmt,...)
output of messages to stdout, too
double min(double a, double b)
int NegBin(double q, int k)
const double SIMLIB_MINTIME
minimal time value
double max(double a, double b)
void SetName(SimObject &o, const std::string &name)
assign name to object
void Error(const char *fmt,...)
print message and terminate program
void Run()
run simulation experiment
const double & MinStep
minimal integration step
signed char EntityPriority_t
Priority of the process/event.
int Print(const char *fmt,...)
for Output methods, can be redirected
void SIMLIB_Init(double T0, double T1, unsigned version)
double Erlang(double alfa, int beta)
Erlang distribution generator.
const double & OptStep
optimal integration step
double Normal(double mi, double sigma)
Gauss distribution generator.
int HyperGeom(double p, int n, int m)
void RandomSeed(long seed)
initialize random number seed
double Exponential(double mv)
Exponential distribution generator.
int Poisson(double lambda)
Poisson distribution generator.
double Random()
base uniform generator (range 0-0.999999...) the default implementation is simple LCG 32bit
void Init(double t0, double t1=SIMLIB_MAXTIME)
Initialize simulator and model time.
const double SIMLIB_MAXTIME
maximum time (1e30 works for float, too)
double Logar(double mi, double delta)
Input Sqr(Input x)
square function
Entity *const & Current
pointer to active (now running) entity
Input operator/(Input a, Input b)
block operator /
void ContractStep()
contract step of integration
const SIMLIB_statistics_t & SIMLIB_statistics
interface to internal run-time statistics structure
const char * SIMLIB_version_string()
Get version of SIMLIB.
void SetBaseRandomGenerator(double(*new_gen)())
set another random generator default Random() implementation can be replaced
#define UnRegisterReference(aContiBlockPtr)
#define RegisterReference(aContiBlockPtr)
reference to block expression This block can be used as handle for block expression trees
double Value() override
Evaluate expression and return the value.
internal statistics structure contains basic statistics of simulator execution
void Output() const
print run-time statistics to output
SIMLIB_statistics_t()
constructor runs SIMLIB_statistics_t::Init()
void Init()
initialize - used at the start of each Run()