Home > atmatch > atGetPenalty.m

atGetPenalty

PURPOSE ^

SYNOPSIS ^

function penalty=atGetPenalty(ConstVal,Constraints)

DESCRIPTION ^

 
 Evaluate the penalty function (distance from the target value of every constraint)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function penalty=atGetPenalty(ConstVal,Constraints)
0002 %
0003 % Evaluate the penalty function (distance from the target value of every constraint)
0004 %
0005 vals=cat(2,ConstVal{:});
0006 low=cat(2,Constraints.Min);
0007 high=cat(2,Constraints.Max);
0008 weight=cat(2,Constraints.Weight);
0009 penalty=zeros(size(vals));
0010 
0011 toohigh=vals>high;
0012 toolow=vals<low;
0013 
0014 penalty(toohigh)=(vals(toohigh)-high(toohigh))./weight(toohigh);
0015 penalty(toolow)=(low(toolow)-vals(toolow))./weight(toolow);
0016 
0017 % check=~(toohigh|toolow);
0018 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005