Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miscmaths
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
Container Registry
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
FSL
miscmaths
Commits
019de600
Commit
019de600
authored
9 years ago
by
Jesper Andersson
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bug that meant that amoeba only worked for strictly positive cost-functions
parent
a9d6db82
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Simplex.cpp
+2
-2
2 additions, 2 deletions
Simplex.cpp
nonlin.cpp
+6
-6
6 additions, 6 deletions
nonlin.cpp
with
8 additions
and
8 deletions
Simplex.cpp
+
2
−
2
View file @
019de600
...
...
@@ -165,12 +165,12 @@ void Simplex::MultiContract()
void
Simplex
::
UpdateRankIndicies
()
{
double
minv
=
std
::
numeric_limits
<
double
>::
max
();
double
maxv
=
std
::
numeric_limits
<
double
>::
m
in
();
double
maxv
=
-
std
::
numeric_limits
<
double
>::
m
ax
();
for
(
unsigned
int
i
=
0
;
i
<
_fv
.
size
();
i
++
)
{
if
(
_fv
[
i
]
<
minv
)
{
minv
=
_fv
[
i
];
_bsti
=
i
;
}
if
(
_fv
[
i
]
>
maxv
)
{
maxv
=
_fv
[
i
];
_wrsti
=
i
;
}
}
maxv
=
std
::
numeric_limits
<
double
>::
m
in
();
maxv
=
-
std
::
numeric_limits
<
double
>::
m
ax
();
for
(
unsigned
int
i
=
0
;
i
<
_fv
.
size
();
i
++
)
{
if
(
i
!=
_wrsti
)
{
if
(
_fv
[
i
]
>
maxv
)
{
maxv
=
_fv
[
i
];
_nwsti
=
i
;
}
...
...
This diff is collapsed.
Click to expand it.
nonlin.cpp
+
6
−
6
View file @
019de600
...
...
@@ -400,32 +400,32 @@ NonlinOut levmar(const NonlinParam& p, const NonlinCF& cfo)
NonlinOut
amoeba
(
const
NonlinParam
&
p
,
const
NonlinCF
&
cfo
)
{
// cout << "Initialsing simplex" << endl;
// cout << "Initialsing simplex" << endl;
cout.flush();
Simplex
smplx
(
p
.
Par
(),
cfo
,
p
.
GetAmoebaStart
());
p
.
SetCF
(
smplx
.
BestFuncVal
());
while
(
p
.
NextIter
())
{
// Check for convergence based on fractional difference
// between best and worst points in simplex.
// cout << "New iteration: Checking for convergence" << endl;
// cout << "New iteration: Checking for convergence" << endl;
cout.flush();
if
(
zero_cf_diff_conv
(
smplx
.
WorstFuncVal
(),
smplx
.
BestFuncVal
(),
p
.
FractionalCFTolerance
()))
{
p
.
SetStatus
(
NL_CFCONV
);
return
(
p
.
Status
());
}
// cout << "Attempting reflexion" << endl;
// cout << "Attempting reflexion" << endl;
cout.flush();
double
newf
=
smplx
.
Reflect
();
// Attempt reflexion
// Extend into an expansion if reflexion very successful
if
(
newf
<=
smplx
.
BestFuncVal
())
{
// cout << "Reflexion succesful: attempting expansion" << endl;
// cout << "Reflexion succesful: attempting expansion" << endl;
cout.flush();
smplx
.
Expand
();
// Attempt expansion
}
else
if
(
newf
>=
smplx
.
SecondWorstFuncVal
())
{
// cout << "New value worse than second worst: attempting contraction" << endl;
// cout << "New value worse than second worst: attempting contraction" << endl;
cout.flush();
double
worst_fval
=
smplx
.
WorstFuncVal
();
newf
=
smplx
.
Contract
();
// Do a contraction towards plane of "better" points
if
(
newf
>=
worst_fval
)
{
// Didn't work. Contract towards best point
// cout << "Contraction unsuccesful: contracting towards best point" << endl;
// cout << "Contraction unsuccesful: contracting towards best point" << endl;
cout.flush();
smplx
.
MultiContract
();
}
}
...
...
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