Skip to content

Commit 7b555ca

Browse files
author
keorn
authored
Merge branch 'master' into abstract-put
2 parents 480460c + 414e329 commit 7b555ca

13 files changed

Lines changed: 37 additions & 94 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ julia> Pkg.add("SimJulia")
4040
* Version 0.4 is a complete rewrite: more julian and less pythonic.
4141
* Only supports Julia v0.6 and above.
4242
* Scheduling of events can be done with `Base.Dates.Datetime` and `Base.Dates.Period`:
43-
```
43+
```julia
4444
using SimJulia
4545
using Base.Dates
4646

@@ -58,7 +58,7 @@ run(sim, datetime+Month(3))
5858
* The discrete event features are on par with version 0.3. (STABLE)
5959
* Two ways of making `Processes` are provided:
6060
- using the existing concept of `Tasks`:
61-
```
61+
```julia
6262
function fibonnaci(sim::Simulation)
6363
a = 0.0
6464
b = 1.0
@@ -90,7 +90,7 @@ run(sim, datetime+Month(3))
9090
run(sim, 10)
9191
```
9292
* The continuous time simulation is based on a quantized state system solver. (EXPERIMENTAL)
93-
```
93+
```julia
9494
@model function diffeq(t, x, p, dx)
9595
dx[1] = p[2]+0.01*x[2]
9696
dx[2] = p[1]-100.0*x[1]-100.0*x[2]

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.4.1

docs/make.jl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,12 @@ makedocs(
88
sitename = "SimJulia.jl",
99
pages = [
1010
"Home" => "index.md",
11-
"Intro" => [
12-
"10_min/1_installation.md",
13-
"10_min/2_basic_concepts.md",
14-
"10_min/3_process_interaction.md",
15-
],
16-
"Manual" => "topics.md",
17-
"Examples" => [
18-
"examples/1_bank_renege.md",
19-
],
20-
"Library" => "api.md"
21-
]
22-
11+
]
2312
)
2413

2514
deploydocs(
2615
repo = "github.com/BenLauwens/SimJulia.jl.git",
27-
julia = "0.5",
16+
julia = "0.6",
2817
osname = "linux",
2918
target = "build",
3019
deps = nothing,

docs/src/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SimJulia
2+
3+
a combined continuous time / discrete event process oriented simulation framework written in [Julia](http://julialang.org/) inspired by the Simula library [DISCO](http://www.akira.ruc.dk/~keld/research/DISCO/), the Python library [SimPy](https://simpy.readthedocs.io/) and the standalone [QSS](https://sourceforge.net/projects/qssengine/) solver.

src/SimJulia.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module SimJulia
99
using Base.Dates
1010
using TaylorSeries
1111

12-
import Base.run, Base.now, Base.isless, Base.show, Base.interrupt, Base.yield
12+
import Base.run, Base.now, Base.isless, Base.show, Base.interrupt, Base.yield, Base.length
1313
import Base.(&), Base.(|)
1414
import TaylorSeries.evaluate
1515

src/continuous.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ struct Continuous <: ContinuousProcess
3535
end
3636
end
3737

38-
function Continuous{I<:Integrator}(model::Model, env::Environment, ::Type{I},
39-
x₀::Vector{Float64}, p::Vector{Float64}=Float64[]; args...)
38+
function Continuous(model::Model, env::Environment, ::Type{I},
39+
x₀::Vector{Float64}, p::Vector{Float64}=Float64[]; args...) where I<:Integrator
4040
cont = Continuous(env)
4141
t = now(env)
4242
integrator = I(model, now(env), x₀, p; args...)

src/finitestatemachines/transforms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function transformYield!(expr::Expr, n::UInt8=0x00, super::Expr=:(), line_no::In
6767
insert!(super.args, line_no, :(_fsm._state = 0xff))
6868
end
6969
insert!(super.args, line_no, :(@label $(Symbol("_STATE_",:($n)))))
70-
if VERSION >= v"0.7.0-DEV"
70+
if VERSION >= v"0.7.0-DEV.357" # julia PR #21746
7171
insert!(super.args, line_no, arg.args[3])
7272
else
7373
insert!(super.args, line_no, arg.args[2])

src/resources/base.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@ function isless(a::ResourceKey, b::ResourceKey)
2323
end
2424

2525
function trigger_put(put_ev::ResourceEvent, res::AbstractResource)
26-
queue = DataStructures.PriorityQueue(res.Put_queue)
26+
queue = DataStructures.PriorityQueue(res.put_queue)
2727
while length(queue) > 0
2828
(put_ev, key) = DataStructures.peek(queue)
2929
proceed = do_put(res, put_ev, key)
30-
state(put_ev) == scheduled && DataStructures.dequeue!(res.Put_queue, put_ev)
30+
state(put_ev) == scheduled && DataStructures.dequeue!(res.put_queue, put_ev)
3131
proceed ? DataStructures.dequeue!(queue) : break
3232
end
3333
end
3434

3535
function trigger_get(get_ev::ResourceEvent, res::AbstractResource)
36-
queue = DataStructures.PriorityQueue(res.Get_queue)
36+
queue = DataStructures.PriorityQueue(res.get_queue)
3737
while length(queue) > 0
3838
(get_ev, key) = DataStructures.peek(queue)
3939
proceed = do_get(res, get_ev, key)
40-
state(get_ev) == scheduled && DataStructures.dequeue!(res.Get_queue, get_ev)
40+
state(get_ev) == scheduled && DataStructures.dequeue!(res.get_queue, get_ev)
4141
proceed ? DataStructures.dequeue!(queue) : break
4242
end
4343
end
4444

4545
function cancel(res::AbstractResource, put_ev::Put)
46-
DataStructures.dequeue!(res.Put_queue, put_ev)
46+
DataStructures.dequeue!(res.put_queue, put_ev)
4747
end
4848

4949
function cancel(res::AbstractResource, get_ev::Get)
50-
DataStructures.dequeue!(res.Get_queue, get_ev)
50+
DataStructures.dequeue!(res.get_queue, get_ev)
5151
end
5252

5353
function capacity(res::AbstractResource)

src/resources/containers.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ mutable struct Container{N<:Number} <: AbstractResource
99
capacity :: N
1010
level :: N
1111
seid :: UInt
12-
Put_queue :: DataStructures.PriorityQueue{Put, ContainerKey{N}}
13-
Get_queue :: DataStructures.PriorityQueue{Get, ContainerKey{N}}
12+
put_queue :: DataStructures.PriorityQueue{Put, ContainerKey{N}}
13+
get_queue :: DataStructures.PriorityQueue{Get, ContainerKey{N}}
1414
function Container{N}(env::Environment, capacity::N, level::N) where {N<:Number}
1515
new(env, capacity, level, zero(UInt), DataStructures.PriorityQueue(Put, ContainerKey{N}), DataStructures.PriorityQueue(Get, ContainerKey{N}))
1616
end
1717
end
1818

19-
function Container{N<:Number}(env::Environment, capacity::N; level::N=zero(N))
19+
function Container(env::Environment, capacity::N; level::N=zero(N)) where N<:Number
2020
Container{N}(env, capacity, level)
2121
end
2222

@@ -28,7 +28,7 @@ end
2828

2929
function Put{N<:Number}(con::Container{N}, amount::N; priority::Int=0) :: Put
3030
put_ev = Put(con.env)
31-
con.Put_queue[put_ev] = ContainerKey(priority, con.seid+=one(UInt), amount)
31+
con.put_queue[put_ev] = ContainerKey(priority, con.seid+=one(UInt), amount)
3232
@callback trigger_get(put_ev, con)
3333
trigger_put(put_ev, con)
3434
put_ev
@@ -65,7 +65,7 @@ end
6565

6666
function Get{N<:Number}(con::Container{N}, amount::N; priority::Int=0) :: Get
6767
get_ev = Get(con.env)
68-
con.Get_queue[get_ev] = ContainerKey(priority, con.seid+=one(UInt), amount)
68+
con.get_queue[get_ev] = ContainerKey(priority, con.seid+=one(UInt), amount)
6969
@callback trigger_put(get_ev, con)
7070
trigger_get(get_ev, con)
7171
get_ev
@@ -88,3 +88,7 @@ function do_get{N<:Number}(con::Container{N}, get_ev::Get, key::ContainerKey{N})
8888
con.level -= key.amount
8989
true
9090
end
91+
92+
function length(res::Resource)
93+
length(res.put_queue)
94+
end

src/resources/stores.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ mutable struct Store{T} <: AbstractResource
1616
capacity :: UInt
1717
items :: Set{T}
1818
seid :: UInt
19-
Put_queue :: DataStructures.PriorityQueue{Put, StorePutKey{T}}
20-
Get_queue :: DataStructures.PriorityQueue{Get, StoreGetKey}
19+
put_queue :: DataStructures.PriorityQueue{Put, StorePutKey{T}}
20+
get_queue :: DataStructures.PriorityQueue{Get, StoreGetKey}
2121
function Store{T}(env::Environment, capacity::UInt) where {T}
2222
new(env, capacity, Set{T}(), zero(UInt), DataStructures.PriorityQueue(Put, StorePutKey{T}), DataStructures.PriorityQueue(Get, StoreGetKey))
2323
end
@@ -41,7 +41,7 @@ end
4141

4242
function Get{T}(sto::Store{T}, filter::Function=get_any_item; priority::Int=0) :: Get
4343
get_ev = Get(sto.env)
44-
sto.Get_queue[get_ev] = StoreGetKey(priority, sto.seid+=one(UInt), filter)
44+
sto.get_queue[get_ev] = StoreGetKey(priority, sto.seid+=one(UInt), filter)
4545
@callback trigger_put(get_ev, sto)
4646
trigger_get(get_ev, sto)
4747
return get_ev

0 commit comments

Comments
 (0)