cplex error in parallel run

2 次查看(过去 30 天)
Maziar Salahi
Maziar Salahi 2022-2-18
回答: TARUN 2025-6-12

I use cplex in parallel in matlab to solve some quadratic problems and get sometimes the following error.
An UndefinedFunction error was thrown on the workers for 'Undefined
function 'handleparams' for input arguments of type 'double'.'.
This might be because the file containing 'Undefined function
'handleparams' for input arguments of type 'double'.' is not
accessible on the workers. Use addAttachedFiles(pool, files) to
specify the required files to be attached. See the documentation
for 'parallel.Pool/addAttachedFiles' for more details.

Error in test_qcqp_rank1 (line 181)
OPTIM_new=One_Negative_Eig_new(2*Q,a,App,bpp,xlb,xub);

Caused by:
Error using cplexqcp
Undefined function 'handleparams' for input arguments of type
'double'.

回答(1 个)

TARUN
TARUN 2025-6-12
The error you're encountering (Undefined function handleparams for input arguments of type double) means that the MATLAB function handleparams.mis not available to the parallel workers when your code runs.
This usually happens in parallel computing because the workers run in their own space and don't automatically have access to all your local files. So, if your code uses a custom function like handleparams, you need to manually send that file to the workers.
To fix it, you can use this command before executing your parallel job:
addAttachedFiles(gcp, {'handleparams.m'});
This tells MATLAB to send the file to all the workers. Just make sure the file handleparams.m is in your current folder or somewhere on the MATLAB path.
Feel free to go through the following documentation:
Parallel Pool File Attachments:
gcp:

类别

Help CenterFile Exchange 中查找有关 MATLAB Mobile Fundamentals 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by