Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
COBREXA.jl
Commits
0ac76bdd
Unverified
Commit
0ac76bdd
authored
Aug 09, 2021
by
Miroslav Kratochvil
Committed by
GitHub
Aug 09, 2021
Browse files
Merge pull request #421 from LCSB-BioCore/mk-clarify-set-optmodel-bound
simplify & unsurprise `set_optmodel_bound!`
parents
7ca418a3
8d85d8b6
Pipeline
#45147
passed with stages
in 40 minutes and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/base/solver.jl
View file @
0ac76bdd
...
...
@@ -48,7 +48,7 @@ end
Shortcut for running JuMP `optimize!` on a model and returning the objective
value, if solved.
"""
function
optimize_objective
(
optmodel
)
::
Union
{
Float64
,
Nothing
}
function
optimize_objective
(
optmodel
)
::
Maybe
{
Float64
}
optimize!
(
optmodel
)
if
is_solved
(
optmodel
)
objective_value
(
optmodel
)
...
...
@@ -70,27 +70,21 @@ get_optmodel_bounds(opt_model) = (
)
"""
set_optmodel_bound!(index, optimization_model;
ub=_constants.default_reaction_rate,
lb=-_constants.default_reaction_rate)
Helper function to set the bounds of variables.
The JuMP `set_normalized_rhs` function is a little confusing,
so this function simplifies setting constraints. In short, JuMP
uses a normalized right hand side representation of constraints,
which means that lower bounds have their sign flipped. This function
does this for you, so you don't have to remember to do this whenever you
change the constraints.
set_optmodel_bound!(vidx, opt_model;
ub::Maybe{Real} = nothing,
lb::Maybe{Real} = nothing,
)
Just supply the constraint `index` and the JuMP model (`opt_model`) that
will be solved, and the variable's bounds will be set to `ub` and `lb`.
Helper function to set the bounds of a variable in the model. Internally calls
`set_normalized_rhs` from JuMP. If the bounds are set to `nothing`, they will
not be changed.
"""
function
set_optmodel_bound!
(
vi
n
d
,
vid
x
,
opt_model
;
ub
=
_constants
.
default_reaction_rate
,
lb
=
-
_constants
.
default_reaction_rate
,
lb
::
Maybe
{
Real
}
=
nothing
,
ub
::
Maybe
{
Real
}
=
nothing
,
)
set_normalized_rhs
(
opt_model
[
:
lbs
][
vi
n
d
],
-
lb
)
set_normalized_rhs
(
opt_model
[
:
ubs
][
vi
n
d
],
ub
)
isnothing
(
lb
)
||
set_normalized_rhs
(
opt_model
[
:
lbs
][
vid
x
],
-
lb
)
isnothing
(
ub
)
||
set_normalized_rhs
(
opt_model
[
:
ubs
][
vid
x
],
ub
)
end
cylon-x
🤖
@cylon-x
mentioned in commit
a3b062f7
·
Aug 09, 2021
mentioned in commit
a3b062f7
mentioned in commit a3b062f7cc32133e1af478efdb438174098cce1e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment