This is a script file.
0001 classdef matRad_SquaredDeviation < DoseObjectives.matRad_DoseObjective
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 properties (Constant)
0024 name = 'Squared Deviation';
0025 parameterNames = {'d^{ref}'};
0026 parameterTypes = {'dose'};
0027 end
0028
0029 properties
0030 parameters = {60};
0031 penalty = 1;
0032 end
0033
0034 methods
0035 function obj = matRad_SquaredDeviation(penalty,dRef)
0036
0037
0038 if nargin == 1 && isstruct(penalty)
0039 inputStruct = penalty;
0040 initFromStruct = true;
0041 else
0042 initFromStruct = false;
0043 inputStruct = [];
0044 end
0045
0046
0047 obj@DoseObjectives.matRad_DoseObjective(inputStruct);
0048
0049
0050 if ~initFromStruct
0051 if nargin == 2 && isscalar(dRef)
0052 obj.parameters{1} = dRef;
0053 end
0054
0055 if nargin >= 1 && isscalar(penalty)
0056 obj.penalty = penalty;
0057 end
0058 end
0059 end
0060
0061
0062 function fDose = computeDoseObjectiveFunction(obj,dose)
0063
0064 deviation = dose - obj.parameters{1};
0065
0066 fDose = obj.penalty/numel(dose) * (deviation'*deviation);
0067 end
0068
0069
0070 function fDoseGrad = computeDoseObjectiveGradient(obj,dose)
0071
0072 deviation = dose - obj.parameters{1};
0073
0074
0075 fDoseGrad = 2 * obj.penalty/numel(dose) * deviation;
0076 end
0077 end
0078
0079 end