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
a5d3eb7d
Commit
a5d3eb7d
authored
1 year ago
by
julienpillis
Browse files
Options
Downloads
Patches
Plain Diff
ajout passages multiples
parent
fc8060d4
No related branches found
Branches containing commit
No related tags found
3 merge requests
!14
Merge v2
,
!12
Metro
,
!11
Metro
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
internal/simulation/metro.go
+6
-3
6 additions, 3 deletions
internal/simulation/metro.go
internal/simulation/simu.go
+5
-1
5 additions, 1 deletion
internal/simulation/simu.go
internal/simulation/way.go
+8
-0
8 additions, 0 deletions
internal/simulation/way.go
with
19 additions
and
4 deletions
internal/simulation/metro.go
+
6
−
3
View file @
a5d3eb7d
...
...
@@ -2,6 +2,7 @@ package simulation
import
(
"log"
"math/rand"
"time"
)
...
...
@@ -12,9 +13,10 @@ type Metro struct {
gates
[]
Coord
//listes des portes du métro
env
*
Environment
comChannel
chan
Request
way
WayID
}
func
NewMetro
(
freq
time
.
Duration
,
stopT
time
.
Duration
,
freeS
int
,
gates
[]
Coord
,
env
*
Environment
)
*
Metro
{
func
NewMetro
(
freq
time
.
Duration
,
stopT
time
.
Duration
,
freeS
int
,
gates
[]
Coord
,
env
*
Environment
,
wayNumber
WayID
)
*
Metro
{
return
&
Metro
{
frequency
:
freq
,
stopTime
:
stopT
,
...
...
@@ -22,6 +24,7 @@ func NewMetro(freq time.Duration, stopT time.Duration, freeS int, gates []Coord,
gates
:
gates
,
env
:
env
,
comChannel
:
make
(
chan
Request
),
way
:
wayNumber
,
}
}
...
...
@@ -33,8 +36,8 @@ func (metro *Metro) Start() {
for
{
//step = <-metro.syncChan
if
refTime
.
Add
(
metro
.
frequency
)
.
Before
(
time
.
Now
())
{
//defer func() { refTime = time.Now() }()
go
metro
.
pickUpUsers
()
metro
.
freeSpace
=
rand
.
Intn
(
5
)
//go metro.dropUsers()
refTime
=
time
.
Now
()
}
...
...
@@ -61,7 +64,7 @@ func (metro *Metro) pickUpGate(gate *Coord) {
gate_cell
:=
metro
.
env
.
station
[
gate
[
0
]][
gate
[
1
]]
if
len
(
gate_cell
)
>
1
{
agent
:=
metro
.
findAgent
(
AgentID
(
gate_cell
))
if
agent
!=
nil
&&
agent
.
width
*
agent
.
height
<=
metro
.
freeSpace
{
if
agent
!=
nil
&&
agent
.
width
*
agent
.
height
<=
metro
.
freeSpace
&&
agent
.
destination
==
*
gate
{
metro
.
env
.
agentsChan
[
agent
.
id
]
<-
*
NewRequest
(
metro
.
comChannel
,
Disappear
)
metro
.
freeSpace
--
}
...
...
This diff is collapsed.
Click to expand it.
internal/simulation/simu.go
+
5
−
1
View file @
a5d3eb7d
...
...
@@ -87,9 +87,13 @@ func NewSimulation(agentCount int, maxStep int, maxDuration time.Duration) (simu
// Communication entre agents
mapChan
:=
make
(
map
[
AgentID
]
chan
Request
)
// Création de l'environement
simu
.
env
=
*
NewEnvironment
([]
Agent
{},
carte
,
mapChan
)
//simu.env = *NewEnvironment([]Agent{}, playground, mapChan)
simu
.
metro
=
*
NewMetro
(
10
*
time
.
Second
,
5
*
time
.
Second
,
2
,
[]
Coord
{{
8
,
5
}},
&
simu
.
env
)
// Création du métro
simu
.
metro
=
*
NewMetro
(
10
*
time
.
Second
,
5
*
time
.
Second
,
2
,
[]
Coord
{{
8
,
5
}},
&
simu
.
env
,
1
)
// création des agents et des channels
for
i
:=
0
;
i
<
agentCount
;
i
++
{
...
...
This diff is collapsed.
Click to expand it.
internal/simulation/way.go
0 → 100644
+
8
−
0
View file @
a5d3eb7d
package
simulation
type
Way
struct
{
id
WayID
gates
[]
Coord
//listes des portes du métro
}
type
WayID
int
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