help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about fmins!


From: Michael Creel
Subject: Re: Question about fmins!
Date: Tue, 12 Jun 2007 15:00:33 +0200
User-agent: Thunderbird 1.5.0.12 (X11/20070604)

Hmm, I don't see any problem. I put the following in a file named test.m

Contents of test.m:
-------- cut here -------------
1;
function a = f(x)
        a = cos(x) + 0.01*(x-pi)^2;
endfunction

# Set up the controls:
ub = 20;
lb = -ub;
nt = 20;
ns = 5;
rt = 0.5;
maxevals = 1e10;
neps = 5;
functol = 1e-10;
paramtol = 1e-5;
verbosity = 1;
minarg = 1;

# Put them in a cell array:
control = {lb, ub, nt, ns, rt, maxevals, neps, functol, paramtol, verbosity, minarg};

# Call the minimizer (function argument also in cell array):
samin("f", {-8}, control)

-------- cut here -------------

Then I run it from octave, and I get

octave:2> test

================================================
SAMIN results

Normal convergence

Convergence tolerances: Func. tol. 1.000000e-10 Param. tol. 1.000000e-05
Obj. fn. value -1.000000

           parameter        search width
            3.141593            0.000009
================================================
ans =  3.1416
octave:3>

How did you obtain samin? If you think you might have an old version, please get the newest one from http://octave.cvs.sourceforge.net/*checkout*/octave/octave-forge/main/optim/src/samin.cc?revision=1.8
and compile it using "mkoctfile samin.cc"
Cheers, M.

rambovn wrote:
Thank you very much for your help. I read about samin and tried the example
that Octave provided, but it appeared error :O:O. Here is the example:

function a = f(x)
        a = cos(x) + 0.01*(x-pi)^2;
endfunction

Set up the controls:
ub = 20;
lb = -ub;
nt = 20;
ns = 5;
rt = 0.5;
maxevals = 1e10;
neps = 5;
functol = 1e-10;
paramtol = 1e-5;
verbosity = 2;
minarg = 1;

Put them in a cell array:
control = {lb, ub, nt, ns, rt, maxevals,
        neps, functol, paramtol, verbosity, minarg};

Call the minimizer (function argument also in cell array):
samin("f", {-8}, control)

error: samin: 1st element of controls must be LB: a vector of lower bounds

Do you know why? :-/
Thank you for your patience.
Regards
Anh


I ran across some Python bindings to the Fortran lbfgsb code by Nocedal and co-authors (http://www.ece.northwestern.edu/~nocedal/lbfgsb.html), at http://setiathome.ssl.berkeley.edu/~aparsons/python/aipy.lbfgsb.html

As far as I know, lbfgsb is about the state-of-the-art for minimization of differentiable functions of high-dimensional parameters, subject to bounds. Maybe someone who has experience with Octave/Fortran would like to try to make some bindings?

Otherwise, samin in octave-forge does bounds, without using derivatives.
It's a stochastic method. In spite of that, it is pretty quick for many problems. Etienne's suggestion is probably the first thing to try, though.
M.

/quote>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]