Optimization of weighted sum
20 ビュー (過去 30 日間)
古いコメントを表示
I want to optimize the weights of the sum , where z is depth (in cm), . The terms are vectors (representing dose) of size for with already fixed and know entry values. I need to optimize these weights such that in the region , where is a constant dose vector of size (see attached figure), in order to flatten the plateau as much as possible.
Could anyone help me with this problem?
Many thanks in advance for any guidance and consideration!
3 件のコメント
採用された回答
Matt J
2022 年 3 月 28 日
編集済み: Matt J
2022 年 3 月 28 日
You did not include Dconst or the corresponding z, so I eyeballed both from your attached .jpg image.
load Dose.mat
C=[D1,D2,D3,D4,D5,D6,D7,D8];
[m,n]=size(C);
Dconst=0.1*ones(m,1); %approximated from .jpg image
z=linspace(0,8.5,m); %approximated from .jpg image
bp=5.5<=z & z<=8.5; %Bragg peak interval
w=lsqlin(C(bp,:),Dconst(bp),[],[],ones(1,n),1,zeros(n,1),ones(n,1));
plot(z, [C*w,Dconst]); legend('Dtot','Dconst','location','southeast')
その他の回答 (1 件)
John D'Errico
2022 年 3 月 28 日
編集済み: John D'Errico
2022 年 3 月 28 日
First, LEARN TO USE ARRAYS!!!!!!!!
Don't create 8 different numbered variables. Why does that make sense, when you can create ONE array, call it Dose?
Dose = [D1,D2,D3,D4,D5,D6,D7,D8];
MATLAB is a MATRIX LANGUAGE. Learn to use it as such. Anyway, in order to use lsqlin, you will need an array.
Next, you don't actually provide Dtot. So is there a way we can help you more? Probably not really, if your goal is to truly achueve that specific dose goal. If your goal is to achieve an aggregate dose that is as large as possible over the entire region, then you might do this:
Daim = 0.12*ones(501,1); % unachievable, but who cares? Aim for the stars.
LB = zeros(1,8);
UB = ones(1,8);
A = ones(1,8); % equality constraint: the sum must be 1
B = 1;
W = lsqlin(Dose,Daim,[],[],A,B,LB,UB)
Minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
<stopping criteria details>
W =
0.0271916622048387
0.043945469132034
0.0555504667354272
0.0671084337012187
0.0905029933411581
0.113513538791469
0.167454011263868
0.434733424829987
plot(Dose*W)
In advance, I played with some numbers, wondering what the solution would look like. That is roughly what I found by hand, at least if your goal is a curve that looks vaguely like your plotted aim.
If you wanted a higher loading on the left end, you need something with some mass down there. However, by dropping the aim just a bit, you can flatten the result, just a bit.
Daim = 0.1*ones(501,1);
W = lsqlin(Dose,Daim,[],[],ones(1,8),1,zeros(1,8),ones(1,8))
Minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
<stopping criteria details>
W =
0.0800640800727342
0.0450974697116315
0.0615545440518655
0.0676444663541099
0.0843898048745855
0.110747769607969
0.135846098000183
0.414655767326922
plot(Dose*W)
This clearly has a flatter plateau, which you sort of indicated was your goal.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Biotech and Pharmaceutical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!