
TODO -- what to do in SIMLIB
============================
metaTODO: clean this list ;-)


process.cc: CANARY[12] = store as intptr_t/uintptr_t

?[remove WaitUntil - use condvars]

Facility::in  - use method In()

add new testcase for Process::Terminate()
clean terminology(thread/coroutine, isCurrent/isRunning)

set rounding mode, (use sse2 in 32bit mode, too?)
add make check (test/, compare automatically)
add new examples


CHECK virtual behavior of Activate() methods in all places! (see BUGS)
continue cleaning of process.cc
use coverage tool: lcov?


* clean-up the interfaces
- check calendar implementation, add heap


what about  { seize(f); seize(f); } //deadlock


///////////////////////////////////////////////////////////
New Queue hierarchy or decorators:
aQueue<Entity>
  PriorityQueue (default)
  FIFOQueue
  LIFOQueue
  RandomQueue
+ChangeQueueSortOrder(*)
+possible new sort orders
=examples:
  Queue Q;        // PriorityQueue (default sort order)
  Queue Q2(FIFO); // FIFOQueue
  Queue Q3(10);   // Prio, limited (exception QueueFull)
///////////////////////////////////////////////////////////

Clean simlib.h interfaces -- hide all implementation details (PIMPL?)

Split fuzzy extension - base SIMLIB should not depend on it

tune AlgLoopDetector code

Calendar - corrections, add heap implementation

ADD: list of all statistics for automatic initialization by Init()
     +flag NoAutoInit


CHECK: Behavior() { delete this; Cancel(); Terminate(); }
    Event: Error message & abort
    Process: Terminate correctly (~Process(), check double-destructor-call?)


! better make test


2007-12-11:
 - try to add reference counting of aContiBlock derived blocks
   it counts number of Input references
   TODO: special handling of loops, Destructor should free inputs

-----------------------------------
Init(): experiment_counter++
publish and use in ststistics
-----------------------------------

Create CONFIGURATION map<string,string>  name=value
fill it using: 1) environment variables, 2) config file, 3) arguments
ProcessStackSizeLimit=xxKiB
ReadConfiguration("file"|argc,argv|...)
string=QueryConfiguration("key"); // Read only

-----------------------------------

SOLVED:
check for problems with GCC 3.3.2 (debian) -- models crash if compiled without -O2
solved by GCC 3.4 ? -- NOT -- it can be libc problem also
*** 2007-10 Finally solved this BUG by rewrite of process switching code
Problem: SP was set by compiler to fixed value and this argument was stored
         above SP (and not saved). Most of the time it worked...
Thu Nov  8 16:07:36 CET 2007

-----------------------------------

TODO: add Expression(Expression) [like Integrator]  ?

-----------------------------------

TODO: use configure to generate Makefiles

======= MAKEfile

all
    Your `all' production should make every executable of your project.
    Usually the `all' production doesn't have an explicit rule; instead it
    refers to all of your project's top-level targets (and, not accidentally,
    documents what those are). Conventionally this should be the first
    production in your makefile, so it will the one executed when the
    developer types `make' with no argument.

    clean
        Remove all files (such as binary executables and object files) that
        are normally created when you `make all'. Don't remove any derived
        files that came with the distribution, however.

  dist
    Make a source archive (usually with the tar(1) program) that can
    be shipped as a unit and used to rebuild the program on another
    machine. This target should do the equivalent of depending on
    `all' so that a `make dist' automatically rebuilds the whole
    project before making the distribution archive -- this is a good
    way to avoid last-minute embarrassments!

    distclean
        Throw away everything but what you would include if you were
        bundling up the source with `make dist'. This may be the the
        same as `make clean' but should be included as a production of
        its own anyway, to document what's going on. When it's
        different, it usually differs by throwing away local
        configuration files that aren't part of the normal `make all'
        build sequence (such as those generated by autoconf(1); we'll
        talk about autoconf(1) in Chapter 10 on portability).

        realclean
  Throw away everything you can rebuild using the makefile.
  This may be the same as `make distclean', but should be
  included as a production of its own anyway, to document
  what's going on. When it's different, it usually differs
  by throwing away files that are derived but (for whatever
  reason) shipped with the project sources anyway.

  install
      Install the project's executables and documentation in
      system directories so they will be accessible to
      general users (this typically requires root
      privileges). Initialize or update any databases or
      libraries that the executables require in order to
      function.

      uninstall
          Remove files installed in system directories by
          `make install' (this typically requires root
          privileges). The presence of an uninstall feature
          implies a kind of humility that experienced Unix
          hands look for as a sign of thoughtful design.

