18 #ifndef __itkParticleTwoCostFunction_h 19 #define __itkParticleTwoCostFunction_h 21 #include "itkPSMCostFunction.h" 50 template <
unsigned int VDimension>
56 typedef SmartPointer<Self> Pointer;
57 typedef SmartPointer<const Self> ConstPointer;
77 virtual VectorType
Evaluate(
unsigned int idx,
unsigned int d,
78 const ParticleSystemType *system,
79 double &maxmove)
const;
80 virtual VectorType
Evaluate(
unsigned int idx,
unsigned int d,
81 const ParticleSystemType *system,
82 double &maxmove,
double &energy)
const;
83 virtual double Energy(
unsigned int idx,
unsigned int d,
84 const ParticleSystemType *system)
const;
88 const ParticleSystemType *system)
90 if (m_AOn) m_FunctionA->BeforeEvaluate(idx, d, system);
91 if (m_BOn) m_FunctionB->BeforeEvaluate(idx, d, system);
98 if (m_AOn) m_FunctionA->AfterIteration();
99 if (m_BOn) m_FunctionB->AfterIteration();
106 if (m_AOn) m_FunctionA->BeforeIteration();
107 if (m_BOn) m_FunctionB->BeforeIteration();
109 m_AverageGradMagA = 0.0;
110 m_AverageGradMagB = 0.0;
112 m_AverageEnergyA = 0.0;
113 m_AverageEnergyB = 0.0;
123 if (m_FunctionA.GetPointer() != 0) m_FunctionA->SetParticleSystem(p);
124 if (m_FunctionB.GetPointer() != 0) m_FunctionB->SetParticleSystem(p);
127 void SetDomainNumber(
unsigned int i)
129 Superclass::SetDomainNumber(i);
130 if (m_FunctionA.GetPointer() != 0) m_FunctionA->SetDomainNumber(i);
131 if (m_FunctionB.GetPointer() != 0) m_FunctionB->SetDomainNumber(i);
137 m_FunctionA->SetDomainNumber(this->GetDomainNumber());
138 m_FunctionA->SetParticleSystem(this->GetParticleSystem());
144 m_FunctionB->SetDomainNumber(this->GetDomainNumber());
145 m_FunctionB->SetParticleSystem(this->GetParticleSystem());
150 void SetAOff() { m_AOn =
false; }
151 void SetAOn(
bool s) { m_AOn = s; }
152 bool GetAOn()
const {
return m_AOn; }
153 void SetBOn() { m_BOn =
true; }
154 void SetBOff() { m_BOn =
false; }
155 void SetBOn(
bool s) { m_BOn = s; }
156 bool GetBOn()
const {
return m_BOn; }
162 m_RelativeEnergyScaling = r;
164 double GetRelativeEnergyScaling()
const 166 return m_RelativeEnergyScaling;
169 void SetRelativeGradientScaling(
double r)
171 m_RelativeGradientScaling = r;
173 double GetRelativeGradientScaling()
const 175 return m_RelativeGradientScaling;
178 double GetAverageGradMagA()
const 180 if (m_Counter != 0.0)
return m_AverageGradMagA / m_Counter;
183 double GetAverageGradMagB()
const 185 if (m_Counter != 0.0)
return m_AverageGradMagB / m_Counter;
189 double GetAverageEnergyA()
const 191 if (m_Counter != 0.0)
return m_AverageEnergyA / m_Counter;
194 double GetAverageEnergyB()
const 196 if (m_Counter != 0.0)
return m_AverageEnergyB / m_Counter;
202 m_RelativeGradientScaling(1.0), m_RelativeEnergyScaling(1.0) {}
210 double m_RelativeGradientScaling;
211 double m_RelativeEnergyScaling;
212 double m_AverageGradMagA;
213 double m_AverageGradMagB;
214 double m_AverageEnergyA;
215 double m_AverageEnergyB;
218 typename PSMCostFunction<VDimension>::Pointer m_FunctionA;
219 typename PSMCostFunction<VDimension>::Pointer m_FunctionB;
224 #ifndef ITK_MANUAL_INSTANTIATION 225 #include "itkPSMTwoCostFunction.hxx" virtual void BeforeEvaluate(unsigned int idx, unsigned int d, const ParticleSystemType *system)
virtual void BeforeIteration()
Superclass::ParticleSystemType ParticleSystemType
virtual VectorType Evaluate(unsigned int idx, unsigned int d, const ParticleSystemType *system, double &maxmove) const
itkStaticConstMacro(Dimension, unsigned int, VDimension)
virtual void SetParticleSystem(ParticleSystemType *p)
virtual void SetParticleSystem(ParticleSystemType *p)
vnl_vector_fixed< double, VDimension > VectorType
virtual void AfterIteration()
Superclass::VectorType VectorType
PSMParticleSystem< VDimension > ParticleSystemType
void SetRelativeEnergyScaling(double r)