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!