Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetroSim
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
Container 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
Julien Pillis
MetroSim
Commits
3a6926e3
Commit
3a6926e3
authored
1 year ago
by
julienpillis
Browse files
Options
Downloads
Patches
Plain Diff
ajout test plusieurs voies
parent
06adc07c
No related branches found
No related tags found
3 merge requests
!14
Merge v2
,
!12
Metro
,
!11
Metro
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/simulation/metro.go
+3
-1
3 additions, 1 deletion
internal/simulation/metro.go
internal/simulation/simu.go
+14
-5
14 additions, 5 deletions
internal/simulation/simu.go
with
17 additions
and
6 deletions
internal/simulation/metro.go
+
3
−
1
View file @
3a6926e3
package
simulation
import
(
"fmt"
"log"
"math/rand"
"time"
...
...
@@ -35,7 +36,8 @@ func (metro *Metro) Start() {
//step = <-metro.syncChan
if
refTime
.
Add
(
metro
.
frequency
)
.
Before
(
time
.
Now
())
{
go
metro
.
pickUpUsers
()
metro
.
freeSpace
=
rand
.
Intn
(
5
)
metro
.
freeSpace
=
rand
.
Intn
(
10
)
fmt
.
Println
(
metro
.
way
.
id
,
metro
.
freeSpace
)
//go metro.dropUsers()
refTime
=
time
.
Now
()
}
...
...
This diff is collapsed.
Click to expand it.
internal/simulation/simu.go
+
14
−
5
View file @
3a6926e3
...
...
@@ -72,7 +72,7 @@ type Simulation struct {
step
int
// Stats
start
time
.
Time
syncChans
sync
.
Map
metro
Metro
metro
s
[]
Metro
}
func
(
sim
*
Simulation
)
Env
()
*
Environment
{
...
...
@@ -93,8 +93,9 @@ func NewSimulation(agentCount int, maxStep int, maxDuration time.Duration) (simu
//simu.env = *NewEnvironment([]Agent{}, playground, mapChan)
// Création du métro
simu
.
metro
=
*
NewMetro
(
10
*
time
.
Second
,
5
*
time
.
Second
,
2
,
&
simu
.
env
,
NewWay
(
1
,
[]
Coord
{{
8
,
5
}}))
metro1
:=
*
NewMetro
(
10
*
time
.
Second
,
5
*
time
.
Second
,
2
,
&
simu
.
env
,
NewWay
(
1
,
[]
Coord
{{
8
,
5
}}))
metro2
:=
*
NewMetro
(
10
*
time
.
Second
,
5
*
time
.
Second
,
2
,
&
simu
.
env
,
NewWay
(
2
,
[]
Coord
{{
13
,
4
}}))
simu
.
metros
=
[]
Metro
{
metro1
,
metro2
}
// création des agents et des channels
for
i
:=
0
;
i
<
agentCount
;
i
++
{
...
...
@@ -109,7 +110,7 @@ func NewSimulation(agentCount int, maxStep int, maxDuration time.Duration) (simu
if
i
%
2
==
0
{
//Type Agent
id
:=
fmt
.
Sprintf
(
"Agent%d"
,
i
)
//NewAgent(id string, env *Environment, syncChan chan int, vitesse time.Duration, force int, politesse bool, behavior Behavior, departure, destination Coord, width, height int)
ag
=
NewAgent
(
id
,
&
simu
.
env
,
syncChan
,
200
,
0
,
true
,
&
UsagerLambda
{},
Coord
{
18
,
4
},
Coord
{
0
,
8
},
1
,
1
)
ag
=
NewAgent
(
id
,
&
simu
.
env
,
syncChan
,
200
,
0
,
true
,
&
UsagerLambda
{},
Coord
{
18
,
4
},
Coord
{
13
,
4
},
1
,
1
)
}
else
{
// Type Controleur
//id := fmt.Sprintf("Controleur%d", i)
id
:=
fmt
.
Sprintf
(
"Agent%d"
,
i
)
...
...
@@ -156,7 +157,15 @@ func (simu *Simulation) Run() {
// On sauvegarde la date du début de la simulation
simu
.
start
=
time
.
Now
()
simu
.
metro
.
Start
()
// Lancement des métros
for
_
,
metro
:=
range
simu
.
metros
{
wg
.
Add
(
1
)
go
func
(
metro
Metro
)
{
defer
wg
.
Done
()
metro
.
Start
()
}(
metro
)
}
// Lancement de l'orchestration de tous les agents
// simu.step += 1 // plus de sens
...
...
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