STK++ 0.9.13
STK_AdditiveBSplineRegressionPage.cpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23 */
24
25/*
26 * Project: stkpp::Regress
27 * created on: 27 sept. 2010
28 * Purpose: .
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 *
31 **/
32
37#include "../include/STK_AdditiveBSplineRegressionPage.h"
38
39namespace STK
40{
41
44static const String BSPLINEERRORCODES[] =
45{
46 _T("AdditiveBSplineRegressionPage::UNKNOWN_ERROR\n")
47 , _T("AdditiveBSplineRegressionPage::INVALID_OPTION\n")
48};
49
50/* constructor. */
52 : IPage(_T("AdditiveBSplineRegression"), level, true)
53 , nbControlPoints_(3)
54 , degree_(3)
55 , position_(Regress::periodicKnotsPositions_)
56
57
58{
59 // reserve for the 4 options
60 options_.reserve(3);
61 // first option : standardize or no the data set
62 options_.push_back(Option(_T("nbControlPoints"), Option::integer_, true));
63 options_.back().setValue(_T("7"));
64 // degree f the spline
65 options_.push_back(Option(_T("degree"), Option::integer_, true));
66 options_.back().setValue(_T("2"));
67 // first option : type of model
68 options_.push_back(Option(_T("knotsPositions"), Option::string_, true));
69 options_.back().setValue(_T("uniform"));
70}
71
72/* copy constructor */
74 : IPage(page)
75 , nbControlPoints_(page.nbControlPoints_)
76 , degree_(page.degree_)
77 , position_(page.position_)
78{}
79
80/* destructor. */
83
84
86{
87 // first option
88 nbControlPoints_ = options_[0].get(int());
89 if ( (nbControlPoints_ <= 0))
90 {
91 msg_error_ = BSPLINEERRORCODES[1];
92 msg_error_ += "nbControlPoints must be strictly positive\n";
93 return false;
94 }
95 // second option
96 degree_ = options_[1].get(int());
97 if ( (degree_ <= 0))
98 {
99 msg_error_ = BSPLINEERRORCODES[1];
100 msg_error_ += "degree must be strictly positive\n";
101 return false;
102 }
103 if ( (nbControlPoints_ <= degree_))
104 {
105 msg_error_ = BSPLINEERRORCODES[1];
106 msg_error_ += "nbControlPoints must be strictly greater than degree.\n";
107 return false;
108 }
109
110 // third option
113 {
114 msg_error_ = BSPLINEERRORCODES[1];
115 msg_error_ += "knots position is unknown.\n";
116 return false;
117 }
118 // validation done
119 return true;
120}
121
122} // namespace STK
#define _T(x)
Let x unmodified.
In this Page, we manage the options for the computation of the Additive BSpline regression.
Regress::KnotsPosition position_
positions of the knots.
AdditiveBSplineRegressionPage(int const &level)
constructor.
A IPage is an interface base class for reading and/or writing a page of option in a file.
Definition STK_IPage.h:94
String msg_error_
Contain the last error message.
Definition STK_IPage.h:204
ContOption options_
array of the options
Definition STK_IPage.h:201
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
the Option class allow to store the value of an option from a IPage.
Definition STK_Option.h:56
@ integer_
discrete number
Definition STK_Option.h:76
@ string_
characters
Definition STK_Option.h:74
@ unknown_Knots_Position_
unknown positions
std::basic_string< Char > String
STK fundamental type of a String.
KnotsPosition stringToKnotsPosition(String const &type)
convert a String to a KnotsPosition.
The namespace STK is the main domain space of the Statistical ToolKit project.