Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stem-dev] Antw: Re: Interfacing STEM with external workflows RE: Committing a Disease Model variant

Stefan's comment seems to get quite close to what we want to do.

For the beginning, we want to have an option to call an external model
out of STEM that sets the appropriate parameters. 
My first idea was the mentioned modified "new disease wizard" that
contains a button that calls an external program (containing a model
that calculates a transition rate for example) and reads its output to
set the corresponding parameters in the "new disease wizard" dialog.

In the next step, it would be desirable to have the feature to: 
-read in relevant values of the entire simulation (model, graph,
population sizes, disease parameters, maybe one day the nutrition
behaviour) 
-tell these read values to an external program that does some
calculation (with the data from STEM and own information like nutrition
behaviour or something like that)
-use output of the model to adapt the simulation values.

In the normal case, one simulation run should be sufficient when the
parameters are once set to the values that the external program spit
out.


The change of the $$$.standard files to change the decorators seems to
be quite effective. This could work without touching any STEM code,
even.
The more comfy solution for the user might be a button in the STEM GUI
that allows to pick a project whose values are to be set by the external
program, but this is of course much more effort to implement in STEM.

KR
Jan

 


>>> Stefan Edlund <edlund@xxxxxxxxxxxxxxx> 11/22/2011 7:12  >>>
My understanding is that there is a important external program that
determines the parameters of the STEM scenario in perhaps ways we
cannot
determine beforehand, so like option 2 below.

Without any changes to the current code, this could be done in a shell
script

1. Call external program
2. Read and parse the output, overwrite the $$$.standard (disease model
or
perhaps an infector) file under the decorators folder with new
parameters.
3. Call 'STEM.exe -headless -uri <your scenario> -log"
4. Repeat from step 1 as long as needed.

Regards,
/ Stefan


Stefan Edlund
Public Health and Computer Science Research
IBM Almaden Research Center
(408) 927-1766   edlund@xxxxxxxxxxxxxxx 



|------------>
| From:      |
|------------>
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |James Kaufman <kaufman@xxxxxxxxxxxxxxx>                             
                                                                        
    |
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |"Wigger Jan-Frederik" <Jan-Frederik.Wigger@xxxxxxxxxxx>,
stem-dev@xxxxxxxxxxx,                                                
                   |
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |11/22/2011 09:52 AM                                                 
                                                                        
    |
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |[stem-dev] Interfacing STEM with external workflows RE: Committing a
Disease Model variant                                                   
    |
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Sent by:   |
|------------>
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |stem-dev-bounces@xxxxxxxxxxx                                        
                                                                        
    |
 
>--------------------------------------------------------------------------------------------------------------------------------------------------|





Jan,
Let's take this discussion to stem-dev (added above).

I'm still not fully understanding your goal. Are any of the following
on
target?

1) If your goal is to use an external program to specify a list of
parameters to use in
kicking off a series of STEM runs, then STEM has a mechanism you can
take
advantage of. Please read on the wiki about
STEM "Experiments".
http://wiki.eclipse.org/Batch_Mode_%28Running_Experiments%29 
 Instead of using the STEM wizard or GUI, all you would need to do is
to
have your external process or workflow
modify the $$$.experiment file. Then run it. We could probably set up a
way
to kick off a headless run of an Experiment batch
just like we now do for a single scenario.

2) If your goal is to modify the parameters of a single active
simulation
before it runs, then I think it makes more sense to modify the
the disease .decorator file (in the decorators folder). This is
preferable
to making an external call at runtime (on startup) because if you take
that option the log files will be wrong. If you modify the .decorator
file,
then STEM will correctly log the parameters actually run and keep
those
with the
results (same for option 1 above).

3) The other case I can image is that you want to use a statistical
package
like R to change the disease parameters until your runs find a minimum
or
until a model
fits some external data. Here again I think we want to try to take
advantage of another existing feature, namely "automated experiments".
Please see: http://wiki.eclipse.org/Running_an_Automated_Experiment 
This feature uses STEMS Nelder-Mead simplex algoritm to do a fit to
data.
You could have your workflow modify the $$$.automaticexperiment file
before
kicking it off.

4) If none of the above I would definitely like to have a phone call
so
Stefan and Matt can join this discussion. Please keep in mind that if
we
create a new disease model
that makes and external call in the "updatelabels()" method, this
method is
called at every iteration and at every node in the canonical graph.

Thanks in advance for your patience. I really want to make sure we
understand the use case so we start down the right path....

