Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyAmak - noyau
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
pyAmak - noyau
Commits
be3113ca
Commit
be3113ca
authored
4 years ago
by
shinedday
Browse files
Options
Downloads
Patches
Plain Diff
Add seed
parent
3256ff05
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyAmakCore/classes/environment.py
+7
-5
7 additions, 5 deletions
pyAmakCore/classes/environment.py
pyAmakCore/tests/seed/main.py
+0
-54
0 additions, 54 deletions
pyAmakCore/tests/seed/main.py
with
7 additions
and
59 deletions
pyAmakCore/classes/environment.py
+
7
−
5
View file @
be3113ca
...
...
@@ -16,14 +16,16 @@ class Environment(Schedulable):
Environment class
"""
def
__init__
(
self
)
->
None
:
self
.
set_seed
()
def
__init__
(
self
,
seed_int
:
int
=
None
)
->
None
:
self
.
set_seed
(
seed_int
)
super
().
__init__
()
self
.
on_initialization
()
def
set_seed
(
self
):
def
set_seed
(
self
,
number
):
"""
This method set the seed for all random in the system, it should be override to set a custom seed
"""
seed
()
if
number
is
None
:
seed
()
return
seed
(
number
)
This diff is collapsed.
Click to expand it.
pyAmakCore/tests/seed/main.py
deleted
100644 → 0
+
0
−
54
View file @
3256ff05
from
random
import
randint
,
seed
from
time
import
sleep
from
pyAmakCore.classes.amas
import
Amas
from
pyAmakCore.classes.environment
import
Environment
from
pyAmakCore.classes.agent
import
Agent
from
pyAmakCore.exception.override
import
ToOverrideWarning
class
SimpleAgent
(
Agent
):
"""
test
"""
def
on_act
(
self
)
->
None
:
print
(
randint
(
0
,
100
))
class
SimpleAmas
(
Amas
):
"""
test
"""
def
on_initialization
(
self
)
->
None
:
ToOverrideWarning
.
enable_warning
(
False
)
def
on_initial_agents_creation
(
self
)
->
None
:
for
i
in
range
(
10
):
self
.
add_agent
(
SimpleAgent
(
self
))
def
on_cycle_begin
(
self
)
->
None
:
pass
# print(randint(0, 100))
def
on_cycle_end
(
self
)
->
None
:
if
self
.
get_cycle
()
==
30
:
sleep
(
300
)
class
SimpleEnv
(
Environment
):
"""
test
"""
def
set_seed
(
self
):
seed
(
30
)
env
=
SimpleEnv
()
amas
=
SimpleAmas
(
env
)
amas
.
put_token
()
amas
.
start
()
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