Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
optimization
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
Model registry
Operate
Environments
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
Erik Strand
optimization
Commits
764be714
Commit
764be714
authored
5 years ago
by
Erik Strand
Browse files
Options
Downloads
Patches
Plain Diff
Teach nm to build its own simplex
parent
a90557a0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
optimization/optimizers/nelder_mead/nelder_mead.h
+19
-0
19 additions, 0 deletions
optimization/optimizers/nelder_mead/nelder_mead.h
with
19 additions
and
0 deletions
optimization/optimizers/nelder_mead/nelder_mead.h
+
19
−
0
View file @
764be714
...
@@ -28,6 +28,8 @@ public:
...
@@ -28,6 +28,8 @@ public:
MatrixDN
const
&
simplex_vertices
()
const
{
return
simplex_vertices_
;
}
MatrixDN
const
&
simplex_vertices
()
const
{
return
simplex_vertices_
;
}
VectorN
const
&
simplex_values
()
const
{
return
simplex_values_
;
}
VectorN
const
&
simplex_values
()
const
{
return
simplex_values_
;
}
// Constructs a simplex from an initial point by offset all coordinate values.
VectorD
optimize
(
Objective
&
objective
,
VectorD
const
&
initial_point
,
Scalar
offset
=
1
);
// Each row of simplex is a vertex.
// Each row of simplex is a vertex.
VectorD
optimize
(
Objective
&
objective
,
MatrixDN
const
&
simplex
);
VectorD
optimize
(
Objective
&
objective
,
MatrixDN
const
&
simplex
);
...
@@ -60,6 +62,23 @@ private:
...
@@ -60,6 +62,23 @@ private:
static
constexpr
Scalar
tiny_
=
1e-10
;
static
constexpr
Scalar
tiny_
=
1e-10
;
};
};
//..................................................................................................
template
<
typename
Objective
,
int32_t
D
>
auto
NelderMead
<
Objective
,
D
>::
optimize
(
Objective
&
objective
,
VectorD
const
&
initial_point
,
Scalar
offset
)
->
VectorD
{
MatrixDN
simplex
;
simplex
.
resize
(
initial_point
.
size
(),
initial_point
.
size
()
+
1
);
simplex
.
col
(
0
)
=
initial_point
;
for
(
uint32_t
i
=
0
;
i
<
initial_point
.
size
();
++
i
)
{
simplex
.
col
(
i
+
1
)
=
initial_point
;
simplex
(
i
,
i
+
1
)
+=
offset
;
}
return
optimize
(
objective
,
simplex
);
}
//..................................................................................................
//..................................................................................................
template
<
typename
Objective
,
int32_t
D
>
template
<
typename
Objective
,
int32_t
D
>
auto
NelderMead
<
Objective
,
D
>::
optimize
(
Objective
&
objective
,
MatrixDN
const
&
simplex
)
->
VectorD
{
auto
NelderMead
<
Objective
,
D
>::
optimize
(
Objective
&
objective
,
MatrixDN
const
&
simplex
)
->
VectorD
{
...
...
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