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
0883ba40
Verified
Commit
0883ba40
authored
1 year ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Apply random kicks to aid convergence
parent
d8dba238
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/build_sequences.jl
+15
-2
15 additions, 2 deletions
src/build_sequences.jl
with
15 additions
and
2 deletions
src/build_sequences.jl
+
15
−
2
View file @
0883ba40
module
BuildSequences
module
BuildSequences
import
JuMP
:
Model
,
optimizer_with_attributes
,
optimize!
,
AbstractJuMPScalar
,
value
,
solution_summary
,
termination_status
,
LOCALLY_SOLVED
,
OPTIMAL
,
num_variables
import
JuMP
:
Model
,
optimizer_with_attributes
,
optimize!
,
AbstractJuMPScalar
,
value
,
solution_summary
,
termination_status
,
LOCALLY_SOLVED
,
OPTIMAL
,
num_variables
,
all_variables
,
set_start_value
,
ALMOST_LOCALLY_SOLVED
import
Ipopt
import
Ipopt
import
Juniper
import
Juniper
import
..
Scanners
:
Scanner
,
gradient_strength
import
..
Scanners
:
Scanner
,
gradient_strength
...
@@ -55,7 +55,20 @@ function build_sequence(f::Function, scanner::Union{Nothing, Scanner}, model::Mo
...
@@ -55,7 +55,20 @@ function build_sequence(f::Function, scanner::Union{Nothing, Scanner}, model::Mo
sequence
=
f
()
sequence
=
f
()
if
optimise
if
optimise
if
!
iszero
(
num_variables
(
model
))
if
!
iszero
(
num_variables
(
model
))
optimize!
(
model
)
for
attempt
in
1
:
100
optimize!
(
model
)
if
termination_status
(
model
)
in
(
LOCALLY_SOLVED
,
OPTIMAL
)
println
(
"Success after
$
(attempt-1) restarts."
)
break
else
old_values
=
value
.
(
all_variables
(
model
))
size_kick
=
0.2
/
attempt
new_values
=
old_values
.*
(
2
.*
size_kick
.*
rand
(
length
(
old_values
))
.+
1.
.-
size_kick
)
for
(
var
,
v
)
in
zip
(
all_variables
(
model
),
new_values
)
set_start_value
(
var
,
v
)
end
end
end
if
!
(
termination_status
(
model
)
in
(
LOCALLY_SOLVED
,
OPTIMAL
))
if
!
(
termination_status
(
model
)
in
(
LOCALLY_SOLVED
,
OPTIMAL
))
@warn
"Optimisation did not report successful convergence. Please check the output sequence."
@warn
"Optimisation did not report successful convergence. Please check the output sequence."
println
(
solution_summary
(
model
))
println
(
solution_summary
(
model
))
...
...
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