matRad_SquaredDeviation

Purpose ^

Synopsis ^

This is a script file.

Description ^

Cross-reference information ^

This function calls: This function is called by:

Subfunctions ^

Source code ^

0001 classdef matRad_SquaredDeviation < DoseObjectives.matRad_DoseObjective
0002 % matRad_SquaredDeviation Implements a penalized least squares objective
0003 %   See matRad_DoseObjective for interface description
0004 %
0005 % References
0006 %     -
0007 %
0008 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0009 %
0010 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0011 %
0012 % Copyright 2015 the matRad development team.
0013 %
0014 % This file is part of the matRad project. It is subject to the license
0015 % terms in the LICENSE file found in the top-level directory of this
0016 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0017 % of the matRad project, including this file, may be copied, modified,
0018 % propagated, or distributed except according to the terms contained in the
0019 % LICENSE file.
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             %If we have a struct in first argument
0038             if nargin == 1 && isstruct(penalty)
0039                 inputStruct = penalty;
0040                 initFromStruct = true;
0041             else
0042                 initFromStruct = false;
0043                 inputStruct = [];
0044             end
0045             
0046             %Call Superclass Constructor (for struct initialization)
0047             obj@DoseObjectives.matRad_DoseObjective(inputStruct);
0048             
0049             %now handle initialization from other parameters
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         %% Calculates the Objective Function value
0062         function fDose = computeDoseObjectiveFunction(obj,dose)
0063             % deviation : dose minus prefered dose
0064             deviation = dose - obj.parameters{1};
0065             % claculate objective function
0066             fDose = obj.penalty/numel(dose) * (deviation'*deviation);
0067         end
0068         
0069         %% Calculates the Objective Function gradient
0070         function fDoseGrad   = computeDoseObjectiveGradient(obj,dose)
0071             % deviation : Dose minus prefered dose
0072             deviation = dose - obj.parameters{1};
0073             
0074             % calculate delta
0075             fDoseGrad = 2 * obj.penalty/numel(dose) * deviation;
0076         end
0077     end
0078     
0079 end

| Generated by m2html © 2005