GA or PatternSearch optimization using a parallel pool
3 views (last 30 days)
Show older comments
I am trying to optimize a function using multiple cores. My function is a function of 29 variables, and it returns a scalar (of course, inside the function there's a lot going on, which is why it's a little slow and I want to parallelize). When I evaluate the function at any value, it returns an answer no problem. When I try to optimize it using say fminsearch, it plows along. When instead i try to parallelize using a GA or patternSearch, it evaluates the function once, but then throws the error I paste below. The function itself seems to be perfectly fine when I evaluate it. I feel i may be overlooking something silly.
Thanks in advance for any help!
Error using LogLike_allin_vectorized
Incorrect dimensions for matrix multiplication. Check that the number of columns in
the first matrix matches the number of rows in the second matrix. To operate on
each element of the matrix individually, use TIMES (.*) for elementwise
multiplication.
Error in parallel.internal.constant.FunctionBasedData>@(Q)(-LogLike_allin_vectorized(Q,N_papers,N_draws,N_authors,DAT_MAT_RHS_Draws_example,sex(1:N_papers,:),lib_dummy(1:N_papers,:),T_Panelids_x,T_Panelids_y,unique_panelids))
Error in funevaluate (line 40)
f = feval(FUN,reshapeinput(Xin,X),varargin{:});
Error in psnextfeasible (line 68)
parfor (k = 1:maxeval)
Error in poll/classic_poll (line 91)
psnextfeasible(ObjFunc,Xin,sites,Iterate,linConstr.Aineq,linConstr.bineq,...
Error in poll (line 61)
classic_poll();
Error in pfminbnd (line 61)
[successPoll,nextIterate,optimState] = poll(FUN,X,Iterate,MeshSize,linConstr, ...
Error in patternsearch (line 294)
[X,FVAL,EXITFLAG,OUTPUT] = pfminbnd(FUN,X0,optimState,linConstr,Iterate, ...
1 Comment
Gyan Vaibhav
on 27 Feb 2024
Hi Camilo,
The error message indicates only that there might be an illegal matrix multiplication due to dimension mismatch. But since your code works for normal evaluation, can you share the code so that it's possible to understand what might be the problem.
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!