Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMAC
AMAK
Python
PyAMAK
example
Commits
01d257fb
Commit
01d257fb
authored
4 years ago
by
Jdrezen
Browse files
Options
Downloads
Plain Diff
Merge branch 'limitedChart'
parents
7bec58fb
bc14ee34
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
philosopher_example/controleurPhilosophersExample.py
+20
-20
20 additions, 20 deletions
philosopher_example/controleurPhilosophersExample.py
with
20 additions
and
20 deletions
philosopher_example/controleurPhilosophersExample.py
+
20
−
20
View file @
01d257fb
...
@@ -11,13 +11,12 @@ class ControleurPhilosophersExample(Controleur):
...
@@ -11,13 +11,12 @@ class ControleurPhilosophersExample(Controleur):
self
.
__left
=
[]
self
.
__left
=
[]
self
.
__right
=
[]
self
.
__right
=
[]
self
.
__numberPhilosopher
=
10
self
.
__numberPhilosopher
=
10
self
.
__
barC
hart
=
[]
self
.
__
c
hart
=
[]
self
.
__
barC
hart
.
append
(
self
.
addBarChart
(
'
Eaten Pastas
'
))
self
.
__
c
hart
.
append
(
self
.
addBarChart
(
'
Eaten Pastas
'
))
self
.
__
barC
hart
.
append
(
self
.
addPlotChart
(
'
Hours of tkinking
'
))
self
.
__
c
hart
.
append
(
self
.
addPlotChart
(
'
Hours of tkinking
'
))
self
.
setPolicy
(
self
.
__barChart
[
1
],
0
,
"
ro
"
)
self
.
__chart
.
append
(
self
.
addLimitedPlotChart
(
'
Hours of tkinking (limited)
'
,
5
)
)
self
.
__barChart
.
append
(
self
.
addPlotChart
(
'
Hours of hunger
'
))
self
.
__hoursThinkingMr5
=
0
self
.
addCurve
(
self
.
__barChart
[
2
],
'
g+-
'
)
def
initialisation
(
self
):
def
initialisation
(
self
):
...
@@ -26,17 +25,17 @@ class ControleurPhilosophersExample(Controleur):
...
@@ -26,17 +25,17 @@ class ControleurPhilosophersExample(Controleur):
# Init
# Init
self
.
setTitle
(
self
.
__
barC
hart
[
0
],
'
Eaten Pastas
'
)
self
.
setTitle
(
self
.
__
c
hart
[
0
],
'
Eaten Pastas
'
)
self
.
setXLabel
(
self
.
__
barC
hart
[
0
],
'
Philosophers
'
)
self
.
setXLabel
(
self
.
__
c
hart
[
0
],
'
Philosophers
'
)
self
.
setYLabel
(
self
.
__
barC
hart
[
0
],
'
Number of eaten pastas
'
)
self
.
setYLabel
(
self
.
__
c
hart
[
0
],
'
Number of eaten pastas
'
)
self
.
setTitle
(
self
.
__
barC
hart
[
1
],
'
Hours of thinking
'
)
self
.
setTitle
(
self
.
__
c
hart
[
1
],
'
Hours of thinking
for Mr 4
'
)
self
.
setXLabel
(
self
.
__
barC
hart
[
1
],
'
Philosophers
'
)
self
.
setXLabel
(
self
.
__
c
hart
[
1
],
'
Cycle
'
)
self
.
setYLabel
(
self
.
__
barC
hart
[
1
],
'
Hours
'
)
self
.
setYLabel
(
self
.
__
c
hart
[
1
],
'
Hours
'
)
self
.
setTitle
(
self
.
__
barC
hart
[
2
],
'
Hours of
hunger
'
)
self
.
setTitle
(
self
.
__
c
hart
[
2
],
'
Hours of
thinking for Mr 4 (limited)
'
)
self
.
setXLabel
(
self
.
__
barC
hart
[
2
],
'
Philosophers
'
)
self
.
setXLabel
(
self
.
__
c
hart
[
2
],
'
Cycle
'
)
self
.
setYLabel
(
self
.
__
barC
hart
[
2
],
'
Hours
'
)
self
.
setYLabel
(
self
.
__
c
hart
[
2
],
'
Hours
'
)
self
.
draw_text
(
40
,
15
,
"
EATING
"
)
self
.
draw_text
(
40
,
15
,
"
EATING
"
)
self
.
draw_text
(
40
,
45
,
"
THINKING
"
)
self
.
draw_text
(
40
,
45
,
"
THINKING
"
)
...
@@ -60,25 +59,26 @@ class ControleurPhilosophersExample(Controleur):
...
@@ -60,25 +59,26 @@ class ControleurPhilosophersExample(Controleur):
nom
=
'
Mr
'
+
str
(
i
)
nom
=
'
Mr
'
+
str
(
i
)
self
.
addColumn
(
self
.
__
barC
hart
[
0
],
nom
)
self
.
addColumn
(
self
.
__
c
hart
[
0
],
nom
)
def
updateWindow
(
self
,
env
,
amas
):
def
updateWindow
(
self
,
env
,
amas
):
agents
=
amas
.
get_Agents_Sorted
()
agents
=
amas
.
get_Agents_Sorted
()
self
.
addPoint
(
self
.
__barChart
[
1
],
0
,
amas
.
get_cycle
(),
randint
(
0
,
100
))
self
.
addPoint
(
self
.
__chart
[
1
],
0
,
amas
.
get_cycle
(),
self
.
__hoursThinkingMr5
)
self
.
addPoint
(
self
.
__barChart
[
2
],
0
,
amas
.
get_cycle
(),
randint
(
0
,
100
))
self
.
addPoint
(
self
.
__chart
[
2
],
0
,
amas
.
get_cycle
(),
self
.
__hoursThinkingMr5
)
self
.
addPoint
(
self
.
__barChart
[
2
],
1
,
amas
.
get_cycle
(),
randint
(
0
,
100
))
for
i
in
range
(
10
):
for
i
in
range
(
10
):
state
=
agents
[
i
].
get_state
()
state
=
agents
[
i
].
get_state
()
if
state
==
State
.
EATING
:
if
state
==
State
.
EATING
:
self
.
change_color
(
self
.
__philosophers
[
i
],
'
green
'
)
self
.
change_color
(
self
.
__philosophers
[
i
],
'
green
'
)
self
.
increaseValue
(
self
.
__
barC
hart
[
0
],
i
,
1
)
self
.
increaseValue
(
self
.
__
c
hart
[
0
],
i
,
1
)
elif
state
==
State
.
HUNGRY
:
elif
state
==
State
.
HUNGRY
:
self
.
change_color
(
self
.
__philosophers
[
i
],
'
red
'
)
self
.
change_color
(
self
.
__philosophers
[
i
],
'
red
'
)
else
:
else
:
self
.
change_color
(
self
.
__philosophers
[
i
],
'
blue
'
)
self
.
change_color
(
self
.
__philosophers
[
i
],
'
blue
'
)
if
(
i
==
5
):
self
.
__hoursThinkingMr5
+=
1
coords
=
self
.
get_coords_element
(
self
.
__philosophers
[
i
])
coords
=
self
.
get_coords_element
(
self
.
__philosophers
[
i
])
if
agents
[
i
].
get_Left_Fork
().
owned
(
agents
[
i
]):
if
agents
[
i
].
get_Left_Fork
().
owned
(
agents
[
i
]):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment