[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fmincon - fminsearch : constrained simplex optimization in Octave?
From: |
Etienne Grossmann |
Subject: |
Re: fmincon - fminsearch : constrained simplex optimization in Octave? |
Date: |
Sat, 11 Nov 2006 11:43:30 -0500 |
User-agent: |
Mutt/1.4.2.1i |
Hi,
from help inline:
======================================================================
-- Built-in Function: inline (STR)
-- Built-in Function: inline (STR, ARG1, ...)
-- Built-in Function: inline (STR, N)
Create an inline function from the character string STR. If
called with a single argument, the arguments of the generated
function are extracted from the function itself. The generated
function arguments will then be in alphabetical order. It should
be noted that i, and j are ignored as arguments due to the
ambiguity between their use as a variable or their use as an
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
inbuilt constant. >>>> All arguments followed by a parentheses are
considered to be functions. <<<<<<
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If the second and subsequent arguments are character strings,
they
are the names of the arguments of the function.
If the second argument is an integer N, the arguments are `"x"',
`"P1"', ..., `"PN"'.
See also: argnames, formula, vectorize.
======================================================================
So that inline creates a function w/ no argument:
======================================================================
octave:14> inline('(x(1)-5).^2+(x(2)-8).^4')
ans =
f() = (x(1)-5).^2+(x(2)-8).^4
======================================================================
A fix is:
======================================================================
octave:15> fmins(inline('(x(1)-5).^2+(x(2)-8).^4',0),[0;0])
ans =
4.9998
7.9918
======================================================================
Hth,
Etienne
On Sat, Nov 11, 2006 at 11:38:39AM +0000, baptiste auguie wrote:
# Hello,
#
# Thanks to your advice, I've installed Octave-Forge and I'm trying the
# different optimization routines available <http://
# octave.sourceforge.net/index/optimization.html#Minimization>. Without
# much success for my first try :(
#
# Here is the test example from fmins documentation and the result I get,
#
# > octave:1> fmins(inline('(x(1)-5).^2+(x(2)-8).^4'),[0;0])
# > error: `x' undefined near line 0 column 6
# > error: evaluating binary operator `-' near line 0, column 10
# > error: evaluating binary operator `.^' near line 0, column 13
# > error: evaluating binary operator `+' near line 0, column 16
# > error: called from `?unknown?'
# > error: evaluating binary operator `*' near line 63, column 12
# > error: evaluating assignment expression near line 63, column 6
# > error: called from `nmsmax' in file `/sw/share/octave/2.1.72/site/m/
# > octave-forge/optim/nmsmax.m'
# > error: evaluating assignment expression near line 78, column 9
# > error: called from `fmins' in file `/sw/share/octave/2.1.72/site/m/
# > octave-forge/optim/fmins.m'
#
# I've tried with a simpler function, in a different file (not inline),
# with the same error.
#
# I get the same sort of error for nelder_mead_min :
#
# > error: `x' undefined near line 3 column 4
# > error: evaluating binary operator `-' near line 3, column 5
# > error: evaluating binary operator `^' near line 3, column 8
# > error: evaluating assignment expression near line 3, column 2
# > error: called from `toto' in file `/Users/.../SPPfit/toto.m'
#
# where toto.m is the most basic function,
#
# > function f=toto(x)
# > f=(x-2)^2;
# > endfunction
#
# same thing for samin,
#
# > error: `x' undefined near line 2 column 10
# > error: evaluating argument list element number 1
# > error: evaluating binary operator `+' near line 2, column 13
# > error: evaluating assignment expression near line 2, column 4
# > error: called from `f' in file `/Users/.../SPPfit/f.m'
# > error: evaluating argument list element number 1
#
#
# Is there something wrong in my install of Octave-forge? I installed
# it using Fink for Mac OS. Octave seems to call the right functions,
# but they don't behave as I'd expect!
#
# Best wishes
#
# baptiste
# _______________________________________________
# Help-octave mailing list
# address@hidden
# https://www.cae.wisc.edu/mailman/listinfo/help-octave
--
Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne