Title: Nessun titolo diapositiva
1Seminario su Swarm 2005-2006 Pietro
Terna pietro.terna_at_unito.it web.econ.unito.it/tern
a
2Secondo semestre martedì 7.3 jES e
jESOF martedì 21.3 ripresa tutorial martedì
11.4 jESlet martedì 2.5 martedì 9.5
sempre dalle 17.30 alle 19 aula 31
3nostro sito a http//eco83.econ.unito.it/swarm/
iscriversi alla mailing list seminarioswarm (vedi
sopra per le istruzioni) inoltre è utile
http//eco83.econ.unito.it/swarm/materiale/ ques
to file ppt e i successivi sono/saranno in linea
a http//web.econ.unito.it/terna/swarm/ questo è
seminario_swarm05-06-20060307.ppt oppure .pdf
4NUOVO StarLogo TNG
nuova versione di StarLogo a http//education.mit
.edu/starlogo-tng/ con leffetto videogioco e
una programmazione semplificata a tesserine
5jGRASP
Da http//www.jgrasp.org ambiente plurilinguaggio
con capacità UML
6jES
- Simulazione ad agenti in contesti di impresa
- jES
- paper Simulazione ad agenti in contesti di
impresa. Sistemi intelligenti, 1, XVI, pp.33-51,
scaricabile da http//web.econ.unito.it/terna/publ
ications.html (paper 2002b) - il codice (Swarm) del modello jES, con un HowTo
esplicativo, sta a http//web.econ.unito.it/terna/
jes/ (scegliere la versione con il numero più
alto il file .tar.gz contiene anche l'HowTo)
7the enterprise simulator
Simulated enterprise, orders, recipes and units
Our simulated enterprise has both orders to
accomplish each described by a recipe that
contains what to do - and units that perform
the different steps of the production
process Units can be within the firm or outside
(i) constituting other complex enterprises or
(ii) standing alone as small business actors
8Figure 1
Recipes and production units
A system of enterprises and micro productive
units (a swarm)
market
Enterprise front end
1-2 2-13 8-28-27-7 ...
units
recipes
FE
8
7
FE
our jES (a swarm of units)
28
7
27
9Figure 2
Recipes on move
8-28-27-7
we have the phases a, b, c, then in x we have a
choice problem
a
units
FE
8
b
7
FE
?
28
c
?
7
x
27
The orders are placed in the unit waiting lists
and executed according to the FIFO criterion
10running jES
Running jES WD DW
The core of the model is the clear separation
between the order recipes (WD side What to Do)
and the operating units (DW side which is Doing
What) WD and DW are completely independent, in
formalism and in code. So, running the model, we
check the consistency of the two sides, as in the
actual world, where the output of an enterprise
arises from a complex interaction among products
and production tools Recipes have also to
describe internal parallel production paths and
include assembly steps, where the typical
procurement problems of a supply chain can be
tested
11jES in action
12WD
WD
WD What to Do
13Figure 3
Basic recipe
WD
The basic recipe in an order is structured as
follows
time quantity measured in days, hours, seconds
step in recipe
n1 ts m1 n2 ts m2 n3 ts m3 n4 ts m4 . . .
time specification days, hours, seconds
14Figure 4
Sequential batch
a sequential batch in a recipe repeats, in a
given time interval, b times the production of
the same step of the recipes of b orders (the
unit doing step n3 has obviously to hang around
until it has b similar order in its waiting list
to start the batch while waiting, it can be
working on other batches)
WD
time quantity measured in days, hours, seconds
step in recipe
n1 ts m1 n2 ts m2 n3 ts m3 \ b3 n4 ts b4
time specification days, hours, seconds
the backslash is followed by the number of
production steps to be repeated in the given time
interval in a sequential batch production of b
pieces, the time necessary for the production of
each piece is measured by the fraction m/b
15Figure 5
Stand alone batch
a stand alone batch repeats, in a given time
interval, b times the production of the same
unique step of the recipes of b orders this kind
of batch production is useful to simulate orders
without details, as external procurements (a sort
of black box for us)
WD
time quantity measured in days, hours, seconds
step in recipe
n1 ts m1 / b1 (no other steps)
time specification days, hours, seconds
the slash is followed by the number of production
steps to be repeated in the given time interval
in a sequential batch production of b pieces, the
time necessary for the production of each piece
is measured by the fraction m/b
16Figure 6
Procurement
8-28-27-7
WD
units
FE
8
121
7
34
28
...
27
73
Deepening recipes to account for procurement
processes
8-121-34-73-28-27-7
17Figure 7
Procurements or components produced by ourselves
WD
Procurements we order some components (here c1,
c2, c3) from other suppliers our management has
to take into account the time necessary to have
the order performed, to make the transport, etc.
e stands for end
n1 ts m1 e c1
n2 ts m2 / b2 e c2
n3 ts m3 / b3 e c3
n41 ts m41 n42 ts m42 \ b42 e c4
n51 ts m51 e c5
Internally produced components we produce inside
our plant the other components (here c4, c5, c6)
our management has to take into account the time
necessary to perform these internal orders
n61 ts m61 / b61 e c6
18DW
DW
DW which is Doing What
19Figure 8
Simple production unit data are reported in a
text file (unitData/unitBasicData.txt)
DW
unit___useWarehouse____prod.phase_____fixed_cost
s_____variable_costs 1 1 11 12 1 2 1 0
0 0 3 1 3 15 2 4 1 0 0 0
5 1 51 12 2 6 1 6 11 20 7 1 12 23
1 8 1 8 22 11 9 1 13 7 12 10 1 18 40
7 11 1 11 5 1
20Figure 9
The general scheme, to be used as a remark page
DW
21Figure 10
A specific complex unit
DW
22Figure 11
End unit data are reported in a text file
(unitData/endUnitList.txt)
DW
end_unit__use_positive_code_for_layer_sensitive_
end_unit_negative_for_unsensitive_do_not_duplica
te_the_codes,_neither_with_a_different_sign -10001
-10002 -10003 10004 10005 10006 10007 10008 10009
10010
NB, all this in a unique line
23Figure 12
Using components (mainly, in assembly steps)
DW
p stands for procurement
step in recipe
n1 ts m1 p k c1 c2 . . . ck n2 ts m2 . . .
after step n1 we have here a procurement phase
(internal or external), looking for k components
coded c1, c2, . . ., ck
the production unit performing the successive
step asks to a special object (the
procurementAssembler) to check whether the
internal or external units can send the
components if not, the production unit waits
24Figure 13
Procurement and internal produced components in a
supply chain
DW
10 s 3 11 s 300 \ 100
e 121 20 s
2000 / 1000 e 34
p 3 31 32 33 44 h 2 e 73
virtual or actual units keeping the completed
procurement components in a warehouse
25Figure 14
Warehouses and inventories in stand alone
production
8-28-27-7
DW
units
?
FE
8
7
FE
28
7
?
27
?
?
? how to decide?
26Figure 15
Knowledge management
8-28-27-7
a microunit
DW
units
News useful for technically objects
FE
8
a macrounit
7
FE
?
?
???
?
28
?
?
7
27
? Sending or not the news a problem of
cooperation, routines, agreements (the core of
organization problems)
??? In external cooperation, which is the
information receiver? The enterprise front end or
directly a sub-unit?
27Figure 16
OR processes (multiple paths) in recipes
after each step we can have multiple paths in our
recipes, but only one of them is followed at a
specific time
n1 ts m1 n2 ts m2 n3 ts m3 n4 ts m4
or
n22 ts m22
end
we use here a C-like formalism ( or)
n1 ts m1 1 n2 ts m2 n3 ts m3 2 n22
ts m22 0 n4 ts m4
where 0 stands for the conclusion of the
multiple paths
28Figure 17
Parallel paths in recipes
after each step we can have also parallel paths
in our recipes, all to be simultaneously executed
at a specific time
n1 ts m1 n2 ts m2 n3 ts m3 n4 ts m4
and
n22 ts m22
end
we use here a C-like formalism ( and)
n1 ts m1 1 n2 ts m2 n3 ts m3 2 n22
ts m22 0 n4 ts m4
where 0 stands for the conclusion of the
multiple paths
29Figure 18
Memory matrixes data are reported in a text file
(unitData/memoryMatrixes.txt)
number(from_0_ordered_negative_if_insensitive_to_
layers)_rows_cols 0 2 3 -1
3 5 2 4 1 3 3
1
Mandatory first line
30Figure 19
Recipes with computations (recipes are reported
in external and intermediate format)
time specification seconds
External format (remember step, time
specification, time)
1 s 1 c 1999 3 0 1 3 2 s 2 3 s 2 1 s 1 c 1998 1
0 5 s 2 1 s 1 c 1998 1 1 6 s 2 1 s 1 c 1998 1 3
7 s 2
step in recipe
a step with computation step 2, requiring 2
seconds, involve computation 1999 with 3 matrixes
(those numbered 0, 1, 3 in the previous Figure)
time in seconds
a step with computation step 7, requiring 2
seconds, involve computation 1998 with 1 matrix
(that numbered 3 in the previous Figure)
Intermediate format (remember each step is
repeated for each unit of time)
1 2 2 -1999 3 0 1 4 1000000002 3 3 1 5 5 -1998
1 0 1000000005 1 6 6 -1998 1 1 1000000006 1 7
7 -1998 1 3 1000000007
after automatic translation, in the intermediate
format reports the computational processes with a
trick (which can be modified, adopting an other
translation in OrderDistiller) we imagine here
that the computations require the time reported
in their steps so they are placed at the end of
the time, followed by a 0 time step (at the
intermediate format level, 0 time step are
reported as 1000000000step
31Figure 20
The Java Swarm code used by the recipes with
computation of this example
/ computational operations with code -1998 (a
code for the checking phase of the
program this computational code
place a number in position 0,0 of the
unique received matrix and set the status to
done / public void c1998() mm0(Memor
yMatrix) pendingComputationalSpecificationSet.
getMemoryMatrixAddress(0) layerpendingComputa
tionalSpecificationSet. getOrderLayer() mm
0.setValue(layer,0,0,1.0) mm0.print() donetr
ue // end c1998
32Figure 21
The Java Swarm code used by the recipes with
computation of this example
/ computational operations with code -1999
(a code for the checking phase of the
program this computational code
verifies position 0,0 of the three
received matrixes only if these positions are
all not empty the code empties them and
set the status to done / public void
c1999() mm0(MemoryMatrix) pendingComputationalS
pecificationSet. getMemoryMatrixAddress(0)
mm1(MemoryMatrix) pendingComputationalSpecificati
onSet. getMemoryMatrixAddress(1) mm2(Memor
yMatrix) pendingComputationalSpecificationSet.
getMemoryMatrixAddress(2) layerpendingComputa
tionalSpecificationSet. getOrderLayer() if
(! (mm0.getEmpty(layer,0,0) mm1.getEmpty(layer,
0,0)
mm2.getEmpty(layer,0,0) ) )
mm0.setEmpty(layer,0,0) mm1.setEmpty(layer,
0,0) mm2.setEmpty(layer,0,0) donetrue
// end c1999
33Figure 22
Accounting capabilities
8-28-27-7
production units
cost accounting on the order side
FE
8
7
differences ?
FE
28
7
cost accounting on the unit side
27
environmental accounting
34agenti
Agenti? ordini, unità produttive agenti che
decidono algoritmi persone (rappresentate da
un avatar) formazione conduzione di
esperimenti simulazione di effetti
35_a simple example with WD, DW and WDW
_______________________________________ A simple
example with WD, DW and WDW ______________________
_________________
36a simple example 0
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t0
100 100 100 101
Building a sequential batch
DW
1
2
3
10
a production unit
an end unit
37a simple example 1
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t1
100 100 100 101
Sequential batch step 1/3
DW
1
2
3
10
a production unit
an end unit
38a simple example 2
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t2
100 100 100 101
Sequential batch step 2/3
DW
1
2
3
10
a production unit
an end unit
39a simple example 3
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t3
101
100 100 100
DW
1
2
3
10
a production unit
an end unit
40a simple example 4
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t4
100
100 100 101
DW
1
2
3
10
a production unit
an end unit
41a simple example 5
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t5
100 100
100 101
Building a sequential batch
DW
1
2
3
10
a production unit
an end unit
42a simple example 6
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t6
100 100 100
101
Sequential batch step 1/3
DW
1
2
3
10
a production unit
an end unit
43a simple example 7
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t7
100 100 100
101
Sequential batch step 2/3
DW
1
2
3
10
a production unit
an end unit
44a simple example 8
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t8
100
101
100
DW
1
2
3
10
a production unit
an end unit
45a simple example 9
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t9
100 101
100
DW
1
2
3
10
a production unit
an end unit
46a simple example 10
the recipes
WD
the starting sequence
WDW
the continuous sequence (empty)
t10
100
100
DW
1
2
3
10
a production unit
an end unit
47_Casi di applicazione
_______________________________________ Casi di
applicazione ____________________________________
___
48applicazioni
Applicazioni? a situazioni concrete (vere
imprese) a sistemi di imprese allo studio delle
decisioni nelle organizzazioni allo studio della
formazione e trasformazione delle imprese
ricette, unità combinazioni di ricette, di
unità innovazione nelle ricette e nelle
unità
49elenco
Tessile Penelope VIR BasicNet 118
50theoretical goals
Theoretical goals
We have to choose where to ideally situate our
enterprise simulations, on a continuum from the
abstractness of spin glass models to the evidence
and the involvement capability of a videogame
(concreteness) Using a formal environment like
that of jES we can (i) investigate the
entrepreneurship phenomenon, (ii) evaluate the
ICT effects on firm organization and on the
economy as a whole, (iii) simulate enterprise
cases A journey from abstractness to
concreteness, with some guidelines . . . and jES
as a building block
51a building block 1
a building block
useful to create simulation models
of
- the Dynamics of Organizations / ref. A.Lomi and
E.R.Larsen (eds.), 2001, Dynamics of
Organizations Computational Modeling and
Organization Theories, AAAI Press / The MIT
Press, Cambridge, MA
- the Social Structure of Competition / ref.
R.S.Burt, 1992, Structural Holes The Social
Structure of Competition, Harvard University
Press, Cambridge, MA
52a building block 2
- the reproduction of the trial and error process
that generates new enterprises
ref. I.Kirzner (1997), Entrepreneurial discovery
and the competitive market process an Austrian
approach, Journal of Economic Literature, vol.XXXV
, n.1, pp. 60-85 If the Austrian theory claims
that entrepreneurial discovery can account for a
tendency toward equilibrium, that vague-sounding
term tendency toward is used deliberately,
advisedly, and quite precisely. Such a
tendency does exist at each and every moment, in
the sense that earlier entrepreneurial errors
have created profit opportunities which provide
the incentives for entrepreneurial corrective
decisions to be made.
53emerging structures 1
From
an unarticulated structure
units
FE
7
FE
?
?
28
7
27
54emerging structures 2
to
local networks of enterprises and industrial
districts
7
FE
28
7
27
with the emergence of new units, new enterprises
and a new space organization
55finale?
56jES O F
jES Open Foundation
(related to jesopenfoundation-0.1.60.tar.gz, How
to v. 0.0.21)
57_jES?jES O F
_______________________________________ jES
jESOF _______________________________________
58jVE?jES
From jES
java Enterprise Simulator
http//www.flightgear.org/
to jES Open Foundation to simulate multi-model
frameworks of system of units or agents
59_A flexible scheme
_______________________________________ A
flexible scheme in jES Open Foundation ___________
____________________________
60DW a flexible scheme
DW
Units
2
1
1
3
4
on a toroidal space
2
1
Each unit is able to do a specific step
5
(left and right borders and top and bottom ones
are close together)
3
61WD recipes
WD
of a recipe
with the recipes of the orders (what to do)
expressed as sequences of numbers orders with
recipes are randomly generated with different
lengths and structures 1 3 2 4 5 3 4 3 5 1 1
62moving recipes
DW and WD
moving around among units
2
1
1 3 2 4
1
3
1 3 2 4
4
2
1 3 2 4
how to choose
1
?
1 3 2 4
5
3
lack of visibility
Visibility is a metaphorical representation of
trustiness and cooperation in a social network
when global visibility increases, we have more
social capital
63visibility and
Visibility increases with the time (initial
visibility is randomly chosen)
- new units appear randomly (enterprise creation)
- with strategic relationships
- or alone
visibility changes
some units are dropped out
64 bars
The left (blue) bar of each unit reports the
number of waiting orders (do be done)
The right (red) bar of each unit reports the
number of unsent products, due to the fact that a
unit able to do the required step does not exist
or is not visible
The down (grey) bar of each unit reports the
number of consecutive clock ticks in which the
unit has been idle
If gt maxInactivity the unit is dropped out and
all unsent products are lost
If gt maxUnsentProducts the unit is dropped out
and all unsent and waiting products are lost
65jES Open Foundation
jES Open Foundation
recipe generator or distiller
recipe generator or distiller
each unit owns a public matrix
each unit owns a public matrix
recipes
recipes
many levels
The system uses only simple recipes containing
computational steps applied to unit matrixes and
to general matrixs
recipe generator or distiller
built in a parametric way by the Observer
each unit owns a public matrix
recipes
recipe generator or distiller
each unit owns a public matrix
recipes
66Visibility
Visibility between two units
Unit a area
Unit b area
Unit a
Unit b
a cannot see b b can see a
67memory matrixes
Memory matrixes data are reported in a text file
(unitData/memoryMatrixes.txt)
number(from_0_ordered)_rows_cols 0 2 3 1 3
5 2 4 1 3 3 1
Mandatory first line
68computational steps 1/3
Recipes with computations (recipes are reported
in external and intermediate format)
time specification seconds
External format (remember step, time
specification, time)
1 s 1 c 1999 3 0 1 3 2 s 2 3 s 2 1 s 1 c 1998 1
0 5 s 2 1 s 1 c 1998 1 1 6 s 2 1 s 1 c 1998 1 3
7 s 2
step in recipe
a step with computation step 2, requiring 2
seconds, involves computation 1999 with 3
matrixes (those numbered 0, 1, 3 in the previous
Figure)
time in seconds
a step with computation step 7, requiring 2
seconds, involves computation 1998 with 1 matrix
(that numbered 3 in the previous Figure)
Computational steps
Intermediate format (remember each step is
repeated for each unit of time)
1 2 2 -1999 3 0 1 4 1000000002 3 3 1 5 5 -1998
1 0 1000000005 1 6 6 -1998 1 1 1000000006 1 7
7 -1998 1 3 1000000007
after automatic translation, the intermediate
format reports the computational processes with a
trick (which can be modified, adopting an other
translation in OrderDistiller) we imagine here
that the computations require the time reported
in their steps so they are placed at the end of
the time, followed by a 0 time step (at the
intermediate format level, 0 time step are
reported as 1000000000step
69computational steps 2/3
The Java Swarm code used by the recipes with the
example code c 1998
/ computational operations with code -1998 (a
code for the checking phase of the
program this computational code
place a number in position 0,0 of the
unique received matrix and set the status to
done / public void c1998() mm0(Memor
yMatrix) pendingComputationalSpecificationSet.
getMemoryMatrixAddress(0) layerpendingComputa
tionalSpecificationSet. getOrderLayer() mm
0.setValue(layer,0,0,1.0) mm0.print() donetr
ue // end c1998
Computational steps, Java code
70computational steps 3/3
The Java Swarm code used by the recipes with the
example code c 1999
/ computational operations with code -1999
(a code for the checking phase of the
program this computational code
verifies position 0,0 of the three
received matrixes only if these positions are
all not empty the code empties them and
set the status to done / public void
c1999() mm0(MemoryMatrix) pendingComputationalS
pecificationSet. getMemoryMatrixAddress(0)
mm1(MemoryMatrix) pendingComputationalSpecificati
onSet. getMemoryMatrixAddress(1) mm2(Memor
yMatrix) pendingComputationalSpecificationSet.
getMemoryMatrixAddress(2) layerpendingComputa
tionalSpecificationSet. getOrderLayer() if
(! (mm0.getEmpty(layer,0,0) mm1.getEmpty(layer,
0,0)
mm2.getEmpty(layer,0,0) ) )
mm0.setEmpty(layer,0,0) mm1.setEmpty(layer,
0,0) mm2.setEmpty(layer,0,0) donetrue
// end c1999
Computational steps, Java code
71_ preys-predators
_______________________________________ preys-pred
ators _______________________________________
72recipes
Recipes
grassGeneration 1 c 1201 2 0 0 1 s 0
utility 100 c 1100 3 0 1 2 1 s 0
Recipes
preysEating 1 1001 s 0 c 1202 2 1 1 1 s 0
timeStep 23 c 1299 2 1 1 1001 s 0
preysReproducing 4 c 1206 2 1 1 1001 s 0
simple spreadsheets
Recipes
predatorsEating 1 2001 s 0 c 1202 2 2 2 1001 s 0
timeStep 23 c 1299 2 2 2 2001 s 0
predatorsReproducing 4 c 1206 2 2 2 2001 s 0
73sequences
sequence sequence
1 1 50
sequence sequence
1 1 100 23 1 4 100
simple spreadsheets
sequence sequence
1 1 33 23 1 4 33
74units
unit____prod.phase_ 1 1
unit____prod.phase_ 1001 1001
text files
unit____prod.phase_ 2001 2001
75preys-predators 1/5
Tutorial, step3b / time 278, look at the complex
codetermination of grass, preys and predators
76preys-predators 2/5
Tutorial, step3b / time 744, another codetermined
configuration
77preys-predators 3/5
Tutorial, step3b / time 1056, another
codetermined configuration
78preys-predators 4/5
Tutorial, step3b / time 1648, another
codetermined configuration
79preys-predators 5/5
Tutorial, step3b / time 3448, predators
disappeared at 2132, now we have a simplified two
stage model
80_ workers-skills-firms
_______________________________________ workers-sk
ills-firms _______________________________________
81Version 0, no links between firms and workers
82Version 1, new workers with skills equal to that
of their neighbors
83Version 2, new workers with skills randomly
distributed in the stratum space
84Version 3, new workers with skills equal to that
of their neighbors, but arising in unequal
quantities
85Version 4, new workers with skills randomly
distributed in the stratum space, but arising in
unequal quantities
86seguito 1
Lavoro sul tutorial tutorial, seconda versione
(sempre provvisoria), con testo e file preparati
da Staelin, a http//eco83.econ.unito.it/swarm/mat
eriale/jtutorial/JavaTutorial.zip utilizziamo
il file jsimplebug11.doc di 55 pagine, contenuto
nel file .zip, come manuale e come base per i
listati
87seguito 2
(SimpleCBug) (SimpleJavaBug) SimpleJavaBug2 Simp
leSwarmBug NB compare il model SimpleSwarmBug2 Si
mpleSwarmBug3 SimpleObserverBug NB compare
lobserver SimpleObserverBug2 SimpleObserverBug3
SimpleExperBug Più run dellesperimento
Ripartire da qui, prossima volta