STK++ 0.9.13
STK_LocalVariancePage.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::Reduct
27 * created on: 27 sept. 2010
28 * Purpose: implement the LocalVariancePage class.
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 *
31 **/
32
37#include "../include/STK_LocalVariancePage.h"
38
39namespace STK
40{
41
43static const String LOCALVARIANCEERRORCODES[] =
44{
45 _T("Error in LocalVariancePage: UNKNOWN ERROR\n")
46 , _T("Error in LocalVariancePage: INVALID OPTION\n")
47};
48
49/* constructor. */
51 : IPage(_T("LocalVariance"), 1, true)
52 , type_(Reduct::distance_)
53 , nbNeighbor_(3)
54{
55 // reserve for the 2 options
56 options_.reserve(2);
57 // first option : type of graph
58 options_.push_back(Option(_T("type graph"), Option::string_, true));
59 options_.back().setValue(_T("minimalDistance"));
60 // number of neighbor
61 options_.push_back(Option(_T("neighborhood"), Option::integer_, true));
62 options_.back().setValue(_T("3"));
63}
64
65/* constructor. */
67 : IPage(_T("LocalVariance"), level, true)
68 , type_(Reduct::distance_)
69 , nbNeighbor_(2)
70{
71 // reserve for the 2 options
72 options_.reserve(2);
73 // first option : type of graph
74 options_.push_back(Option(_T("type graph"), Option::string_, true));
75 options_.back().setValue(_T("minimalDistance"));
76 // number of neighbor
77 options_.push_back(Option(_T("neighborhood"), Option::integer_, true));
78 options_.back().setValue(_T("2"));
79}
80
81/* copy constructor */
83 : IPage(page)
84 , type_(page.type_)
85 , nbNeighbor_(page.nbNeighbor_)
86{}
87
88/* destructor. */
91
93{
94 // validate first option
97 {
98 msg_error_ = LOCALVARIANCEERRORCODES[1];
99 msg_error_ += "graph type unknown.\n";
100 return false;
101 }
102 // validate second option
103 nbNeighbor_ = options_[1].get(int());
104 if (nbNeighbor_ <= 0)
105 {
106 msg_error_ = LOCALVARIANCEERRORCODES[1];
107 msg_error_ += "neighborhood must be a strictly positive value.\n";
108 return false;
109 }
110 return true;
111}
112
113} // namespace STK
#define _T(x)
Let x unmodified.
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
In this Page, we manage the options for the computation of the LocalVariance.
int nbNeighbor_
number of neighbors of each individual in the graph.
virtual ~LocalVariancePage()
destructor.
LocalVariancePage()
default constructor
Reduct::TypeGraph type_
type of the graph to compute
virtual bool validate()
validate the options.
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
std::basic_string< Char > String
STK fundamental type of a String.
TypeGraph stringToTypeGraph(String const &type)
convert a String to a TypeGraph.
The namespace STK is the main domain space of the Statistical ToolKit project.