Sincerely,
Jamie

IBM Almaden Research Center, 650 Harry Rd.
San Jose, CA 95120-6099
email: kaufman@xxxxxxxxxxxxxxx 
phone: (408) 927-2477  (tie 457-2477)



                                                                       
   
 From "Wigger Jan-Frederik" <Jan-Frederik.Wigger@xxxxxxxxxxx>          
   
 :                                                                     
   
                                                                       
   
 To:  "Kaufman James" <kaufman@xxxxxxxxxxxxxxx>,                       
   
                                                                       
   
 Cc:  "Edlund Stefan" <edlund@xxxxxxxxxxxxxxx>, "Weiser Armin"         
   
      <Armin.Weiser@xxxxxxxxxxx>, "Filter Matthias"                    
   
      <Matthias.Filter@xxxxxxxxxxx>                                    
   
                                                                       
   
 Date 11/22/2011 06:20 AM                                              
   
 :                                                                     
   
                                                                       
   
 Subj Antw: Re: Committing a Disease Model variant                     
   
 ect:                                                                  
   
                                                                       
   
                                                                       
   






Hey Jamie,

thank you very much for your quick response.
I think it is something similar to (1) what we need, but much easier.
We want to call something like R-scripts or other external programs,
that return the results of their calculations in a standard output
format.
Something like this:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("c:\\..\\R.exe --vanilla --slave  <
C:\\..\\own_model.R ");

This is then read by the call within STEM, like:
BufferedReader input = new BufferedReader(new
InputStreamReader(pr.getInputStream()));
...

These values are then used to set the parameters of the disease model.

So all of this is fairly low-level stuff, but supposed to be the first
step in the development of a communication with external models that
calculate parameters of a simulation.

If there is another way of handling this or covered by Stefans
approach, any help with this is as always highly appreciated.

Thanks!
Jan


>>> James Kaufman <kaufman@xxxxxxxxxxxxxxx> 11/21/2011 5:40  >>>
Hi Jan,
We already have something called an external data source disease
model.

Please take a look at this code and see if it is a model that might
work.
It is not multipopulation but it should be possible to generalize it
to

multipopulation. It basically reads files and "plays them back".

Is your goal primarily to
1) Use STEM to initialize and kick off a separate simulation
or
2) Read and use results from and external simulation inside STEM.

The externaldatasourcedisease model handles 2
Stefan has protoytped a new feature called "compile" for case (1) but
we
really need to think carefully about the API for that before
committing

it. No call this week because of thanksgiving but let's take this
discussion forward on stem-dev.

Best Regards,
Jamie

IBM Almaden Research Center, 650 Harry Rd.
San Jose, CA 95120-6099
email: kaufman@xxxxxxxxxxxxxxx 
phone: (408) 927-2477  (tie 457-2477)





From:
"Wigger Jan-Frederik" <Jan-Frederik.Wigger@xxxxxxxxxxx>
To:
"Edlund Stefan" <edlund@xxxxxxxxxxxxxxx>, "Kaufman James"
<kaufman@xxxxxxxxxxxxxxx>,
Cc:
"Weiser Armin" <Armin.Weiser@xxxxxxxxxxx>, "Filter Matthias"
<Matthias.Filter@xxxxxxxxxxx>
Date:
11/21/2011 04:47 AM
Subject:
Committing a Disease Model variant



Hey Stefan and Jamie,

we've got another question next to the discussion about the
cattle-meat-case..
In our project, we want to realize the possibility to call external
models out of STEM. The easiest way for us that still meets the
project
requirements seems to be the following:
in the new-disease-wizard, there should be a button like "use external
model".
By pressing the button, a new dialog appears where you can give the
path of the external model program.
This external model program reads whatever values have been set in the
disease dialog or ignore the disease parameters if no values have been
set.
The external model returns values for the disease model and sets them.

So, at this level, this is only a function for bonelazy users that
don't want to
- start an external program,
- feed it and
-type in the results into STEM
themselves.
So there is no big intellectual challenge in this. But it is supposed
to show the beginning of this direction that might give a good
impression in the project report.

Are you okay when I create a new disease model like "Multipopulation
SEIR disease model + external" that I commit?
New stuff would only be the button and its function to call an
external
program and the dialog to enter the model path and parameters.

Kind regards
Jan


>>> Stefan Edlund <edlund@xxxxxxxxxxxxxxx> 11/11/2011 10:25  >>>
Hi Jan,

