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
00026
00027
00028 #include "numeric/rosenbrock.hxx"
00029 #include "numeric/funcobj.hxx"
00030 #include "numeric/type.hxx"
00031 #include "numeric/nlpmodel.hxx"
00032 #include "numeric/exception.hxx"
00033 #include "numeric/testtool.hxx"
00034
00035 using namespace ::scsolver::numeric;
00036 using namespace ::std;
00037 using ::scsolver::numeric::nlp::Rosenbrock;
00038
00039 class TestFunc1 : public BaseFuncObj
00040 {
00041 public:
00042 TestFunc1() :
00043 BaseFuncObj(2)
00044 {
00045
00046 setVar(0, 0);
00047 setVar(1, 3);
00048 }
00049
00050 virtual ~TestFunc1()
00051 {
00052 }
00053
00054 virtual double eval() const
00055 {
00056 const vector<double>& vars = getVars();
00057 double term1 = vars[0] - 2;
00058 term1 *= term1*term1*term1;
00059
00060 double term2 = vars[0] - 2.0*vars[1];
00061 term2 *= term2;
00062
00063 return term1 + term2;
00064 }
00065
00069 virtual const string getFuncString() const
00070 {
00071 return string("(x1 - 2)^4 + (x1 - 2*x2)^2");
00072 }
00073 };
00074
00075 int main()
00076 {
00077 runNonLinearTest(new Rosenbrock, new TestFunc1);
00078 }