[Ipopt] Help with problem formulation
Nuno Silva
pg17455 at alunos.uminho.pt
Wed Sep 19 07:54:42 EDT 2012
Greetings
I'm a researcher enrolled in a project that requires fitting measured data
into known functions.
The measured data is the color variation of a point on a material, as the
camera and light source moves around the object.
So our functions depend on those directions.
A simplistic model is the Lambertian BRDF model that simply says thatthe
color value is the dot product of the normal at that point with the
incident light direction.
The incident lighting direction and the camera direction are known, they
are a discrete set of directions expressed in polar coordinates w :=
(theta, phi).
The objective is to find the best parameters of the BRDF model so that it
is most correlated with the measured data, this is, to minimize the
difference between the measured data and the estimated values.
I came up with this:
/** This class implements the following NLP.
*
* Lambert BRDF model
* min sum[i=0, ni-1] sum[o=0, no-1]{ f(N, wi, wo) - T(wi,wo) }
* with
* f(N, wi, wo) = dot(wi, N)
*
* note:
* T -> texel value for the wi and wo directions
* N -> Geometric Normal := {theta_n, phi_n}
* wi -> Incomming light direction := {theta_i, phi_i}
* wo -> Outgoing camera direction := {theta_o, phi_o}
*/
I defined these boundaries:
// theta is limited to the upper hemisphere
x_l[THETA_N] = x_l[THETA_i] = x_l[THETA_o] = 0.0;
x_u[THETA_N] = x_u[THETA_i] = x_u[THETA_o] = PI/2;
// phi
x_l[PHI_N] = x_l[PHI_i] = x_l[PHI_o] = 0.0;
x_u[PHI_N] = x_u[PHI_i] = x_u[PHI_o] = 2*PI;
This is the eval_f function:
// get diretions in cartesian coordinates
vec3 N = vec3( sin(x[THETA_N])*cos(x[PHI_N]),
sin(x[THETA_N])*sin(x[THETA_N]), cos(x[THETA_N]) );
vec3 wi_c = vec3( sin(x[THETA_i])*cos(x[PHI_i]),
sin(x[THETA_i])*sin(x[THETA_i]), cos(x[THETA_i]) );
vec3 wo_c = vec3( sin(x[THETA_o])*cos(x[PHI_o]),
sin(x[THETA_o])*sin(x[THETA_o]), cos(x[THETA_o]) );
for each(texel_value t in texel_coordinates)
{
Number f = dot(wi_c, N);
Number T = t.value;
obj_value += f - T;
}
And this is the gradient of the objective function, in order to calculate
it I had to do the math in Cartesian coordinates, consequently by
converting the spherical coordinates to Cartesian a lot of trigonometric
functions appear:
(note: all vectors are normalized, the 'r' coordinate in spherical
coordinates can be ignored)
grad_f[THETA_N] =
cos(x[THETA_N])*sin(x[THETA_i])*cos(x[PHI_N]-x[PHI_i])-sin(x[THETA_N])*cos(x[THETA_i]);
grad_f[PHI_N] = -sin(x[THETA_N])*sin(x[THETA_i])*sin(x[PHI_N]-x[PHI_i]);
grad_f[THETA_i] =
sin(x[THETA_N])*cos(x[THETA_i])*cos(x[PHI_N]-x[PHI_i])-cos(x[THETA_N])*sin(x[THETA_i]);
grad_f[PHI_i] = -sin(x[THETA_N])*sin(x[THETA_i])*sin(x[PHI_N]-x[PHI_i]);
grad_f[THETA_o] = 0.0;
grad_f[PHI_o] = 0.0;
I haven't specified constraints, so I don't have the Jacobian of the
constraints.
As for the Hessian of the Lagrangian, I did similar calculations as for the
gradient.
Running IPOPT gives me an output that is not very satisfactory.
Unfortunately I don't have the means to validate the output.
I know that the value of the IPOPT run give significantly different
values depending on the starting point.
Can someone assist me on this?
Am I doing any mistake?
Do I need constraints?
Best Regards
Nuno Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20120919/37ab081d/attachment.html>
More information about the Ipopt
mailing list