Add Problem::SetParameterLowerBound and Problem::SetParameterUpperBound.

These two methods allow the user to associate upper and lower bounds
with individual parameters inside parameter blocks.

Change-Id: I68dc37f20b64408da510ba06b89a4f08df54ddad
This commit is contained in:
Sameer Agarwal
2014-02-18 22:24:03 -08:00
parent fc827de385
commit a482ab8ad5
4 changed files with 34 additions and 1 deletions
+5 -1
View File
@@ -300,7 +300,7 @@ class Problem {
// Hold the indicated parameter block constant during optimization.
void SetParameterBlockConstant(double* values);
// Allow the indicated parameter to vary during optimization.
// Allow the indicated parameter block to vary during optimization.
void SetParameterBlockVariable(double* values);
// Set the local parameterization for one of the parameter blocks.
@@ -317,6 +317,10 @@ class Problem {
// associated then NULL is returned.
const LocalParameterization* GetParameterization(double* values) const;
// Set the lower/upper bound for the parameter with position "index".
void SetParameterLowerBound(double* values, int index, double lower_bound);
void SetParameterUpperBound(double* values, int index, double upper_bound);
// Number of parameter blocks in the problem. Always equals
// parameter_blocks().size() and parameter_block_sizes().size().
int NumParameterBlocks() const;
+12
View File
@@ -183,6 +183,18 @@ const LocalParameterization* Problem::GetParameterization(
return problem_impl_->GetParameterization(values);
}
void Problem::SetParameterLowerBound(double* values,
int index,
double lower_bound) {
problem_impl_->SetParameterLowerBound(values, index, lower_bound);
}
void Problem::SetParameterUpperBound(double* values,
int index,
double upper_bound) {
problem_impl_->SetParameterUpperBound(values, index, upper_bound);
}
bool Problem::Evaluate(const EvaluateOptions& evaluate_options,
double* cost,
vector<double>* residuals,
+14
View File
@@ -541,6 +541,20 @@ const LocalParameterization* ProblemImpl::GetParameterization(
->local_parameterization();
}
void ProblemImpl::SetParameterLowerBound(double* values,
int index,
double lower_bound) {
FindParameterBlockOrDie(parameter_block_map_, values)
->SetLowerBound(index, lower_bound);
}
void ProblemImpl::SetParameterUpperBound(double* values,
int index,
double upper_bound) {
FindParameterBlockOrDie(parameter_block_map_, values)
->SetUpperBound(index, upper_bound);
}
bool ProblemImpl::Evaluate(const Problem::EvaluateOptions& evaluate_options,
double* cost,
vector<double>* residuals,
+3
View File
@@ -129,6 +129,9 @@ class ProblemImpl {
LocalParameterization* local_parameterization);
const LocalParameterization* GetParameterization(double* values) const;
void SetParameterLowerBound(double* values, int index, double lower_bound);
void SetParameterUpperBound(double* values, int index, double upper_bound);
bool Evaluate(const Problem::EvaluateOptions& options,
double* cost,
vector<double>* residuals,