00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "DirectObjFcn.hh"
00026
00027 static const char* myNameIs = "DirectObjFunction";
00028
00029 const char* DirectObjFcn::className() const {
00030 return (myNameIs);
00031 }
00032
00033 const char* DirectObjFcn::forwardName() const {
00034 return forOp->className();
00035 }
00036
00037 DirectObjFcn::DirectObjFcn (int n, SlaveForward* forwardOp)
00038 : ObjectiveFunction(n)
00039 {
00040 isUpdated = 0;
00041 forOp = forwardOp;
00042 given_g = 0;
00043 }
00044
00045 DirectObjFcn::DirectObjFcn (int n, SlaveForward* forwardOp, int ig)
00046 : ObjectiveFunction(n)
00047 {
00048 isUpdated = 0;
00049 forOp = forwardOp;
00050 given_g = ig;
00051 }
00052
00053 DirectObjFcn::~DirectObjFcn()
00054 {
00055 forOp = NULL;
00056 }
00057
00058 double DirectObjFcn::realPerformance(const Model<double>& p)
00059 {
00060 List<double> ldat = forOp->dataList(p);
00061 return ldat[0];
00062 }
00063
00064 double DirectObjFcn::realPerformance(const Model<long>& p)
00065 {
00066 List<double> ldat = forOp->dataList(p);
00067 return ldat[0];
00068 }
00069
00070 Vector<double>* DirectObjFcn::getGradient(const Model<double>& p)
00071 {
00072 Vector<double>* g;
00073 if (!given_g) return NULL;
00074 g = new Vector<double>(p.modSize());
00075 g = forOp->gradient(p);
00076 return g;
00077 }
00078
00079 Vector<double>* DirectObjFcn::getGradient(const Model<long>& p)
00080 {
00081 Vector<double>* g;
00082 if (!given_g) return NULL;
00083 g = new Vector<double>(p.modSize());
00084 g = forOp->gradient(p);
00085 return g;
00086 }