Optimization problem gets stuck before going into solver
5 次查看(过去 30 天)
显示 更早的评论
I have defined my constraints and objective function for my optimization problem and I have selected fmincon as the solver using the command
opt = optimoptions('fmincon', 'MaxIterations', 1000, 'Algorithm', 'sqp');
However, the command window does even show the classical message "Solving problem using fmincon" after 30 minutes. So I think that matlab gets stuck even before that. Meanwhile the system is under "busy" condition. Then, when I stop it manually I get the following error:
Operation terminated by user during optim.internal.problemdef.visitor.CompileNonlinearFunction/getArgumentName In optim.internal.problemdef.visitor.CompileReverseADReversePass/getParentJacArgumentName In optim.internal.problemdef.visitor.CompileReverseADReversePass/visitOperatorTimes In optim.internal.problemdef.Times/acceptVisitor In optim.internal.problemdef.visitor.CompileReverseADReversePass/visitBinaryExpressionImpl In optim.internal.problemdef.BinaryExpressionImpl/acceptVisitor In optim.internal.problemdef.visitor.CompileReverseADReversePass/visitTree In optim.internal.problemdef.visitor.CompileReverseADReversePass/visitForest In optim.internal.problemdef.ExpressionForest/compileReverseAD In optim.problemdef.OptimizationExpression/compileReverseAD In optim.internal.problemdef.compile.compileNonlinearExprOrConstrWithAD In optim.internal.problemdef.compile.compileNonlinearObjective In optim.problemdef.OptimizationProblem/compileObjectives In optim.internal.problemdef.ProblemImpl/prob2structImpl In optim.internal.problemdef.ProblemImpl/solveImpl In optim.problemdef.OptimizationProblem/solve In routingGame (line 92) sol = solve(sysProb,x_init,'options',opt);
Does anybody have any idea?
Thanks in advance!
2 个评论
Nima
2023-11-28
If this is happenning at the "define objective" step, I have exactly faced the same issue recently with the surrogate optimization. It takes quite a while until MATLAB gets to the "solve" step and I haven't found any solution for that yet.
回答(1 个)
Alan Weiss
2023-11-20
It is apparent that solve is taking too long to calculate constraint derivatives using reverse-mode autodifferentiation. This might not happen in a new version of MATLAB, where internally there are smarter AD algorithms. However, you can lkely avoid this issue in all versions by turning off AD:
sol = solve(prob,ConstraintDerivative="finite-differences") % Maybe also ObjectiveDerivative="finite-differences"
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!