Hello all,
I am using LM for my problem, where I have around 120 equations and need to
determine the values of parameters a,b,c (depending on the experiment I have
three to eight variables). The equations are non linear with a,b,c in the
powers of 1 to cubic. I am quite happy w the performance of ceres. My question is, is there a way to implement weighted residuals, where the weighting is dependent on two separate ceres Residual Blocks? And is there a way to do this without changing the cost function
equations (see definitions below)? I need to implement these two weightings:
Weightings:
1. residual_new1 = res1^2/ (const)
where res1^2 = summation(i=1:N) { [ (y_abc - y_abc_calc)^2 + (y_abc_C2 - y_abc_C2_calc)^2] / [y_abc^2 + y_abc_C2^2] }
where y_abc and y_abc_C2 are from two different cost functions as defined below.
2. residual_new2 = res2^2/ (const)
where res2^2 = summation(i=1:N) { [ (y_abc - y_abc_calc)^2 / (y_abc^2) ] + [(y_abc_C2 - y_abc_C2_calc)^2 / (y_abc_C2^2) ] }
where y_abc and y_abc_C2 are from two different cost functions as defined below.
DEFINITIONS of the ceres problem and the residual blocks:
DEFINE_string(minimizer, "trust_region",
"Minimizer type to use, choices are: line_search &
trust_region");
Solver::Options options_smart;
options_smart.trust_region_strategy_type =
ceres::LEVENBERG_MARQUARDT;
options_smart.max_num_iterations = 500;
options_smart.linear_solver_type = ceres::DENSE_QR;
options_smart.minimizer_progress_to_stdout = true;
Problem problem;
double a, b, c;
for (int i = 0; i < logf.size(); ++i) {
eqn_abc_t *eqn_abc_1 = new
eqn_abc_t(logf[i], Zr[i]);
problem.AddResidualBlock(new
AutoDiffCostFunction<eqn_abc_t, 1, 1, 1, 1>(eqn_abc_1), NULL, &a,
&b, &c);
eqn_C2_abc_t *eqn_C2_abc_1 = new
eqn_C2_abc_t(logf[i],ZC2[i]);
problem.AddResidualBlock(new
AutoDiffCostFunction<eqn_C2_abc_t, 1, 1, 1, 1>(eqn_C2_abc_1), NULL,
&a, &b, &c);
}
Solver::Summary summary;
Solve(options_smart, &problem,
&summary);
The cost functions:
class eqn_abc_t{
public:
eqn_abc_t(double x, double y)
: x_(x), y_(y) {}
template <typename T>
bool operator()(const T* const a, const T* const b, const T* const
c, T* residual) const {
residual[0] = (T(y_) - a[0])*(1.0 + (4.0 * Pisq
* pow(10, T(x_)) * pow(10, T(x_)) * b[0] * b[0] * c[0] * c[0]))
- b[0];
return true;
}
private:
const double x_;
const double y_;
};
class eqn_C2_abc_t{
public:
eqn_C2_abc_t(double x, double y)
: x_(x), y_(y) {}
template <typename T>
bool operator()(const T* const a, const T* const b, const T* const
c, T* residual) const {
residual[0] = T(y_) + (T(y_) * (4.0 * Pisq *
pow(10, T(x_)) * pow(10, T(x_)) * b[0] * b[0] * c[0] * c[0]))
- (b[0] * b[0] * 2.0 * Pi *
c[0] * pow(10, T(x_)));
return true;
}
private:
const double x_;
const double y_;
};
Thanks.
-Adit
There is no automatic way to do this.
I am curious though, why are you trying to do this?
--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/46614c29-f03c-4e54-b065-788d5b46b025%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/59fb9dfd-0427-472e-8cb3-94fbf46dc2e1%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/59fb9dfd-0427-472e-8cb3-94fbf46dc2e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/H3JKVp5p6tg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUByjq_DNM1W%2B6S4zAxhzhYF-dX%3DgDFgCcjLTym%3Ds7AdLQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/59fb9dfd-0427-472e-8cb3-94fbf46dc2e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/H3JKVp5p6tg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUByjq_DNM1W%2B6S4zAxhzhYF-dX%3DgDFgCcjLTym%3Ds7AdLQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CAK520qYiRxPcCmxBkzEgM%3DnqeX94V%2B_Mhszjx8O0Mu0x%2BDdMGQ%40mail.gmail.com.