source/numeric/penalty.cxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  The Contents of this file are made available subject to
00004  *  the terms of GNU Lesser General Public License Version 2.1.
00005  *
00006  *
00007  *    GNU Lesser General Public License Version 2.1
00008  *    =============================================
00009  *    Copyright 2008 by Kohei Yoshida.
00010  *    1039 Kingsway Dr., Apex, NC 27502, USA
00011  *
00012  *    This library is free software; you can redistribute it and/or
00013  *    modify it under the terms of the GNU Lesser General Public
00014  *    License version 2.1, as published by the Free Software Foundation.
00015  *
00016  *    This library is distributed in the hope that it will be useful,
00017  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *    Lesser General Public License for more details.
00020  *
00021  *    You should have received a copy of the GNU Lesser General Public
00022  *    License along with this library; if not, write to the Free Software
00023  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024  *    MA  02111-1307  USA
00025  *
00026  ************************************************************************/
00027 
00028 #include "numeric/penalty.hxx"
00029 #include "numeric/nlpmodel.hxx"
00030 #include <string>
00031 #include <vector>
00032 
00033 using ::std::string;
00034 using ::std::vector;
00035 
00036 namespace scsolver { namespace numeric { namespace nlp {
00037 
00038 struct PenaltyImpl
00039 {
00040 
00041     const BaseFuncObj*  pObjectiveFunc;
00042     vector<Constraint>  Constraints;
00043     double              Factor;
00044 
00045     PenaltyImpl();
00046     PenaltyImpl(const PenaltyImpl& r);
00047 };
00048 
00049 PenaltyImpl::PenaltyImpl() :
00050     pObjectiveFunc(NULL), 
00051     Factor(1.0)
00052 {
00053 }
00054 
00055 PenaltyImpl::PenaltyImpl(const PenaltyImpl& r) :
00056     pObjectiveFunc(r.pObjectiveFunc), 
00057     Constraints(r.Constraints),
00058     Factor(r.Factor)
00059 {
00060 }
00061 
00062 // ----------------------------------------------------------------------------
00063 
00064 Penalty::Penalty() :
00065     BaseFuncObj(),
00066     mpImpl(new PenaltyImpl)
00067 {
00068 }
00069 
00070 Penalty::Penalty(const Penalty& r) :
00071     BaseFuncObj(*this),
00072     mpImpl(new PenaltyImpl(*r.mpImpl))
00073 {
00074 }
00075 
00076 Penalty::~Penalty()
00077 {
00078 }
00079 
00080 double Penalty::eval()
00081 {
00082     return 0.0;
00083 }
00084 
00085 const string Penalty::getFuncString() const
00086 {
00087     string str("");
00088     return str;
00089 }
00090 
00091 void Penalty::initFromModel(Model* pModel)
00092 {
00093     mpImpl->pObjectiveFunc = pModel->getFuncObject();
00094     const vector<Constraint>& cons = pModel->getAllConstraints();
00095     mpImpl->Constraints.assign(cons.begin(), cons.end());
00096 }
00097 
00098 void Penalty::setConstraintFactor(double factor)
00099 {
00100     mpImpl->Factor = factor;
00101 }
00102 
00103 
00104 }}}

Generated on Mon Jul 28 09:13:20 2008 for scsolver by  doxygen 1.5.3