How do I use GlobalSearch to find global minimum?

Hi
I'm trying to find a global minimum when fitting my function to my dataset
% ramaniw = @(p,freq) ramani_4s(p,freq,constants(1,:),M0_wm,theta,linesh);
ramanig = @(p,freq) ramani_4s(p,freq,constants(2,:),M0_gm,theta,linesh);
opts = optimset;%('Algorithm','trust-region-reflective');
problemw = createOptimProblem('lsqcurvefit','objective',ramaniw,'x0',ptsw,'xdata',freq,...
'ydata',ydata_wm,'lb',lb,'ub',ub,'options',options);
problemg = createOptimProblem('lsqcurvefit','objective',ramanig,'x0',ptsg,'xdata',freq,...
'ydata',ydata_gm,'lb',lb,'ub',ub,'options',options);
gs = GlobalSearch;
[xw,fw,exitflagw,outputw] = run(gs,problemw);
but I get the following error:
Error using AbstractGlobalSolver/checkProblem (line 227) Invalid problem structure: missing required field or invalid field value.
Error in GlobalSearch/run (line 305) obj.checkProblem(problem, probRequiredFields, probValidValues);
Error in main_mt_s (line 108) [xw,fw,exitflagw,outputw] = run(gs,problemw);
Does any of you know what I do wrong? Thank you for your help!
Best regards Nanna

Answers (2)

It seems to me that you wrote
opts = optimset(...)
but then you passed options, not opts:
problemg = createOptimProblem(...,'options',options);
Should be
problemg = createOptimProblem(...,'options',opts);
Alan Weiss
MATLAB mathematical toolbox documentation

3 Comments

Thank you very much for your answer, but this did not solve the problem (I had, by mistake, defined the options twice, both as 'options' and 'opts'). I still get the same error.
Do you have any other ideas? Thank you very much for your time and help!
Nanna
Perhaps you can show us your problem structure so that we can see why GlobalSearch throws this error. I mean, enter "problemw" at the command line, and copy-paste the result to this newsgroup, formatted properly with the {}Code tool.
Alan Weiss
MATLAB mathematical toolbox documentation
Hi again, and sorry, it didn't see your comment back.
The problem structure is as follows:
objective: [function_handle]
x0: [3 0.1000 0.0700 1.0000e-05]
xdata: [7x1 double]
ydata: [7x4 double]
lb: [0 0 0 0]
ub: [10 1 0.1000 1.0000e-03]
solver: 'lsqcurvefit'
options: [1x1 struct]
It might be that 'function_handle' in objective. My function is dependant on two variables, p and xdata, where p contains the 4 unknown parameters I would like to find. In the above, the objective function is given like this:
@(p,xdata) ramani_4s(p,xdata,constants(1,:),theta,linesh);
I have tried giving the objective function without the function handle:
ramani_4s(p,xdata,constants(1,:),theta,linesh);
but then it reacts to p as it is undefined: Undefined function or varaible 'p'.
Thank you for your help!
Nanna

Sign in to comment.

I am puzzled. Did you try running lsqcurvefit on the problem structure? If so, what happened? If not, please try it, as suggested in the documentation (step 10).
Alan Weiss
MATLAB mathematical toolbox documentation

1 Comment

Thank you very much for all your help. I gave up on the Global search as I had limited time to find a solution. I tried running lsqcurvefit on the problem and I did as suggested in the documentation, but nothing worked. But thank you for your input!! Nanna

Sign in to comment.

Asked:

on 14 Apr 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!