it's really exciting what you are trying to do and we're eager to help
out
in any way we can. Food mediated diseases could be a very important
direction to take STEM, also very timely given the recent high
visibility
outbreaks.

Here's some answers/suggestions to your questions from me in blue and
Jamie
in  green.

  1)            It might be easier to model the scenario with only 2
populations:
     animal and human. It has the advantage that an infected animal
from
     the farm passes through the slaughterhouse and the infection of
     humans could be realized via a mulit-population disease model.
     Problem in this setting is, that infected animals in the area 1
     country nodes would behave like a regular animal population
which
     means that the disease would also spread between the animals in
this
     node which is in contrast to the intended use. Question: is it
     possible to create something like a node specific trigger that
     prevent the transmission of a disease in a specific node? Or
even
     better: is it possible to alter the transmission rates for
specific
     nodes for a disease?

                The interventions framework (
     http://wiki.eclipse.org/Triggering_interventions) is supposed to
be
     able to handle situations like this. The idea is you attach an
     intervention label to a node and the disease model calculation
takes
     into account any control/interventions that are in place.
However,
     currently we model vaccinations and isolations only, and only
for
the
     deterministic SI, SIR and SEIR models (not the multi-population
     disease models). Being able to modify the transmission rate in a
node
     is a great idea, it's essentially saying that social distancing
is
     taking place locally. It's easy to extend STEM and implement it
for
     disease models where it makes sense and if you think it is of
use.

                JK: Rather than using interventions I like the idea of

defining
new
     types of nodes (farms, feeding houses, dairies, etc). With a new
     disease model we could scale the transmission rate based on the
TYPE
     of node.

  2)            Instead of two separate populations for animal and
meat,
we
could
     work with an animal population with “demographic”
subgroups..
     Question: Would this be beneficial?

                I think I see one problem with that. Demographic
subgroups are
really
     for dividing populations into things like men/women. The problem
is
     that the birth/death rate is the same for both subgroups and if
one
     of the subgroups, in your case meat, goes away via migration no
new
     meat is "born". If have a feeling that what you did is correct,
     modeling meat as its own population, and that we need to design
a
new
     type of population model that depends on the availability of
another
     population. Actually, come to think of it this might be useful
for
     modeling parasites too.

                JK. Perhaps 1) Modeling cattle => meat could be a
transition
between
     two compartments in a new type of demographic food (cattle)
     population model. We would use the death rate only to specify
death
     rates for cattle. We could introduce a new rate= "expiration
rate"
     for meat. Dead cattle are never turned into meat (unless we want
to
     model pet food). The transition rate from cattle to meat (with a
     multiplier) would be a mass action term very much like the
infection
     process (SI) term in a disease. The transition rate at which
meat
is
     produced is a function of both the 'S'ource cattle population
     (locally) and the 'I'slaughter house capacity. This could be a
label
     on a new slaughter house type node. There would also be a rate
factor
     beta (production rate) which could be shut off in an
intervention. A
     slaughter house could be a new type of region node with a label
for
     capacity, or it could be a label on any region node. The former
might
     be better because if we want to model e-coli then a slaughter
house
     itself could become infected.
     2) Consumption of meat is like a death rate for the meat
population.
     Again there is a mass action term where meet is consumed by a
product
     of 'S'upply of meat and 'I'human population with a rate term. We
     probably want another rate for expiration of uneaten meat. Doing
it
     this way the rate of consumption (like beta) could change. For
     example if an outbreak occurs people might stop eating the meat
but
     it could get thrown away when it expires. We want to be able to
model
     interventions.
     3) Eventually we should think also about a cattle feed model.
Ideally
     our model for cattle should also support modeling their food.

  3)            Could a Modifier/Trigger set the population A in a
node
to the
value
     of Population B?

                No, we don't have any modifiers that can read the
count
of one
     population (or any other attribute for that matter) and set a
value
     of another population.

       JK We do need to deal with the multiplier between cattle and
meat
     (they don't add up to P). I think in a new demographic
population
     model we could define a scale factor so that
       (A*living cattle)+(B*Meat) = total population or supply. In
this
     case A = 1, B = some multiplier. I'm not sure we would really
use
     total population supply to calculate anything but it could be
used in
     unit testing for death rates = 0.

  4)            Is it possible to have a demographic population model

with in a
node
     that other nodes do not have? For example: California has a
     demographic population model with 2 subpopulations, human1 and
     human2. Is it possible to have a Migration Edge to Nevada that
