Conversion to double from optim.problemdef.OptimizationExpression is not possible.
이전 댓글 표시
Can anyone please help!!! I am trying to solve an optimization problem using MILP (problem-based approach)
'r' and 'q' are optimization variables
The following error occurred converting from optim.problemdef.OptimizationExpression to double: Conversion to double from optim.problemdef.OptimizationExpression is not possible.
How can I fix it????
nt = 24;
nh= 20;
Pbcd = 5*ones(nt,1);
Eb = 5*ones(nt,1);
Ebinv = (1/98)*ones(nt,1);
Pbc = q.*Pbcd.*Ebinv;
Pbd = r.*Pbcd.*Ebinv;
socb = zeros(nt,1);
socb(1,1) = 1;
for i= 2:nt
socb(i,1) = socb(i-1,1) + Pbc(i,1) - Pbd(i,1);
end
댓글 수: 3
Matt J
2018년 6월 25일
What line is the error occurring at?
Sohaib Rafique
2018년 6월 25일
natascia andrenacci
2020년 11월 13일
I have the same error in a similar problem. Did you manage to solve it?
답변 (2개)
Steven Lord
2018년 6월 25일
Please add these lines immediately before the start of your for loop then run your code and show us what gets displayed. It will show us the types of your variables and make sure you haven't accidentally shadowed the built-in ones function with a version that performs some optimization calculations.
which -all ones
whos
Alan Weiss
2018년 6월 25일
If you intend socb to be an optimization expression, then initialize it that way.
socb = optimexpr(nt,1); % Not zeros(nt,1)
socb(1,1) = 1;
Alan Weiss
MATLAB mathematical toolbox documentation
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!