(ses) system entity structure
TRANSCRIPT
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 1
(SES) System Entity Structure
One of Knowledge Representation scheme
Other knowledge representation schemes:
Semantic net, production rules, logic expression, scripts, etc.
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 2
The System Entity
Structure/Model Base (SES/MB) framework
ABC
AB C
C1 C2
AB
A B
ENITY STRUCUTRE BASE MODEL BASE
A
B
C
D
KNOWLEDGE BASE
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 3
SES :
- specify hierarchical models and organize them
for reuse from an archival model base
- forms enbase (entity structure base) within the
devs knowledge-base
Supports three relationships:
decomposition (aspect), taxonomy (specialization),
and coupling (multiple decomposition)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 4
SES for life support systemLSS
LSS mission
length spec
Short
Duration
Mission
LSS
Medium
Duration
Mission
LSS
Physical
Chemical
LSS
Biological
LSS
bio–spec
Bioregenerative
LSS
Other
LSS
Hybrid
LSS
hybrid–dec
Medium
Duration
Mission
LSS
LSS – spec
Physical
Chemical
LSS
Biological
LSS
Resupply
Schedules
Expendables
Resupply
System
exp – dec
Radiation
Protection
System
Resupply
Transport
Vehicles
Resupply
Payloads
Computer &
Communication
System
Life
Elements
System
life – dec
Microbes
Humans
Plants
Soil
Energy
Supply
System
energy – spec
Solar
ESSNuclear
ESS
Waste
Management
System
Waste – spec
Biological
Waste
Decomposition
System
Mechanical
WMS
Chemical
Waste
Treatment
System
…LSS – dec
Fire
Control
System
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 5
Lighting
System
Environment
Control
System
ECS – dec
Natural
Light Source
lighting – dec
Water
Maintenance
System
Electrical
Light
art – spec
Air
Maintenance
System
…
Temperature
Control
System
Artificial
Light Source
Radio
Isotope
Light
Food
Supply
System
food – sup –spec
Limited
Cultivation
FSSAgro
Ecological
FSS
food – sup –dec
Food
Storage
System
Food
Production
System
food – prod –dec
Growth
Medium
gm – spec
Soil –based
GM
Harvest
System
Hydroponic
GM
Plant Waste
Recycle
System
pwr – spec
Microbial
Based
PWRSMechanical
Chemical
Disposal
PWRS
Nutrient
Supply
System
SES for life support system
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 6
Pruned system entity structure for long
duration mission using bioregenerative LSS
Long Duration
Bioregenerative
LSS
LSS – dcc
Computer &
Communication
System
Expendables
Resupply
System
*
Fire
Control
System
Solar Energy
Supply System
Life
Elements
System
life – dcc
Microces
Humans
Plants
Soil
Biological
Waste
Decomposition
System
Radiation
Protection
System
Lighting
System
Environment
Control
System
ECS – dec
Natural
Light Source
lighting – dec
Water
Maintenance
System
Air
Maintenance
System
Temperature
Control
System
Radio
Isotope
Light
Source
Agro – Ecological
Food Supply
System
food – sup – dec
Food
Storage
System
Food
Production
System
food – prod – doc
Hydroponic
Growth Medium
Microbial
Plant Waste
Recycle System
Nutrient
Supply
SystemHarvest
System
* Pruned by constraint rules
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 7
Decomposition: for representing the manner in
which an object is decomposed into components
Taxonomy: for organizing the different kinds of objects,
i.e., how they can be categorized and subclassified
Coupling: for representing how models are coupled
together and what constraints apply to component combinations
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 8
SES Example
Computer
technologyspecialization
Wafer VLSI
class-specialization
Hybrid
Analog Digital
part-decomposition
physical-decomposition
CPUMemory
I/O-Devices
I/O-Device
OperationSystem
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 9
SES Definitions and Axioms (1)
SES is defined as labeled tress with attached variable types
which satisfies the following axioms:
1. uniformity: any two nodes have the same labels have identical attached variable
types and isomorphic subtrees
2. strict hierarchy: No label appears more than once down any path of the tree
3. alternating mode: Each node has a mode which is either entity, aspect, or specialization
; if mode of a node is entity then its successors are aspect or specialization,
if the mode aspect or specialization then its successors are entity.
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 10
4. valid brothers: no two brothers have the same label
5. Attached variables: no two variable types attached to the same item have
the same name
6. Inheritance: every entity in a specialization inherits all the variables, aspects
and specializations from the parent of the specialization
SES Definitions and Axioms (2)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 11
EF
EF-Dec
GENR TRANSD
EF-Dec:
Coupling: ((GENR TRANSD (OUT. ARIV))
(GENR EF (OUT.OUT))
(TRANSD GENR (OUT.STOP))
(TRANSD EF (OUT.RESULT))
(EF TRANSD (IN.SOLVED))
Entity structure for experimental frame component
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 12
;; ef.a
;; make an entity structure with root EF
(make-entstr ’ef)
;; add an aspect for decomposition
(add-item e:ef asp ’ef-dec)
;; experimental frame consists of generator and transducer
(set-current-item e:ef ’ef-dec)
(add-item e:ef ent ’transd)
(add-item e:ef ent ’genr)
;coupling----------------------------------------------------
(add-couple e:ef ’ef ’transd ’in ’solved)
(add-couple e:ef ’transd ’ef ’out ’result)
(add- couple e:ef ’transd ’genr ’out ’stop)
(add- couple e:ef ’genr ’ef ’out ’out)
(add- couple e:ef ’genr ’transd ’out ’ariv)
;save e:ef in a file ef ef.e
(save-en e:ef)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 13
EF-P
EF-P-Dec
P EF
EF-P-Dec:
coupling: ((EF EF-P (RESULT.OUT))
(EF P (OUT.IN))
(P EF (OUT.IN))
Entity structure for EF-P
priority list: (P EF)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 14
EF-P
EF-P-Dec
P EF
Entity structure for EF-P
EF-P-Dec:
coupling: ((EF EF-P (RESULT.OUT))
(EF P (OUT.IN))
(P EF (OUT.IN))
priority list: (P EF)
EF-Dec
GENR TRANSD
EF-Dec:coupling: ((GENR TRANSD (OUT. ARIV))
(GENR EF (OUT.OUT))
(TRANSD GENR (OUT.STOP))
(TRANSD EF (OUT.RESULT))
(EF TRANSD (IN.PROC))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 15
Simulating directly from SES of EF-P
;; load the entity structure
(load-entstr e:ef-p) or (load “enbase/ef-p.s”)
;; transform it into a hierarchical model and initialize it
;; with a root-co-ordinatior r:ef-p
(transform e:ef-p)
;; start a simulation run
(restart r:ef-p)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 16
System Entity Structure Organization of Model Base
scheme directory: scheme
DEVS-scheme directory: /scheme/devs
domain directory: /scheme/devs/simparc
model base directory: /scheme/devs/simparc/mbase
entity structure directory: /scheme/devs/simparc/enbase
For entering into devs-scheme: /scheme/devs/simparch/pcs
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 17
SES/Model Base for Simple Architectures
p.m
mul-c.m
pip-c.m
dc-c.m
genr.m
transd.m
model base directory:
/scheme/devs/simparc/mbase files:
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 18
entity structure directory:
scheme/devs/simparc/enbase files:
ef-a.s
ef-a.e
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 19
SES for simple architecture studyEF-A
ef-a-dec
Arch
arch-spec
P Mul-Arch Pip-Arch DC-Arch
mul-arch-dec pip-arch-dec dc-arch-dec
Mul-C P1 P2 P3 Pip-C P1 P2 P3
P&DIV P1 P2 P3 P&CMPL DC-C
EF
ef-dec
GENR TRANSD
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 20
EF-A-DEC: priority list: (EF ARCH)
coupling: ((EF EF-A (RESULT.OUT)) …)
EF-DEC: coupling ((GENR TRANSD (OUT.ARIV)) …)
MUL-ARCH-DEC: priority list: (P1 P2 P3 MUL-C)
coupling : ((P3 MUL-C (OUT.Y3)) …)
PIP-ARCH-DEC: priority list: (P3 P2 P1 PIP-C)
coupling: ((P3 PIP-C (OUT.Y3)) …)
DC-ARCH-DEC: priority list: (P&CMPL P3 P2 P1 P&DIV DC-C)
coupling: ((P&CMPL DC-C (OUT.CY)) …)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 21
PES (Pruned Entity Structure) of Divide&Conquer Architecture
EF-A
ef-a-dec
DC-Arch
dc-arch-dec
P&DIV P1 P2 P3 P&CMPL DC-C
EF
ef-dec
GENR TRANSD
EF-A-DEC: priority list, coupling
EF-DEC: coupling
DC-ARCH-DEC: priority list, coupling
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 22
Simulation using System Entity Structure of EF-A
(prune e:ef-a)
SES e:ef-a
PES p:ef-a@dc
(transform p:ef-a@dc)
DEVS Model ef-a
(restart r:ef-a)
(load “enbase/ef-a.s”) or (load-entstr e:ef-a)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq atomic Model(1)
pq
in out
sigma phase job-id p.tqueue
default
∞ passive ’( ) ’( ) 10
• model diagram
23
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
• timing diagram
t
t
t
X
S
Y g1
g1
passive
intext
in
out
g2 g3
g2 g3
int int
6 4 42
Busy 10 Busy 10 Busy 10
in in
out out
passive
0
0
0
(phase)
ext ext
pq atomic Model(2)
24
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq atomic Model(3-1)
• model definition (code)
(make-pair atomic-models ’pq)
(send pq def-state ’( job-id
queue
processing-time)
)
(send pq set-s
(make-state ’sigma ’inf
’phase ’passive
’job-id ’()
’queue ’()
’processing-time 10)
)25
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq atomic Model(3-2)(define (ext-pq s e x)
(case (content-port x)
(’in (case (state-phase s)
(’passive (set! (state-job-id s) (content-value x))
(hold-in ’busy (state-processing-time s))
)
(’busy (set! (state-queue s)
(append (state-queue s)
(list (content-value x))
) )
(continue)
)
);case
);’in
) ) 26
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq atomic Model(3-3)
(define (int-pq s)
(case (state-phase s)
(’busy
(if (null? (state-queue s))
(passivate)
(begin
(set! (state-job-id s) (car (state-queue s)))
(set! (state-queue s) (cdr (state-queue s)))
(hold-in ’busy (state-processing-time s))
)
);if
)
))
27
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
(define (out-pq s)
(case (state-phase s)
(’busy
(make-content ’port ’out ’value (state-job-id s))
)
(else (make-content))
))
(send pq set-ext-transfn ext-pq)
(send pq set-int-transfn int-pq)
(send pq set-outputfn out-pq)
pq atomic Model(3-4)
28
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq
pq coupled Model(1)
• model diagram
in out
q
outdone
p
in out
29
in
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 30
PES for coupling P to Q for PQ
coupling : ( (Q P (OUT .IN))
(P PQ (OUT .OUT))
(P Q (OUT .DONE))
(PQ Q (IN. IN)) )
PQ-DEC:PQ
pq-dec
P Q
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(2)• timing diagram
t
𝑋𝑝𝑞
0
t
𝑞(𝑝ℎ𝑎𝑠𝑒)
0
t0
t0
𝑝(𝑝ℎ𝑎𝑠𝑒)
𝑌𝑝𝑞
g1
ing2
in
passive passive
passive
busy(g1) busy(g2)
passive
send send
passive
passive
g1
outg2
out
10
𝑒𝑥𝑡 𝑖𝑛𝑡 𝑒𝑥𝑡 𝑖𝑛𝑡
𝑒𝑥𝑡(𝑑𝑜𝑛𝑒, 𝑔1)
𝑖𝑛𝑡
10
𝑒𝑥𝑡(𝑖𝑛, 𝑔1)
𝑒𝑥𝑡(𝑖𝑛, 𝑔2)
𝑖𝑛𝑡
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
p Model
• model diagram
∞ passive ’( ) 10
p
in out
sigma phase job-id processing-time
default
32
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-1)
• model definition (code)
* atomic-models p
(make-pair atomic-models 'p)
(send p def-state '(job-id pt))
(send p set-s
(make-state 'sigma 'inf
'phase 'passive
'job-id '()
’pt 10
)
)33
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-2)(define (ext-p s e x)
(case (content-port x)
('in
(case (state-phase s)
('passive
(set! (state-job-id s) (content-value x))
(hold-in ‘busy (state-pt s)))
(else (continue))
))))
(define(int-p s)
(case (state-phase s)
(‘busy (passivate))
))34
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-3)
(define (out-p s)
(case (state-phase s)
(‘busy (make-content 'port 'out 'value (state-job-id s)))
(else (make-content))
)
)
(send p set-ext-transfn ext-p)
(send p set-int-transfn int-p)
(send p set-outputfn out-p)
35
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
q Model
• model diagram
∞ passive ’( ) ’( ) passive
q
in out
sigma phase job-id
default
queue p-state
36
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-4)
* atomic-models q
(send q def-state '(job-id queue p-state))
(send q set-s
(make-state 'sigma 'inf
'phase 'passive
'job-id '()
‘queue ’()
‘p-state ’passive
)
)
37
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-5)(define (ext-q s e x)
(case (content-port x)
('in
(case (state-phase s)
('passive
(case (state-p-state s)
(‘passive ;; p is passive
(set! (state-job-id s) (content-value x))
(hold-in ‘send 0)
)
(else ;; p is busy
(set! (state-queue s) (append (state-queue s) (content-value x)))
(continue)
)
)
)
(else (continue)) ;; q phase is send
)
) 38
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-6)(‘done
(if (null? (state-queue s))
(begin
(set! (state-p-state s) ‘passive)
(continue)
)
(begin
(set! (state-job-id s) (car (state-queue s)))
(set! (state-queue s) (cdr (state-queue s)))
(set! (state-p-state s) ‘busy)
(hold-in ‘send 0)
)))))
(define(int-q s)
(case (state-phase s)
(‘send (passivate))
))
39
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved.
pq coupled Model(3-7)
(define (out-q s)
(case (state-phase s)
(‘send
(make-content 'port 'out 'value (state-job-id s))
)
(else (make-content))
))
(send q set-ext-transfn ext-q)
(send q set-int-transfn int-q)
(send q set-outputfn out-q)
40
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 41
Selective Interruptible Processor
• model diagram
∞ passive
sigma phasetime-
remainingjob-id
in solved
unsolved
special
1
SIP
tempprocessor-
leveltransfer-time max-level
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 42
Selective Interruptible Processor• timing diagram
t0
3
‘(g1 5 1)
in
‘(g2 5 1)
in
t0
passive
int
t0
unsolved
busytransfer
busypassive
2
1
ext
ext int
solved
‘(g2 5 2) g1
Processor-level = 1
Max-level = 3
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 43
t0
3
‘(g1 5 2)
in
‘(g2 5 2)
in
t0
passive
int
t0
special
busytransfer
busypassive
2
1
ext
ext int
solved
‘(g2 5 3) g1
Selective Interruptible Processor• timing diagram Processor-level = 2
Max-level = 3
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 44
Selective Interruptible Processor
Accepts problems for processing only under certain conditions.
(make-pair atomic-models ’sip)
(send sip def-state
’(time-remaining job-id temp processor-level transfer-time max-level))
(send sip set-s (make-state
’sigma ’inf
’phase ’passive
’transfer-time 1))
Accepts when
passive: problem-level >= processor-level
busy: problem-level = processor-level
(just transfers by increasing problem-level by 1)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 45
(define (ext-sip s e x)
(let* ((val (content-value x)) (job-id (car val)) (processing-time (cadr val)) (problem-level (caddr val)))
(case (content-port x)
(’in
(case (state-phase s)
(’passive (when (>= problem-level (state-processor-level s))
(set! (state-job-id s) job-id)
(set! (state-time-remaining s) processing-time)
(hold-in ‘busy processing-time)))
(’busy (if (= problem-level (state-processor-level s))
(begin (set! (state-temp s) x)
(set! (state-time-remaining s) (- (state-time-remaining s) e))
(hold-in ’transfer (state-transfer-time s)))
(continue)))
(’transfer (continue))))
(’else (bkpt “error: invalid input port” (content-port x))))))
Selective Interruptible Processor
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 46
(define (int-sip s)
(case (state-phase s)
(’busy (passivate))
(’transfer (hold-in ’busy (state-time-remaining s)))
(else (continue))))
Selective Interruptible Processor
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 47
Selective Interruptible Processor(define (out-sip s)
(case (state-phase s)
(’busy (make-content ’port ’solved ’value (state-job-id s)))
(’transfer (let* ( (val (content-value (state-temp s)))
(job-id (car val)) (processing-time (cadr val))
(problem-level (caddr val)))
(set! (content-value (state-temp s))
(list job-id processing-time (+1 problem-level)))
(set! (content-port (state-temp s))
(if (< problem-level (state-max-level s))
’unsolved
’special))
(state-temp s)))
(else (make-content))))
(send sip set-int-transfn int-sip)
(send sip set-ext-transfn ext-sip)
(send sip set-outputfn out-sip)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 48
Alternative design for the problem acceptance behavior
The acceptance decisions are now made by ACT-BUF
PEL
ACT-BUF P
inin
unsolved
special
unsolved
outdone in
special
solvedsolved
to other PELs
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 49
PES for coupling ACT-BUF to P for PEL
PEL
pel-dec
ACT-BUF P
PEL-DEC:coupling : ( (ACT-BUF P (OUT .IN))
(ACT-BUF PEL (UNSOLVED .UNSOLVED))
(ACT-BUF PEL (SPECIAL .SPECIAL))
(P ACT-BUF (SOLVED .DONW))
(P PEL (SOLVED .SOLVED))
(PEL ACT-BUF (IN .IN)) )
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 50
Active Buffer Model
• model diagram
sigma phase job-id p-free
tempprocessor-
level
transfer-
timemax-level
ACT-BUF
∞ passive ’( ) #T
’( ) 1 1 5
in
done
out
unsolved
special
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 51
Active Buffer Model
(make-pair atomic-models ‘act-buf)
(send act-buf def-state ‘(p-free temp processor-level transfer-time max-level)
(send act-buf set-state (make-state
’sigma ’inf
’phase ’passive
’p-free #T
’temp ’()
’processor-level 1 ;all the inputs are accepted’
’transfer-time 1
’max-level 5 ; maximum transferable problem level
))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 52
Active Buffer Model(define (ext-ab s e x)
(set! (state-temp s) x)
(case (content-port x)
(’in (let* ( (val (content-value x)) (problem-level (caddr val)) )
(case (state-phase s)
(’passive (if (state-p-free s)
(when (>= problem-level (state-processor-level s) ;; case passive of sip
(hold-in ‘send 0)
)
(when (= problem-level (state-processor-level s)) ;; case busy of sip
(hold-in ’transfer (state-transfer-time s)))))
(’send (continue))
(’transfer (continue))
)))
(’done (set! (state-p-free s) #!true)
(case (state-phase s)
(‘transfer (hold-in ’send 0))
(else (continue))))
(else (bkpt “error: invalid input port” (content-port x)))))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 53
(define (int-ab s)
(when (equal? (state-phase s) ‘send)
(set! (state-p-free s) #!false)
)
(passivate)
)
Active Buffer Model
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 54
(define (out-ab s)
(case (state-phase s)
(’send (set! (content-port (state-temp s)) ’out)
(state-temp s))
(’transfer (let* ( (val (content-value (state-temp s))
(job-id (car val))
(processing-time (cadr val))
(problem-level (caddr val))); let*
(set! (content-value (state-temp s))
(list job-id processing-time (1+ problem-level)))
(set! (content-port (state-temp s))
(if (<problem-level (state-max-level s))
’unsolved
’special))
(state-temp s))) ;’transfer
(else (make-content))))
Active Buffer Model
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 55
(send act-buf set-int-transfn int-ab)
(send act-buf set-ext-transfn ext-ab)
(send act-buf set-outputfn out-ab)
Active Buffer Model
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 56
• model diagram
Processor P
sigma phase job-idprocessing-
time
P
∞ passive ’( )
in solved
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 57
Processor P
(make-pair atomic-models ’p)
(send p def-state ’job-id))
(send p set-s (make-state ’sigma ’inf ’phase ’passive ’job-id ’()))
(define (ext-p s e x)
(let* ( (val (content-value x))
(job-id (car val))
(processing-time (cadr val)))
(case (content-port x)
(’in (case (state-phase s)
(’passive (set! (state-job-id s) job-id)
(hold-in ‘busy processing-time))
(else (bkpt “input received when not passive” val))))
(else (bkpt “error: invalid input port” (content-port x))))))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 58
(define (int-p s)
(passivate)
)
(define (out-p s)
(case (state-phase s)
(’busy (make-content ’port ’solved
’value (state-job-id s)))))
(send p set-int-transfn int-p)
(send p set-ext-transfn ext-p)
(send p set-outputfn out-p)
Processor P
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 59
Model/Frame pair for broadcast architecture
Accepts when
passive: problem-level >= processor-level
busy: problem-level = processor-level
(just transfers by increasing problem-level by 1)
ARCH+EX
PARCH
EXP
in
unsolved
out
solved
P1 P2 P3 P4
G A Tout
result
result
solvedproc
genaccacc
out
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 60
Generator Model(make-pair atomic-models ’generator)
(send generator def-state ’(
;;state-variable
;;parameter
interarrival-time
processing-time
problem-level
)
)
(send generator set-s
(make-state ’sigma 0 ’phase ’busy
’interarrival-time 5
’processing-time 10 ’problem-level 1
))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 61
Generator Model(define (int-g s)
(case (state-phase s)
(’busy
(hold-in ’busy (expon (state-interarrival-time s) 1)))
(else (passivate))
))
(define (out-g s)
(make-content ’port ’out
’value (list (gensym)
(expon (state-processing-time s) 2)
(state-problem-level s))
))
(send generator set-int-transfn int-g)
(send generator set-outputfn out-g)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 62
Transducer Model
(make-pair atomic-models ’transducer)
(send transducer def-state ’(sigma phase arrived-list solved-list
multiple-solved-list clock report-time
total-ta))
(send transducer set-s (make-state ’sigma 0 ’phase ’active
’arrived-list ’() ’solved-list ’()
’multiple-solved-list ’() ’clock 0
’report-time 200 ’total-ta 0))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 63
Transducer Model(define (ext-t s e x)
(let ((problem-id (content-value x)))(set! (state-clock s) (+ (state-clock s) e))(case (content-port x)
(’gen (set! (state-arrived-list s)(cons (list problem-id (state-clock s))
(state-arrived-list s))))(’proc (cond
((member problem-id (state-multiple-solved-list s)) ’())((member problem-id (state-solved-list s))(set! (state-multiple-solved-list s)
(cons problem-id (state-multiple-solved-list s))))((assoc problem-id (state-arrived-list s))(set! (state-total-ta s)
(+ (state-total-ta s)(- (state-clock s)
(cdar (assoc problem-id (state-arrived-list s))
))))(set! (state-solved-list s)
(cons problem-id (state-solved-list s))))))(else
(bkpt “error: invalid input port name -->” (content-port x))))(continue)
))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 64
Transducer Model(define (int-t s)
(case (state-phase s)(’active (set! (state-clock s) (+ (state-clock s) (state-sigma s)))
(hold-in ’temp 0))(’temp (hold-in ’active (state-report-time s)))(else (passivate))
))
(define (out-t s)(case (state-phase s)
(’active (make-content ’port ’out ’value (list
;average turn-around time(if (NULL? (state-solved-list s))
‘nil(/ (state-total-ta s) (length (state-solved-list s))))
;throughput(if (= (state-clock s) 0)
‘nil(/ (length (state-solved-list s)) (state-clock s)))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 65
Transducer Model;percentage of unsolved-packets
(if (NULL? (state-arrived-list s))‘nil(/ (- (length (state-arrived-list s))
(length (state-solved-list s)))(length (state-arrived-list s))))
;percentage of multiple-solved packets(if (NULL? (state-arrived-list s))
‘nil(/ (length (state-multiple-solved-list s))
(length (state-solved-list s)))))))(’temp (make-content ’port ’acc ’value
(list (state-clock s)(length (state-arrived-list s))))))
(else (make-content ’port ’dum ’value ’()))))
(send transducer set-ext-transfn ext-t)(send transducer set-int-transfn int-t)(send transducer set-outputfn out-t)
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 66
Acceptor Model
(make-pair atomic-models ’acceptor)
(send acceptor def-state ’(observation-packet
observation-time))
(send acceptor set-s (make-state ’sigma ’inf ’phase ’passive
’observation-packet 8 ’observation-time 500))
(send acceptor set-ext-transfn (lambda(s e x)
(case (content-port x)
(’acc (if (or (> (car (content-value x)) ;; local clock of transducer
(state-observation-time s))
(> (cadr (content-value x)) ;; solved list length of transducer
(state-observation-packet s)))
(set! Pause #!true)))
)))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 67
Activity
decomposition
Before –
Output
Condition Action
After –
Output
specialization
Internal External
Structure of an activity
Forward Models
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 68
external activity:
R1. if phase is wait–for–info
and receive x on port motion–info
then record value of x as current position
and hold in phase active for 1 unit
internal activities:
R2. if phase is active
and need help in executing task
then send out request for help
and passivate in wait–for–help
R3. if phase is active
then send to port ’starting
and hold–in working for 100 units
and send to port ’finished
R4. if phase is working
then passivate
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 69
(make–pair forward–models ’assistance–requestor)
(send assistance–requestor def–state ’(need–help position))
(send assistance–requestor set–s ’(make–state ’sigma ’inf ’interpreter–phase ’test–condition
’phase ’wait–for–info))
(send assistance–requestor add–ext–activities
(list
;;;R1:
(make–activity
’condition ’(and
(equal? (content–port x) ’motion–info)
(equal? (state–phase s) ’wait–for–info)
)
’action ’(begin
(set! (state–position s)
(car (content–value x)))
(hold–in ’active 1)
))))
Sungkyunkwan University
Computer Engineering
Copyright (c) 2015 Intelligence Modeling Lab. All rights reserved. 70
(send assistance–requestor add–int–activities
(list
;;;R2:
(make–activity
’condition ’(and (equal? (state–phase s) ’active) (state–need–help s))
’before–output ’(make–content ’port ’ask–for–help ’value (state–position s))
’action ’(passivate–in ’wait–for–help)
)
;;;R3:
(make–activity
’condition ’(equal? (state–phase s) ’active)
’before – output ’(make–content ’port ’starting)
’action ’(hold–in ’working 100)
’after – output ’(make–content ’port ’finished)
)
;;;R4:
(make–activity
’condition ’(equal? (state–phase s) ’working)
’action ’(passivate)
) ) )