=======

new design: namespace SIMLIB, use templates, etc

(DONE) discrete-only subset of SIMLIB
(partialy done) integrate optimization algorithms & infrastructure
(DONE) integrate fuzzy extension
Doxygen comments in source

restructuralization of modules
-----------------------------------------------------------------------------

Condition c(in,UP,function1,DOWN,function2)
Condition c(in,UP,function)
Condition c(in,DOWN,function)
Condition c(in,function)
Bool = c.Value()
in==Bool ==> halv-interval
in==Real ==> regula falsi?
possible inheritance and redefinition of Action() by any code
+ DEMO - accuracy in x/y = f(minstep,dy/dt)
-----------------------------------------------------------------------------


Makefile universal, calls Makefile.`uname` ??????????
                    or special parameters? no_shared, c++name, ...

clean the semantic for Facility/Store/etc
add STL containers, remove non-STL upport


-----------------------------------------------------------------------------


Borland C++ 5.0x -- changes, testing, exceptions?

add RCS

DOC: nespolehat na okamzik ruseni procesu atd..

ADD: NO_WAITUNTIL, NO_PROCESS, 
     DISCRETE_ONLY, CONTINUOUS_ONLY 

clean-up code, remove 'magic' comments ###!!!???
-----
ADD statistics for simulation run:
  model time: start-stop-length [model-time-units]
  ??? real time: start[date:time]-stop-length [seconds]
  continuous step length: len-min len-max len-avg  
  # of conti. steps  
     #of shortened (calls to ContractStep) #of widened (+1%max)
  # of event activations (Run)
  # of WaitUntil activations (WAU)
  # of discontinuity times (all StateCondition changes activation)
  # of output events = Sampler calls

-----
ADD model statistics: at end of Run
  # of process and events (created,now?)
  # of contiblocks (Integrators, Delay, ...) created
  # of Queues, Facilities, Stores, ... created
  
CHANGE Process implementation void*

CZECH only section:
----------------------------------------------------------------------------

TODO - delay:
=============
kratka zpozdeni --- problem s moznou smyckou !!!!!!
!!!!! obcas testovat if MaxStep < delay_time
moznost zadat maximum zpozdeni --> rezervace mista pro
                prodluzovani zpozdeni!!!!!!!!!!

zajistit vzorky pri skokove zmene v modelu (time-event, state-event)
TJ pred a po zmene !!!! (Time-event funguje, Conditions OK 12.8.98)
je hotovo ???

----------------------------------------------------------------------------
neni testovano, co uz je
 - upravit adresare/soubory

dokumentace - zakladni (README,TODO,BUGLIST,...) do SIMLIB/

980612:
 - upravit Makefile pro DOS-BC>=5, DJGPP>=2.8
 - vyhodit _test_
 globalni Makefile pro Make-simlib, Make-examples, Make-test, ...
 - upravit pro STL!
 - dodelat dokumentaci v anglictine (popis+tutorial)
 - README
 - bloky zpozdeni (vzorkovane i obecne)

----------------------------------------------------------------------------

kontrola zbytecnosti!

= novy I/O system

+ kontrola pri propojovani! aContoBlock magic number

vse jen v jednom adresari ?? move to Linux!

--
Histogram-doplnit funkce pro rel.cetnost, kumulativni.cetnost,
  sum pridat do atributu, doresit okrajove hodnoty, (automaticke upravy?)
  +priklad procesor.cpp upravit!!!
--

VSE prelozit do anglictiny!!!
(pouze dokumentaci a nektere priklady take cesky)

