How to pass inequality constraints to surrogateopt?
6 views (last 30 days)
Show older comments
Hello,
I have a function that returns the objective and constraint functions to be passed to surrogateopt. However, I receve the following error about the constraint
Error using parallel.FevalFuture/fetchNext
The function evaluation completed with an error.
[~, self.pendingTrials(fetchID).output] = fetchNext(self.pendingTrials(fetchID).task);
trialResponse = self.modelMgr.getNext();
controller = controller.optimize();
xfinal = surrogateopt(objconstr,lb,ub,intcon, options);
Caused by:
Input arguments to function include colon operator. To input the colon character, use ':' instead.
The function that returns the constraint is as follows
[obj, con]=func1(a,b,c);
objconstr=@(x) struct('Fval',obj,'Ineq',con);
% lb ub, intcon and options have also been appropriately specified and supplied to the optimiser.
xfinal = surrogateopt(objconstr,lb,ub,intcon, options);
function [obj, con]=func1(a,b,c)
P=[];
obj=@func2;
con=@func3;
function obj=func2(x)
%many matrix operations that calculate P using a,b,c and a number
%of optimsiation variables "x"
P=somedummyoperation; %P is a nXM matrix
obj=sum(sum(P));
end
function con=func3
load('ref_vector_file','ref_vec');
buff_var=cross(P(1:2:3,:),ref_vec);
con=norm(buff_vec);
end
end
This code however runs when i remove the constraint and optimise (the solution is unacceptable since the problem is poorly defined in this case)
How would I choose to move ahead to to address the error?
0 Comments
Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!