Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autonomous_driving_tools
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
Service Desk
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
mobile_robotics
autonomous_driving
autonomous_driving_tools
Commits
0516dd8d
Commit
0516dd8d
authored
4 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a flag to indicate if the convergence went beyond the specified limits.
parent
d2f67dbe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/gradient.h
+1
-1
1 addition, 1 deletion
include/gradient.h
src/gradient.cpp
+5
-5
5 additions, 5 deletions
src/gradient.cpp
with
6 additions
and
6 deletions
include/gradient.h
+
1
−
1
View file @
0516dd8d
...
...
@@ -28,7 +28,7 @@ class CGradient
void
get_coord_constraints
(
double
&
max
,
double
&
min
);
void
set_function
(
boost
::
function
<
double
(
double
)
>
p_function
);
void
set_function_der
(
boost
::
function
<
double
(
double
)
>
p_function
);
bool
compute
(
double
max_func_error
,
unsigned
int
max_iter
,
double
start_point
,
bool
max
=
true
);
bool
compute
(
double
max_func_error
,
unsigned
int
max_iter
,
double
start_point
,
bool
&
beyond_limits
,
bool
max
=
true
);
double
get_value
(
void
);
double
get_coordinate
(
void
);
~
CGradient
();
...
...
This diff is collapsed.
Click to expand it.
src/gradient.cpp
+
5
−
5
View file @
0516dd8d
...
...
@@ -47,13 +47,13 @@ void CGradient::set_function_der(boost::function<double (double)> p_function)
this
->
p_function_der
=
p_function
;
}
bool
CGradient
::
compute
(
double
max_func_error
,
unsigned
int
max_iter
,
double
start_point
,
bool
max
)
bool
CGradient
::
compute
(
double
max_func_error
,
unsigned
int
max_iter
,
double
start_point
,
bool
&
beyond_limits
,
bool
max
)
{
unsigned
int
iteration
=
0
;
double
gamma
=
1.0
,
func_value
,
func_der_value
,
prev_func_value
,
prev_func_der_value
;
double
coord
,
prev_coord
,
coord_inc
;
bool
beyond_limits
=
false
;
beyond_limits
=
false
;
coord
=
start_point
;
func_value
=
this
->
p_function
(
coord
);
func_der_value
=
this
->
p_function_der
(
coord
);
...
...
@@ -68,7 +68,7 @@ bool CGradient::compute(double max_func_error,unsigned int max_iter,double start
coord
+=
coord_inc
;
else
coord
-=
coord_inc
;
if
(
coord
>
this
->
max_coord
)
if
(
(
coord
-
this
->
max_coord
)
>
max_func_error
)
{
coord
=
this
->
max_coord
;
this
->
coordinate
=
coord
;
...
...
@@ -76,7 +76,7 @@ bool CGradient::compute(double max_func_error,unsigned int max_iter,double start
beyond_limits
=
true
;
break
;
}
else
if
(
coord
<
this
->
min_coord
)
else
if
(
(
coord
-
this
->
min_coord
)
<-
max_func_error
)
{
coord
=
this
->
min_coord
;
this
->
coordinate
=
coord
;
...
...
@@ -93,7 +93,7 @@ bool CGradient::compute(double max_func_error,unsigned int max_iter,double start
}
while
((
fabs
(
func_value
-
prev_func_value
)
>
max_func_error
||
fabs
(
coord
-
prev_coord
)
>
0.001
)
&&
iteration
<
max_iter
);
this
->
coordinate
=
coord
;
this
->
value
=
func_value
;
if
(
iteration
==
max_iter
||
beyond_limits
)
if
(
iteration
==
max_iter
)
return
false
;
else
return
true
;
...
...
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