trida PeriodicEvent, + parametr AutoStart/kdy? !!!!

-------------------------------------------------------------------------
JAK zpracovat rozdil blok/funkce? 
   Limit l;... l(x,lo,hi)   NEBO/A    (a + Limit(x,lo,hi))
co s tim???? NELZE pojmenovat stejne!!!??
Envelope: Limit     Letter: SIMLIB_Limit
objekt staticky (deklarace)/ tmp (vyraz)
ve vyrazu jen zprostredkuje propojeni !!!!!!
FUNGUJE - je treba zkoumat dusledky!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-------------------------------------------------------------------------

doplnit bloky podle 

4.4.96
------

Polynom3 -  ax3 + bx2 + cx (+ d??)  Horner
rizeny integrator

soustavy!1!
!!!diskretni bloky dt,...


port+outstream+sampler pro vzorkovani vystupu !!!!!!

WaitUntilList: 
KONTROLA: - prochazi cyklicky dokud nejsou _vsechny_ FALSE
            (problem: zacykleni!!!???)


zmna struktury 
 List   <->   ListItem   <->   SimObjectLink?
          zklad 3 ukazatele   ukazatele Link a Where (nejen fronta)

 cl: monost doplnit informace do ListItem u nkterch front?



22.3.96
-------

KONTROLA: inicializovat _vsechny_ atributy trid v CTR !!!!

NEW: experiment jako funkce/objekt?  SimulationExperiment()

REGISTRACE: vsechny instance aBlock pri vzniku => mozne testy a GC !!!
            (seznam - slozitost: in=const, out=N)


zjistit proc je Sin s velkym S ???? (asi byly problemy, ale mozna 
 jen ve starych prekladacich !!!!)


vice abstrakci EventActive,EventPasive a alias Event


special Condition: a) s toleranc, b)s detekc bez pekroen meze
class History: zaznamenat stav objektu


metoda Activate u bloku - provede akci pri stavove podmince???????


POZOR: SetInput se neprojevi v pripade zadratovani 
       struktury --> pouzit novou tridu InputRef:aContiBlock???

       class X { 
          Input i; 
        public: 
          X() : i(Sin(i)) {} // chyba - neinicializovany odkaz
       };

       Input povolit jan na predavani parametru a vraceni odkazu
        (jen alokace na STACK?)


prevod na STL a STD-LIB !!!!!!!!!!!!!!!!!!


NumericalIntegration:
    - funkce static v modulu method.cpp a friend v Integrator? (ochrana)

OUTPUT - rozdelit!

!!! instalovatelne akce:
    - stepchange     dovoli efektivne sledovat zmeny delky kroku
    - Start/Stop     doplnky
    - everyStep      
 implementace = kontejnery ^funkci
------


Relay r;    r.PreEvent|PostEvent(Event*)   ____.|.^^^^ (obvykle pro tisk)
^^^^^ a SimpleRelay1 jen jednosmerne || rele bez testu


abstrakce GATE    fronta | ---> ovladano bool, jako WaitUntil


Event: automaticky ukonovat!!! nelze!
novy priklad: animace delky fronty atd.....


publikovat ZDROJOVE TEXTY


STL priority Queue!


SetName,GetName,RemoveName - pojmenovani objektu - zmenit:
  Facility F; SetName(F,"zarizeni1"); ??????????????????


Randomize,Random - ukazatele? SetRandom?????
nebo objekty RandomValue x[(type?,base_function)]
(2 varianty? jednoducha/rychla a lepsi/pomala)
 - nco pevzt z GNU C lib


Store S(jmeno,kapacita[,init_kap]);


Input operator op ( Input a, Input b );
^^^^^               ^^^^^^^^^^^^^^^^ nahradit Block & ? - vyhody/ne?

NELZE! double--->block problem


!@!!!!! Input -- neodkazovat se skrz ale na Input sm a v jeho destruktoru
                 provst pepnut vstupu ?????????????????????

doplnit: blok prepinac  x>0:Ainp:Binp ++
++++ BOOL_BLOCKS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dovol Conditions!!!

