Good video, would it be possible to run a Simulink model within a loop, saving outputs to use as the data each time and change workspace variables to optimise how the model runs?
Thank you John, this is an excellent video! Thank you for the tutorial! My problem is that I wrote the same command with you . But the results I got are dependent on the random number I gave to P0 at the beginning, which means that if I input p0=[1,2] and p0=[2,3], I will get a totally different Popt. I don't know even how to describe this problem in Google >
Initial guesses are important, especially with less powerful solvers. See the Gekko solution to the same problem here: apmonitor.com/che263/index.php/Main/PythonDataRegression
I am trying to do regression non-linear on a data of force-displacement. I would like to ask how to know the equation in advance (as you mostly do know at the start of your videos related to regression) without doing the fit first? I have a data with strain-hardening behavior
Coming up with the correct form of the equation is typically based on physics-based principles. Another approach is to use machine learning where the equations are determined by the algorithm: apmonitor.com/pds/ (see Regression section).
Another great video! I commented extensively on one of your other videos. I have further narrowed it down to the following: I keep getting this error: "Error using fmincon (line 619) Supplied objective function must return a scalar value." I think its due to the fact that I have more than one set of xm and ym's, i.e. [xm, ym; xm, ym; ....;......]. Any comments?
You may need to wait for the video to buffer for 1080p video resolution. Higher quality video is available but may be limited by your bandwidth. This method should also work with noisy data. See apmonitor.com/che263/index.php/Main/PythonRegressionStatistics for another example with a user-defined function.
excuse me. thanks for the great tutorial. but, I want to ask something. in initial, there is the function y = p1 + (p2/x) + ln(x)*p3. is that equation an objective function for optimization? if it is so, what is the constraint? and, I think xm and ym can be plotted in excel file, so we shouldn't put xm and ym in MATLAB script. i.e. we import it from excel to MATLAB as an alternative. could it be? thank u so much.
No, the equation is the constraint. The objective function is a measure of how well the data fits the predicted output (y) based on the input xm such as (y-ym).^2 Here is information on importing data files into Matlab: apmonitor.com/che263/index.php/Main/MatlabDataAnalysis It is easier if you save the file as a CSV type first.
Great video I tried to use this code with a p(1) + p(2).*x+p(3).*(x).^2 and this error pops up Unrecognized function or variable 'getIpOptions'. Error in fmincon (line 822) options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01); Error in Program1 (line 323) popt = fmincon(obj,p0); The code is the same as yours and i don't know what to do
It sounds like it could be a problem with your MATLAB installation or compatibility of a toolbox. APMonitor MATLAB toolbox is another option if that doesn't work for you: apmonitor.com/che263/index.php/Main/MatlabDataRegression or you could try Python: apmonitor.com/che263/index.php/Main/PythonDataRegression
Sir thnx for ur tutorial! but I have a problem, Where I want to solve an error regression with an objective function contains a parameter contains three values at the same time, one always remains fixed and for the other two takes a value it depends on tells conditions how I can do that please !
fmincon is a general purpose solver while polyval is just for fitting polynomials to data. See apmonitor.com/che263/index.php/Main/MatlabOptimization and apmonitor.com/che263/index.php/Main/MatlabDataRegression
Hello sir,it is really very usefull lesson. I am facing trouble and I hope to help me in coding. I want to separate the coeffisions to solve advace problems like below p1=4 p2=.54 p3=-0.1 yp =@(p1,p2,p3) p1+p2./xm +log (xm).*p3 obj=@(p1,p2,p3) sum ((yp (p1,p2,p3)-ym)./ym).^2) p_ottimal =fmincon (pbjective,(p1,p2,p3)) i found error in fmincon can you help me
If it's an error that it didn't converge then you may need to give better guess values for the optimizer. If it still isn't solving then a better optimizer such as APM Matlab may be better.
Very helpful, thanks! Couldn't get the constraints to work before watching this video :)
Thank you
Thank you so much for this great tutorial! Cheers
You are welcome!
Thank you for this great tutorial
@15:23: Modifying line 27 from 'lb = ones(3)*0.2' to 'lb = ones(1,3)*0.2;' removes the warning message (Length of lower bounds is > length(x) ...).
Thanks for the tip!
Hi, how about if the function is in complex number form. eg: y (x) = A(x) + B(x)*i . Thanks
Does this help? www.mathworks.com/help/optim/ug/complex-numbers-in-optimization-toolbox-solvers.html
Good video, would it be possible to run a Simulink model within a loop, saving outputs to use as the data each time and change workspace variables to optimise how the model runs?
Very well explained... Great... I have one doubt. How to verify that the optimized value is global optima not the local one?
The methods I share use local optimizers. You could try a multi-start method where you give the local optimizer different initial conditions.
Thank you John, this is an excellent video! Thank you for the tutorial! My problem is that I wrote the same command with you . But the results I got are dependent on the random number I gave to P0 at the beginning, which means that if I input p0=[1,2] and p0=[2,3], I will get a totally different Popt. I don't know even how to describe this problem in Google >
Initial guesses are important, especially with less powerful solvers. See the Gekko solution to the same problem here: apmonitor.com/che263/index.php/Main/PythonDataRegression
I am trying to do regression non-linear on a data of force-displacement. I would like to ask how to know the equation in advance (as you mostly do know at the start of your videos related to regression) without doing the fit first? I have a data with strain-hardening behavior
Coming up with the correct form of the equation is typically based on physics-based principles. Another approach is to use machine learning where the equations are determined by the algorithm: apmonitor.com/pds/ (see Regression section).
Can we use fmincon with two independent variables. Also can you please show how to use fmincon for finding global minimum.
Another great video! I commented extensively on one of your other videos. I have further narrowed it down to the following: I keep getting this error: "Error using fmincon (line 619)
Supplied objective function must return a scalar value." I think its due to the fact that I have more than one set of xm and ym's, i.e. [xm, ym; xm, ym; ....;......]. Any comments?
The error is because the objective function must always return a single number.
thankyou
its awesome.video quality is not good.plz makes videos on the fitting of large noisy by using user-defined functions.
You may need to wait for the video to buffer for 1080p video resolution. Higher quality video is available but may be limited by your bandwidth. This method should also work with noisy data. See apmonitor.com/che263/index.php/Main/PythonRegressionStatistics for another example with a user-defined function.
excuse me. thanks for the great tutorial. but, I want to ask something. in initial, there is the function y = p1 + (p2/x) + ln(x)*p3. is that equation an objective function for optimization? if it is so, what is the constraint? and, I think xm and ym can be plotted in excel file, so we shouldn't put xm and ym in MATLAB script. i.e. we import it from excel to MATLAB as an alternative. could it be? thank u so much.
No, the equation is the constraint. The objective function is a measure of how well the data fits the predicted output (y) based on the input xm such as (y-ym).^2 Here is information on importing data files into Matlab: apmonitor.com/che263/index.php/Main/MatlabDataAnalysis It is easier if you save the file as a CSV type first.
@@apm thank u so much for the answer, professor 👍👍👍
I getting this error: "Error in fmincon (line 859)
options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01)"
Check the MathWorks website for that specific option. Here is some help on fmincon: apmonitor.com/che263/index.php/Main/MatlabOptimization
Great video I tried to use this code with a p(1) + p(2).*x+p(3).*(x).^2 and this error pops up
Unrecognized function or variable 'getIpOptions'.
Error in fmincon (line 822)
options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01);
Error in Program1 (line 323)
popt = fmincon(obj,p0);
The code is the same as yours and i don't know what to do
It sounds like it could be a problem with your MATLAB installation or compatibility of a toolbox. APMonitor MATLAB toolbox is another option if that doesn't work for you: apmonitor.com/che263/index.php/Main/MatlabDataRegression or you could try Python: apmonitor.com/che263/index.php/Main/PythonDataRegression
What should we do if we want the sum of the errors?
You can compute it with sum((ym-yp).^2) where ym is your vector of measurements and yp is your vector of predicted values.
Sir thnx for ur tutorial! but I have a problem, Where I want to solve an error regression with an objective function contains a parameter contains three values at the same time, one always remains fixed and for the other two takes a value it depends on tells conditions how I can do that please !
Yes, you can do multivariate regression. You can additional parameters to the model.
@@apm OK thnx, I will try
What's the difference of fmincon and Polyval? Does polyval return same results as of fmincon for a given set of data?
fmincon is a general purpose solver while polyval is just for fitting polynomials to data. See apmonitor.com/che263/index.php/Main/MatlabOptimization and apmonitor.com/che263/index.php/Main/MatlabDataRegression
Hello sir,it is really very usefull lesson. I am facing trouble and I hope to help me in coding. I want to separate the coeffisions to solve advace problems like below
p1=4
p2=.54
p3=-0.1
yp =@(p1,p2,p3) p1+p2./xm +log (xm).*p3
obj=@(p1,p2,p3) sum ((yp (p1,p2,p3)-ym)./ym).^2)
p_ottimal =fmincon (pbjective,(p1,p2,p3))
i found error in fmincon can you help me
If it's an error that it didn't converge then you may need to give better guess values for the optimizer. If it still isn't solving then a better optimizer such as APM Matlab may be better.
@@apm Thank you soo much