PACKAGE OPTIM - fmincon

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

PACKAGE OPTIM - fmincon

steph

I have the following function works in Matlab, but not in Octave, the error message is

 

error: lbound: wrong dimensions

error: called from

    __apply_param_config_vectors__ at line 37 column 11

    fmincon at line 311 column 5

 

I have tried  transpose of lower bound, i.e.   x0_lb = [-100,0]’ but then same message, except that upper bound now has wrong dimension, then I took transpose of X0_ub and message reverts back to lower bound has wrong dimension.

 

Any assistance will be appreciated.

 

FUNCTION is

 

function [ k1, k2, RMSE ] = fn_FIT_WLF( aT_measured, Tref, T )

% WLF Shift Function

%   Note: temperatures are in K, and aT is input

%   In this function the constants C1 and C2 in WLF function

%   is calculated that minimize the error in aT

%   at temperature (T) for reference temperature (Tref)

 

% calculate the RMSE

fun_WLF = @(x)fn_WLF_RMSE( x, aT_measured, Tref, T );

x0_lb = [-100,0];  % lower bound of C1, C2

x0_ub = [200,200]; % upper bound of C1, C2

x0 = [-15,80];     % initial estimate of C1, C2

 

[x, RMSE] =...

    fmincon(fun_WLF, x0, [], [], [], [], x0_lb, x0_ub);

   

k1 = x(1);

k2 = x(2);

 

end

 

Steph Bredenhann PrEng, PrCPM

 



Reply | Threaded
Open this post in threaded view
|

Re: PACKAGE OPTIM - fmincon

Olaf Till-2
On Fri, Feb 14, 2020 at 01:55:49PM +0200, [hidden email] wrote:

> I have the following function works in Matlab, but not in Octave, the error
> message is
>
> error: lbound: wrong dimensions
>
> error: called from
>
>     __apply_param_config_vectors__ at line 37 column 11
>
>     fmincon at line 311 column 5
>
> I have tried  transpose of lower bound, i.e.   x0_lb = [-100,0]' but then
> same message, except that upper bound now has wrong dimension, then I took
> transpose of X0_ub and message reverts back to lower bound has wrong
> dimension.
The 'fmincon' in Octaves optim package requires x0, x0_lb, and x0_ub
to be column vectors. This is probably a bug, since Matlabs 'fmincon'
seems to accept arbitrary arrays at least for x0. You may want to file
a bug report so I don't forget to deal with the issue.

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: PACKAGE OPTIM - fmincon

steph
Thanks Olaf

The documentation actually states that that those must be column vectors,
see https://octave.sourceforge.io/optim/function/fmincon.html

I have now made sure that mine are column vectors but I still get same
message, therefore I have changed my code to use nonlin_min, but I want to
maintain Matlab compatibility to avoid two sets of code. I am new at Octave
and I love Octave.

And to be complete, I use Octave 5.2 on Win10 and optim is version 1.6.0.

Steph


-----Original Message-----
From: Olaf Till <[hidden email]>
Sent: Saturday, 15 February 2020 12:54
To: [hidden email]
Cc: [hidden email]
Subject: Re: PACKAGE OPTIM - fmincon

On Fri, Feb 14, 2020 at 01:55:49PM +0200, [hidden email] wrote:

> I have the following function works in Matlab, but not in Octave, the
> error message is
>
> error: lbound: wrong dimensions
>
> error: called from
>
>     __apply_param_config_vectors__ at line 37 column 11
>
>     fmincon at line 311 column 5
>
> I have tried  transpose of lower bound, i.e.   x0_lb = [-100,0]' but then
> same message, except that upper bound now has wrong dimension, then I
> took transpose of X0_ub and message reverts back to lower bound has
> wrong dimension.

The 'fmincon' in Octaves optim package requires x0, x0_lb, and x0_ub to be
column vectors. This is probably a bug, since Matlabs 'fmincon'
seems to accept arbitrary arrays at least for x0. You may want to file a bug
report so I don't forget to deal with the issue.

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



Reply | Threaded
Open this post in threaded view
|

Re: PACKAGE OPTIM - fmincon

nrjank


On Sat, Feb 15, 2020, 6:10 AM <[hidden email]> wrote:
Thanks Olaf

The documentation actually states that that those must be column vectors,
see https://octave.sourceforge.io/optim/function/fmincon.html

True, but if MATLAB allows either dimension is is a compatibility bug and should be filed as one at bugs.octave.org


Reply | Threaded
Open this post in threaded view
|

RE: PACKAGE OPTIM - fmincon

steph

I’ll log the “bug”, but at the moment I can’t login to bugs.octave.org, I have sent an email for assistance.

 

Steph Bredenhann PrEng, PrCPM

 

From: Nicholas Jankowski <[hidden email]>
Sent: Saturday, 15 February 2020 22:25
To: [hidden email]
Cc: Olaf Till <[hidden email]>; Help GNU Octave <[hidden email]>
Subject: Re: PACKAGE OPTIM - fmincon

 

 

On Sat, Feb 15, 2020, 6:10 AM <[hidden email]> wrote:

Thanks Olaf

The documentation actually states that that those must be column vectors,
see https://octave.sourceforge.io/optim/function/fmincon.html

True, but if MATLAB allows either dimension is is a compatibility bug and should be filed as one at bugs.octave.org



Reply | Threaded
Open this post in threaded view
|

Re: PACKAGE OPTIM - fmincon

Olaf Till-2
On Sat, Feb 15, 2020 at 11:16:03PM +0200, [hidden email] wrote:
> I’ll log the “bug”, but at the moment I can’t login to
> bugs.octave.org <http://bugs.octave.org> , I have sent an email for
> assistance.
>

Filing the bug shoudn't be essential anymore, since I already
submitted a fix, which should be available with the next release of
the optim package. (It is also possible to install the last repository
version of the package without a release.)

The fix should handle parameters and bounds in a more
Matlab-compatible way, thereby solving your problem, too.

But I don't understand why calling fmincon and even nonlin_min with
the currently required input sizes didn't work for you. Maybe you
should post a full example.

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



signature.asc (849 bytes) Download Attachment