provit! : Status - implementace s detekc smyek??? NE !!!!!!!!!!!!!!!!!!!

+++ doplnit double RealTimeOfSimulationRun() [seconds]
+++ funkce  GetStepSize(), GetAccuracyEstimate(), GetStepNumber()
+++ dal statistick informace (poty proces, pam?, ...)

nov RANDOM, PRINT(opertory,fce - ne metody)

jmna: HashTable
OBJid=adresa objektu (this)

OPRAVA!!!! doplnit do Input kontrolu pri pouziti (byl-li inicializovan),
 nebo zavest Expression pro pomocne vyrazy (optimalizaci)


26.4.95:
regulace: monost zastavit integraci u Integrator (vyadit ze seznamu???)
          blok omezen - vstup: Omezuje|Neomezuje -- pro spnn integrace^
          bloky PI[D]


29.3.95:
FUN.CPP: reimplementovat! bloky fun1 fun2, v konstruktoru parametry a funkce
(a u debug-verze i textova identifikace "Sin"|"Cos"...)
moznost uzivatelske definice (zverejnit bazovy blok)
+++nove bloky:
Tan, ArcTan, Abs, Sqrt, Sgn, 
Step, Ramp, Pulse(s), 
Deriv, Delay, Hold?=Status

==== zvazit implementaci front a kalendare ====
SKIPLISTs !!! c:\ar\sources
viz !!!!!!!.cpp

Universe - [Sub]Model - Entity
==============================

---------------------------------------------------------------------------
! doplnit pro vechny objekty (entity) zaazen do seznamu objekt modelu
  (dvojsmrn seznam)

 Object
   container
     Model (nebo Universe?)
     queue (hierarchick struktura podle 'umstn' v modelu)



---------------------------------------------------------------------------
!POPIS:
  #include "simlib.h"
  MODEL(jmeno); // makro - generuje jmno, Universe?|Model, kontroly
  // popis td
  [ // popis experimentu ]

  nebo
  #define MODEL "toto je model testujici num. integraci"
  #include "simlib.h"  <<< zde se testuje atd...







 funkce Init, End
 tda Experiment e1(Model,Init,End);  /// v main() ???


---------------------------------------------------------------------------



? Process { PID } --------> ThreadTable[PID] { state } ------> stav zasobniku

Iterators!!!!!!!!!!!!

a) nezavisle moduly: threads, calltable, callptr, container


function table for Init(),
                   Run(), etc.
     -Add-Rem-Call- priority atd...
     funkce se instaluj dynamicky pri pouziti modulu (jinak se nelinkuji)


Linux version| MSDOS version
BC | GNU C++

diferenn rovnice -> ada zpodn cyklick fronta -> rychlost

oddlit modul  THREADS - samostatn a implementan zvisl
 (a testy pro reimplementaci an jinem HW)
 oddelit thread a proces - z SIMLIB.H zrusit #include <longjmp.h>

templates!!!!!!!!!!!

moduly Random a Stat - oddlit
i/o, NumIntMethods - oddlit

doplnit #pragma -b -p -u -f -k -ml -d -rd 
zruit -Vo a generovat ruzne verze SIMLIB pro ruzne  prekladace!!!
na konci simlib.h obnovit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


doplnit Monitor(ON|OFF)


zkontrolovat integran metodu - pizpsobovn kroku !!!!!!!!
const char *Name() pro Integrator# ... ?????
(dal vrstva v plnovacm systmu?  krok spojit sim. 0,1/4,1/2,3/4,1)
======================================================================
integrtory s rznmi metodami!!!!!!!!!!!!


inicializace objekt pi Init -- automaticky????


doplnit NameTable dynamicky mnit poet jmen !!!!!!!!!!!!
---------------------------------------------------------


Init() -- doplnit inicializace !!!!!!!!!!!!!
--------------------------------------------


kontrola smantiky  Store::Leave ! (parametr)
  a) [current] search the queue for acceptable requests
  b) check only the first

Queue sorting: use template specification?




oprava: skripta [156] - ~Zakaznik(<parametry>)   !!!!!! nesm mt parametry


