필터 지우기
필터 지우기

Can I use parfor and CVX togther

조회 수: 19 (최근 30일)
Ge Shi
Ge Shi 2021년 2월 15일
댓글: Ge Shi 2021년 2월 18일
Hi, I tried to use CVX toolbox inside the parfor loop for solving my optimization problems with different parameters, and the structure of my code is
parfor index_time=1:times
invoke function { cvx_begin
optimization problem
cvx_end }
end
Unfortunately, I received a warning as follows,
Warning: A non-empty CVX problem already exists in this scope.
It is being overwritten.
In cvxprob (line 28)
In cvx_begin (line 41)
In SSR (line 11)
In parallel_function>make_general_channel/channel_general (line 923)
In remoteParallelFunction (line 46)
The above warning showed the optimizaiton problem was overwritten. However, a lot of people mentioned cvx can work with parfor on the internet. I am so confused.

채택된 답변

Edric Ellis
Edric Ellis 2021년 2월 16일
I'm not familiar with the CVX toolbox. However, a lot of parfor problems can be remedied by pushing the body of the loop into a separate function, a bit like this:
parfor i = 1:N
out(i) = doCvxStuff(i);
end
function out = doCvxStuff(i)
% Something like whatever CVX needs...
invoke function { cvx_begin
optimization problem
cvx_end }
end
  댓글 수: 1
Ge Shi
Ge Shi 2021년 2월 18일
Thanks, Eric, I did the way you recommended, and I still receive the warning above.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by