optimization expression includes an integration
I am trying an optimization problem in which the expression of the objective function includes an integral.
It is obvious that the sigma equal to one results in the optimium solution. I want to use the optimization toolbox to get this result with an initial sigma equal to, say, 10.
I wrote the following code.
g1 = @(x,c) (exp(-(0.5*(x./c).^2))./sqrt(2*pi*c^2));
c = optimvar("c",1,1,’Type’,’continuous’,’LowerBound’,0.1,’UpperBound’,10);
prob = optimproblem(‘Objective’, (0.5 – integral(@(x)g1(x,c),0, 10)).^2);
[solf,fvalf,eflagf,outputf] = solve(prob)
The following error is generated.
Error using integralCalc>finalInputChecks (line 544)
Input function must return ‘double’ or ‘single’ values. Found
‘optim.problemdef.OptimizationExpression’.
I have two questions:
1, Am I coding the problem properly/correctly?
2, If the code is basically correct, how can I solve the error?
Thank you.I am trying an optimization problem in which the expression of the objective function includes an integral.
It is obvious that the sigma equal to one results in the optimium solution. I want to use the optimization toolbox to get this result with an initial sigma equal to, say, 10.
I wrote the following code.
g1 = @(x,c) (exp(-(0.5*(x./c).^2))./sqrt(2*pi*c^2));
c = optimvar("c",1,1,’Type’,’continuous’,’LowerBound’,0.1,’UpperBound’,10);
prob = optimproblem(‘Objective’, (0.5 – integral(@(x)g1(x,c),0, 10)).^2);
[solf,fvalf,eflagf,outputf] = solve(prob)
The following error is generated.
Error using integralCalc>finalInputChecks (line 544)
Input function must return ‘double’ or ‘single’ values. Found
‘optim.problemdef.OptimizationExpression’.
I have two questions:
1, Am I coding the problem properly/correctly?
2, If the code is basically correct, how can I solve the error?
Thank you. I am trying an optimization problem in which the expression of the objective function includes an integral.
It is obvious that the sigma equal to one results in the optimium solution. I want to use the optimization toolbox to get this result with an initial sigma equal to, say, 10.
I wrote the following code.
g1 = @(x,c) (exp(-(0.5*(x./c).^2))./sqrt(2*pi*c^2));
c = optimvar("c",1,1,’Type’,’continuous’,’LowerBound’,0.1,’UpperBound’,10);
prob = optimproblem(‘Objective’, (0.5 – integral(@(x)g1(x,c),0, 10)).^2);
[solf,fvalf,eflagf,outputf] = solve(prob)
The following error is generated.
Error using integralCalc>finalInputChecks (line 544)
Input function must return ‘double’ or ‘single’ values. Found
‘optim.problemdef.OptimizationExpression’.
I have two questions:
1, Am I coding the problem properly/correctly?
2, If the code is basically correct, how can I solve the error?
Thank you. #optimization #integral MATLAB Answers — New Questions