Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DirectObjFcn.cpp

Go to the documentation of this file.
00001 //============================================================
00002 // COOOL           version 1.1           ---     Nov,  1995
00003 //   Center for Wave Phenomena, Colorado School of Mines
00004 //============================================================
00005 //
00006 //   This code is part of a preliminary release of COOOL (CWP
00007 // Object-Oriented Optimization Library) and associated class 
00008 // libraries. 
00009 //
00010 // The COOOL library is a free software. You can do anything you want
00011 // with it including make a fortune.  However, neither the authors,
00012 // the Center for Wave Phenomena, nor anyone else you can think of
00013 // makes any guarantees about anything in this package or any aspect
00014 // of its functionality.
00015 //
00016 // Since you've got the source code you can also modify the
00017 // library to suit your own purposes. We would appreciate it 
00018 // if the headers that identify the authors are kept in the 
00019 // source code.
00020 //
00021 //=============================================================
00022 // Author: H. Lydia Deng
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 }

Generated on Wed Dec 15 21:20:28 2004 for vuVolume by  doxygen 1.3.9.1