This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Parameter vectors declared as const in minimized functions


My opinion is that you should be very careful by doing in this way. I think that gsl provides only unconstrained optimization approaches (correct me if I am wrong), but you artificially introduces bounds constraints. The descent directions can then lie in the unfeasible region, so the optimization procedure could behave poorly, or simply break down. Moreover, you can have problems by computing gradients components at or near the bounds constraints. This again could introduces difficulties for the optimization. While I am not involved in the development of gsl, it seems therefore reasonable to me to use the const indentifier.

You should check if there is any bounds-constrained solver, or try a barrier approach to force the iterates to be feasible at each step of the optmization.

Fabian

Andrej Prsa wrote:

Hi,



I have a question about (multidimensional) minimization functions; why
does a first argument to the function have to be a const gsl_vector *
type? I understand one should not attempt to change the contents of
this vector during unconstrained minimization, since that's
minimizer's job, but doesn't it unnecessarily restrict the method?


I hope I didn't understand what you are trying to say ...

In the c programming language, a 'const' function parameter just means
that the subroutine promises not to alter the value of that parameter.
It does not mean that the caller needs to also declare it as a const.



But of course. I'm not trying to ask whether it's legal to pass a value to the function taking const, I'm trying to say that in particular cases (e.g. when minimizing the cost function instead of any analytic function) you may want to change the argument to that function. Consider the following snippet:

/* Not actually compiled and tested */

int f (const int *arg)
 {
 if (*arg > 5) *arg -= 5;
 return *arg+2;
 }

int main ()
 {
 int var = 10;
 printf ("Result: %d\n", f(&var));
 return 0;
 }

Now obviously you pass to f() whatever (int *), but the if statement in
the f() function cannot be done, because arg is read-only, as is assured
by the keyword const.

Best wishes,

Andrej





-- Dr Fabian Bastin | Tel: +33(0)561193014 Chercheur Post-Doctoral | Fax: +33(0)561193030 CERFACES, Toulouse, France | email: bastin@cerfacs.fr http://www.fundp.ac.be/~fbastin | JabberID: slashbin@jabber.org




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]