Skip to content
Snippets Groups Projects
Unverified Commit 49177280 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Skip variables that are always zero

parent dfa3371d
No related branches found
No related tags found
1 merge request!2Define variables through new @defvar macro
...@@ -12,7 +12,7 @@ In addition this defines: ...@@ -12,7 +12,7 @@ In addition this defines:
- [`gradient_orientation`](@ref): returns the gradient orientation of a waveform if fixed. - [`gradient_orientation`](@ref): returns the gradient orientation of a waveform if fixed.
""" """
module Variables module Variables
import JuMP: @constraint, @variable, Model, @objective, objective_function, AbstractJuMPScalar import JuMP: @constraint, @variable, Model, @objective, objective_function, AbstractJuMPScalar, QuadExpr, AffExpr
import StaticArrays: SVector import StaticArrays: SVector
import MacroTools import MacroTools
import ..Scanners: gradient_strength, slew_rate, Scanner import ..Scanners: gradient_strength, slew_rate, Scanner
...@@ -472,6 +472,9 @@ function scanner_constraints!(bb::AbstractBlock) ...@@ -472,6 +472,9 @@ function scanner_constraints!(bb::AbstractBlock)
continue continue
end end
for v in value for v in value
if v isa Number || ((v isa Union{QuadExpr, AffExpr}) && length(v.terms) == 0)
continue
end
@constraint global_model() v <= max_value @constraint global_model() v <= max_value
@constraint global_model() v >= -max_value @constraint global_model() v >= -max_value
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment