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
fe33a03b
Unverified
Commit
fe33a03b
authored
10 months ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Set qval/qvec directly if possible
parent
016647d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Define variables through new @defvar macro
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/instant_gradients.jl
+9
-16
9 additions, 16 deletions
src/components/instant_gradients.jl
with
9 additions
and
16 deletions
src/components/instant_gradients.jl
+
9
−
16
View file @
fe33a03b
module
InstantGradients
module
InstantGradients
import
StaticArrays
:
SVector
,
SMatrix
import
StaticArrays
:
SVector
,
SMatrix
import
JuMP
:
@constraint
import
JuMP
:
@constraint
import
...
Variables
:
@defvar
,
VariableType
,
variables
,
get_free_variable
,
set_simple_constraints!
,
make_generic
,
adjust_internal
,
adjustable
,
gradient_orientation
import
...
Variables
:
@defvar
,
VariableType
,
variables
,
get_free_variable
,
set_simple_constraints!
,
make_generic
,
adjust_internal
,
adjustable
,
gradient_orientation
,
apply_simple_constraint!
import
...
BuildSequences
:
global_model
import
...
BuildSequences
:
global_model
import
..
AbstractTypes
:
EventComponent
,
GradientWaveform
import
..
AbstractTypes
:
EventComponent
,
GradientWaveform
...
@@ -20,16 +20,18 @@ If the `orientation` is set an [`InstantGradient1D`](@ref) is returned, otherwis
...
@@ -20,16 +20,18 @@ If the `orientation` is set an [`InstantGradient1D`](@ref) is returned, otherwis
"""
"""
abstract type
InstantGradient
{
N
}
<:
EventComponent
end
abstract type
InstantGradient
{
N
}
<:
EventComponent
end
function
(::
Type
{
InstantGradient
})(;
orientation
=
nothing
,
group
=
nothing
,
va
riable
s
...
)
function
(::
Type
{
InstantGradient
})(;
orientation
=
nothing
,
group
=
nothing
,
q
va
l
=
nothing
,
qvec
=
[
nothing
,
nothing
,
nothing
],
var
s
...
)
if
isnothing
(
orientation
)
if
isnothing
(
orientation
)
res
=
InstantGradient3D
(
nothing
,
group
)
res
=
InstantGradient3D
(
get_free_variable
.
(
qvec
),
group
)
apply_simple_constraint!
(
variables
.
qval
(
res
),
qval
)
else
else
res
=
InstantGradient1D
(
nothing
,
orientation
,
group
)
res
=
InstantGradient1D
(
get_free_variable
(
qval
)
,
orientation
,
group
)
if
!
(
res
.
qv
ec
isa
Number
)
if
!
(
res
.
qv
al
isa
Number
)
@constraint
global_model
()
res
.
qv
ec
>=
0
@constraint
global_model
()
res
.
qv
al
>=
0
end
end
apply_simple_constraint!
(
variables
.
qvec
(
res
),
qvec
)
end
end
set_simple_constraints!
(
res
,
var
iable
s
)
set_simple_constraints!
(
res
,
vars
)
return
res
return
res
end
end
...
@@ -52,15 +54,6 @@ struct InstantGradient3D <: InstantGradient{3}
...
@@ -52,15 +54,6 @@ struct InstantGradient3D <: InstantGradient{3}
group
::
Union
{
Nothing
,
Symbol
}
group
::
Union
{
Nothing
,
Symbol
}
end
end
function
InstantGradient3D
(;
qvec
=
nothing
,
group
=
nothing
,
variables
...
)
if
isnothing
(
qvec
)
qvec
=
[
nothing
,
nothing
,
nothing
]
end
res
=
InstantGradient3D
(
get_free_variable
.
(
qvec
),
group
)
set_simple_constraints!
(
res
,
variables
)
return
res
end
@defvar
gradient
qvec
(
ig
::
InstantGradient3D
)
=
ig
.
qvec
@defvar
gradient
qvec
(
ig
::
InstantGradient3D
)
=
ig
.
qvec
...
...
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