ns. ddinost: opravit new a delete ??? (GNU protestuje)  ZMNIT!


DOPLNIT signly pro peruen simulace !!!!!!!!!!!
  (msto ESC bude Ctrl-C)


kontrola konzistence
operace pri startu/ukonceni simulace (AtStart AtEnd)


o do v3.0 TEMPLATE modely pro prvn piblen !!!!!!!!!!!!!!!!!!!!???


o -- 2 verze: SIMLIB a DSIMLIB(debug)  (a verze pro ruzne prekladace a systemy)


o -- zvit zkaz typu double v obj. vrazech !!!!!!!!!!!!!!!!!!!!!!!!


- podmnky:
    Condition x( a>b | a, event | funkce)


o promyslet vrazy!!!!!!!!!!!!!!!!!
o Calendar - reimplementovat!!!
o Queue, List, Link, Entity - reimplementovat
o Facility, Store - upravit

o Garbage collecting!!! na vrazy +-
------------------------------------

o formty tisku statistik do souboru?????

o zajistit automatickou inicializaci objekt pi Init()

o   prostedky pro ladn:
    - _Memory monitor
    - _Debug class: promnn se  stavem:
                    as, poty (procesy,udlosti,...)
		    dlka kalende, waituntil, ...

o   rozdlit hierarchii objekt?????????????

o   genertory nhodnch sel (new)

o prozkoumat pouit seznamu Integrator a Status (spojit do jednoho?)



----------------------------------------------------------------------------
/////////////////////////// OLD - z HISTORY ////////////////////////////////
----------------------------------------------------------------------------

- doplnit:
   - integracni metody, (EULER,stiff)
   - detekce nespojitosti
   - vypis "nedodrzena presnost" pouze jednou na zac (a na konci jiny)
   - doplnit on-line graficky vystup DEMO
   - doplnit novy format vystupniho souboru

NEWS!
- waituntil x
- class XXX : Process, Continuous, Condition { ... }
- striktni oddeleni modelu a experimentu

=======================================================
- integrace & aproximace
- semi-persistent containers
- discrete event simulation
- numerical analysis
- optimization & O.R.
- adaptive modelling
-queuing systems
- exceptions
- statistics


STRUCT:
  model        ------>
  rizeni sim.  <-->    sber dat  ----> DISK/...
  experiment   ------>

OUTPUTS
  output-list = seznam objektu pro vystupy
  vystupy:
  1) explicitni - fce Output(co[,kam])
  2) implisitni - AssignOutput(stream#,co)
                  AssignStream(stream#,file[,delta_T])
                                        +-  podle typu TXT/BIN

  OutputBlocks
  normalblock---->ob----->file

NAMES - external identifiers
  NameTable
    - hash table of name & pointer to object
    if object is deleted - search & delete in table
    AssignName("xxx",obj1)
    name -> object
    object -> name fast!
    objectFlag = named  // -> rychlejsi pri delete!

  NameOf() methods - class names

OBJEKT
    -getStatus
    -Activate
    -Identification
    -Initialize
    -Ctr/Dtr
    -Assign operator =


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
operace - formalni specifikace !!!!!!!!!!!!!!!!

Pozor!!!
  doplnit
    WaitUntilVar

    waituntil(x);

DOPLNIT:
  - class Delay
  - obecnou nelinearitu, obecny gen nah. cisel
  - podminky:
      Condition<TypPodminky> C(Event*), C1(void(*)(void)), C2();
      Conditions ()   // typedef symbol !!!!
      {
        C(xxxx);
        C1(x>3);
        C2(y<2); 
      } 
      Dynamic { .... }

	class ev1:event {
           Behavior { .... } // ???????????????????

  - OUTPUT !!!!!!!!!!!

Pouit nsobn ddinosti ???? // ANO !!!!!

class DynLink {
  void Init(procptr x);
  void Call();
//  void Done();
};

class Initializer { // pro inicializaci modulu
  Initializer
  ~Initializer
};

class Experiment { ... };
usage: MyExperiment e1(T0,T1,...); // it is all!
----------------------------------------------------------------------------
