forked from e0404/APMtoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobFuncProb.m
More file actions
33 lines (24 loc) · 823 Bytes
/
obFuncProb.m
File metadata and controls
33 lines (24 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [objFunc,gradient] = obFuncProb(dij,Voxel,mOmega,w)
vOmega = mOmega * w;
if ~isfield(dij,'mAlphaDose')
d = dij.physicalDoseExp * w;
else
d = (dij.mAlphaDoseExp * w) + (dij.mSqrtBetaDoseExp * w).^2;
end
deviation = (d - Voxel.presDose');
deviation(Voxel.ixNT' == 1 & deviation < 0) = 0;
% calculate objective function value
objFunc = (Voxel.penalty' .* deviation)' * deviation + (w' * vOmega);
% calculate gradient
delta = 2 * (Voxel.penalty'.*deviation);
if nargout > 1
if ~isfield(dij,'mAlphaDose')
gradient = dij.physicalDoseExp' * delta + 2 * vOmega;
else
vBias = (delta' * dij.mAlphaDoseExp)';
quadTerm = dij.mSqrtBetaDoseExp * w;
mPsi = (2*(delta.*quadTerm)'* dij.mSqrtBetaDoseExp)';
gradient = vBias + mPsi + 2 * vOmega;
end
end
end