has a
     Standard population model that only provides a human population?

                No, there is currently no connection between subgroups

and the
     "parent" group that created them. I'm not saying it wouldn't be
     possible to take it into account when processing migration
edges,
but
     it has other side effects I would have to think about. If we
were
to
     do this I think any changes to the human1/human2 population
would
     need to be aggregated up to the 'human' population, something we
     don't do today.

                Correct, no. But we don't need to. IF we made the
transition
between
     cattle and meat a mass action term that depends on the region
being a
     slaughter house, no transition would ever occur outside the
slaughter
     house. Supply of cattle to the slaughter house and distribution
of
     meat out of it would be driven by separate migration edges with
rates
     that can be modified by supply and demand and/or by
interventions.

  As for your exception, I know where it's coming from and it would
need
     some fixing on our side. For now as a workaround, you can set
the
     number of worker threads to 1 (Window->Preferences STEM->Solver
then
     "Number of concurrent worker threads").

  Can you open a defect and attach this scenario? The problem is
really
     how we determine which nodes a thread updates, especially in
this
     case when you have population models that only works on a single
     node.

  Thanks!
  / Stefan



Stefan Edlund
Public Health and Computer Science Research
IBM Almaden Research Center
(408) 927-1766   edlund@xxxxxxxxxxxxxxx 





 From:       "Wigger Jan-Frederik" <Jan-Frederik.Wigger@xxxxxxxxxxx>



 To:         "Edlund Stefan" <edlund@xxxxxxxxxxxxxxx>, "Kaufman
James"
<kaufman@xxxxxxxxxxxxxxx>,


 Cc:         "Weiser Armin" <Armin.Weiser@xxxxxxxxxxx>, "Filter
Matthias" <Matthias.Filter@xxxxxxxxxxx>



 Date:       11/11/2011 01:23 AM



 Subject:    Advice from the sages..








Hey Jamie and Stefan,

It's been quite a while, hope you guys do fine?
As you know, we are working on the problem to model the transmission
of
a disease from a product to human population also considering
production
& trade networks.
We are now wondering how we can best model that with stem with the
least effort possible. Maybe even without touching the code at all..
I created a little toy model that has a farm, a slaughterhouse and
three country nodes. I added some functionalities to the graph editor
to
add edges (and edit their values) and display overlayed edges
correctly,
I will uplaod the update soon...

Next to the model, there is a bunch of text attached where we made an
epic out of what we try to do, if you feel like having a look at the
model and the problem description, any advice to solve the problem
would
be highly appreciated.

Thank you very much and have a nice weekend!

Kind regards

Jan



P.S.
after a while, the simulation throws an error (something with the
disease model), any idea why?
!ENTRY org.eclipse.core.jobs 4 2 2011-11-11 09:50:00.868
!MESSAGE An internal error occurred during: "Finite Difference Worker
1".
!STACK 0
java.util.ConcurrentModificationException
                                 at
org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount
(AbstractEList.java:762)
                                 at
org.eclipse.emf.common.util.AbstractEList$EIterator.doNext
(AbstractEList.java:716)
                                 at
org.eclipse.emf.common.util.AbstractEList$EIterator.next
(AbstractEList.java:696)
                                 at
org.eclipse.stem.diseasemodels.standard.impl.StandardDiseaseModelImpl.applyExternalDeltas

(StandardDiseaseModelImpl.java:327)
                                 at
org.eclipse.stem.solvers.fd.impl.FiniteDifferenceImpl.computeDeltasStep
(FiniteDifferenceImpl.java:260)
                                 at
org.eclipse.stem.solvers.fd.impl.FdJob.run(FdJob.java:63)
                                 at
org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)





Jan-Frederik Wigger
Bundesinstitut für Risikobewertung
Fachgruppe Epidemiologie und Zoonosen
Abteilung Biologische Sicherheit

Federal Institute for Risk Assessment
Unit Epidemiology and Zoonoses
Department Biological Safety
Diedersdorfer Weg 1, 12277 Berlin, Germany
Tel. +49 30 18412-2118
Fax +49 30 18412-2952
www.bfr.bund.de 



[attachment "Bfr_toymodel.zip" deleted by Stefan Edlund/Almaden/IBM]
[attachment "Problemspecification_BfR.rtf" deleted by Stefan
Edlund/Almaden/IBM]





_______________________________________________
stem-dev mailing list
stem-dev@xxxxxxxxxxx 
https://dev.eclipse.org/mailman/listinfo/stem-dev 



Back to the top