Nevermind abs is not supported function https://www.mathworks.com/help/optim/ug/supported-operations-on-optimization-variables-expressions.html
abs cannot be used in problem-based optimization expression
조회 수: 7 (최근 30일)
이전 댓글 표시
Can someone tell me why I cannot use abs() in this simple setup.
prob = optimproblem();
x = optimvar('x',1,1);
y = 1;
x0 = struct('x',0);
prob.Objective = abs(x-y); % sum(abs(x-y)) also doesn't work
%prob.Objective = norm(x-y,1); % this however works
sol = solve(prob,x0)
If I use prob.Objective = norm(x-y,1) it wokks just fine
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Problem-Based Optimization and Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!