[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optimisation based on index of data
From: |
inor0627 |
Subject: |
Re: Optimisation based on index of data |
Date: |
Thu, 21 Jan 2016 01:17:23 -0800 (PST) |
NJank wrote
> On Wed, Jan 20, 2016 at 6:18 AM, inor0627 <
> ingo.ortlepp@
> >
> wrote:
>
>> I have some 1D measuring data and try to find the subset with best
>> linearity. The following approach
>>
>> lin_error = @(start_idx) range( detrend(
>> data(round(start_idx):round(start_idx)+interesting_length) ) );
>> start_opt = round(fminsearch(lin_error,guess));
>>
>> works fine for some measurements, but in most cases fminsearch violates
>> the
>> bounds of 'data' ('index out of bound') as the optimal subset is near the
>> end of 'data'.
>>
>> So there are 2 questions:
>> Is fminsearch the right choice for this integer-type optimisation? I have
>> a
>> bad feeling due to the resulting discontinuities in 'lin_error' when
>> rounding 'start_idx'. A google search for 'octave integer optimization'
>> didn't answer this question to me.
>> If fminsearch is ok for this task, how can I handle the bounds of 'data'?
>>
>
> Well, fminsearch is an unconstrained optimization method, when you have a
> constrained data set (max(idx) <= numel(data) ). You could try another
> routine that allows you to set bounds for the solver. I'm only familiar
> with single variable routines, however, I believe in Matlab fmincon can do
> multivariable optimization with bounds specified (so you could specify
> [1,numel(data)] as your bounds.
>
> however, a quick look seems to show that this function has not yet been
> implemented in the Octave optim package, unless someone has a working copy
> that just hasn't hit the released version of the package yet.
>
> Nick J
Hello Nick,
thanks for your advice. I wasn't aware of routines supporting the setting of
bounds as I have not needed them until now.
After some testing it became apparent that fminbnd is suitable for my task,
so
start_opt = fminbnd( lin_error , 0 , length(data)-interesting_length );
results in the correct Minimum, which I checked by calculating all possible
'start_idx' by brute-force (Thank you Olaf for that suggestion).
So for the future measuring data I will go on with fminbnd.
Regards,
Ingo
--
View this message in context:
http://octave.1599824.n4.nabble.com/Optimisation-based-on-index-of-data-tp4674457p4674473.html
Sent from the Octave - General mailing list archive at Nabble.com.