Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MRIBuilder.jl
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
Michiel Cottaar
MRIBuilder.jl
Commits
90f75bd0
Verified
Commit
90f75bd0
authored
1 year ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Standardise way to get children blocks of containers
parent
e80b81cf
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
src/building_blocks.jl
+16
-0
16 additions, 0 deletions
src/building_blocks.jl
src/containers/sequences.jl
+3
-2
3 additions, 2 deletions
src/containers/sequences.jl
with
19 additions
and
2 deletions
src/building_blocks.jl
+
16
−
0
View file @
90f75bd0
...
@@ -28,10 +28,21 @@ abstract type GradientBlock <: BuildingBlock end
...
@@ -28,10 +28,21 @@ abstract type GradientBlock <: BuildingBlock end
"""
"""
Parent type for all types combining one or more pulses/gradients.
Parent type for all types combining one or more pulses/gradients.
Required methods:
- [`get_children_blocks`](@ref): return all the [`BuildingBlock`](@ref) objects includes in this container with their indices.
"""
"""
abstract type
ContainerBlock
<:
BuildingBlock
end
abstract type
ContainerBlock
<:
BuildingBlock
end
"""
get_children_blocks(container)
Return all the [`BuildingBlock`](@ref) objects includes in this container with their indices.
"""
function
get_children_blocks
end
"""
"""
start_time(container, args...)
start_time(container, args...)
...
@@ -72,6 +83,11 @@ function scanner_constraints!(model::Model, building_block::BuildingBlock, scann
...
@@ -72,6 +83,11 @@ function scanner_constraints!(model::Model, building_block::BuildingBlock, scann
@constraint
model
func
(
building_block
)
<=
func
(
scanner
)
@constraint
model
func
(
building_block
)
<=
func
(
scanner
)
end
end
end
end
if
building_block
isa
ContainerBlock
for
(
_
,
child_block
)
in
get_children_blocks
(
building_block
)
scanner_constraints!
(
model
,
child_block
,
scanner
)
end
end
end
end
"""
"""
...
...
This diff is collapsed.
Click to expand it.
src/containers/sequences.jl
+
3
−
2
View file @
90f75bd0
...
@@ -2,7 +2,7 @@ module Sequences
...
@@ -2,7 +2,7 @@ module Sequences
import
JuMP
:
Model
,
@constraint
import
JuMP
:
Model
,
@constraint
import
...
BuildSequences
:
@global_model_constructor
import
...
BuildSequences
:
@global_model_constructor
import
...
Variables
:
variables
,
start_time
,
duration
,
VariableType
,
get_free_variable
,
TR
import
...
Variables
:
variables
,
start_time
,
duration
,
VariableType
,
get_free_variable
,
TR
import
...
BuildingBlocks
:
BuildingBlock
,
ContainerBlock
,
to_block
,
add_scanner_constraints!
import
...
BuildingBlocks
:
BuildingBlock
,
ContainerBlock
,
to_block
,
get_children_blocks
"""
"""
Sequence(building_blocks...)
Sequence(building_blocks...)
...
@@ -14,7 +14,7 @@ struct Sequence <: ContainerBlock
...
@@ -14,7 +14,7 @@ struct Sequence <: ContainerBlock
model
::
Model
model
::
Model
blocks
::
Vector
{
<:
BuildingBlock
}
blocks
::
Vector
{
<:
BuildingBlock
}
TR
::
VariableType
TR
::
VariableType
function
Sequence
(
model
::
Model
,
blocks
::
Vector
;
TR
=
nothing
)
function
Sequence
(
model
::
Model
,
blocks
::
Abstract
Vector
;
TR
=
nothing
)
seq
=
new
(
seq
=
new
(
model
,
model
,
to_block
.
(
blocks
),
to_block
.
(
blocks
),
...
@@ -31,6 +31,7 @@ Sequence(model::Model, blocks...; TR=nothing) = Sequence(model, [blocks...]; TR=
...
@@ -31,6 +31,7 @@ Sequence(model::Model, blocks...; TR=nothing) = Sequence(model, [blocks...]; TR=
Base
.
length
(
seq
::
Sequence
)
=
length
(
seq
.
blocks
)
Base
.
length
(
seq
::
Sequence
)
=
length
(
seq
.
blocks
)
Base
.
getindex
(
seq
::
Sequence
,
index
)
=
seq
.
blocks
[
index
]
Base
.
getindex
(
seq
::
Sequence
,
index
)
=
seq
.
blocks
[
index
]
get_children_blocks
(
seq
::
Sequence
)
=
enumerate
(
seq
.
blocks
)
"""
"""
start_time(sequence::Sequence, index::Integer, args...)
start_time(sequence::Sequence, index::Integer, args...)
...
...
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