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
2a108798
Verified
Commit
2a108798
authored
1 year ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Add JuMP helper methods for BuildingBlocks
parent
cdff9357
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/building_blocks.jl
+17
-1
17 additions, 1 deletion
src/building_blocks.jl
with
17 additions
and
1 deletion
src/building_blocks.jl
+
17
−
1
View file @
2a108798
module
BuildingBlocks
module
BuildingBlocks
import
JuMP
:
has_values
,
GenericVariableRef
,
value
,
Model
,
@constraint
,
@objective
,
owner_model
,
objective_function
import
JuMP
:
has_values
,
GenericVariableRef
,
value
,
Model
,
@constraint
,
@objective
,
owner_model
,
objective_function
,
optimize!
,
AbstractJuMPScalar
import
Printf
:
@sprintf
import
Printf
:
@sprintf
import
..
Scanners
:
Scanner
import
..
Scanners
:
Scanner
import
..
Variables
:
variables
,
start_time
,
duration
,
end_time
,
gradient_strength
,
slew_rate
import
..
Variables
:
variables
,
start_time
,
duration
,
end_time
,
gradient_strength
,
slew_rate
...
@@ -138,4 +138,20 @@ function match_blocks!(block1::BuildingBlock, block2::BuildingBlock)
...
@@ -138,4 +138,20 @@ function match_blocks!(block1::BuildingBlock, block2::BuildingBlock)
match_blocks!
(
block1
,
block2
,
property_list
)
match_blocks!
(
block1
,
block2
,
property_list
)
end
end
optimize!
(
bb
::
BuildingBlock
)
=
optimize!
(
owner_model
(
bb
))
function
owner_model
(
bb
::
BuildingBlock
)
if
hasproperty
(
bb
,
:
model
)
return
bb
.
model
else
for
name
in
propertynames
(
bb
)
value
=
getproperty
(
bb
,
name
)
if
value
isa
AbstractJuMPScalar
return
owner_model
(
value
)
end
end
end
error
(
"Cannot find owner model of
$
bb"
)
end
end
end
\ No newline at end of file
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