[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah/problem itsProblem.hpp itsProblem.cpp
From: |
Johann |
Subject: |
[oMetah-devel] ometah/problem itsProblem.hpp itsProblem.cpp |
Date: |
Sat, 05 Mar 2005 17:43:34 -0500 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: Johann <address@hidden> 05/03/05 22:43:34
Modified files:
problem : itsProblem.hpp itsProblem.cpp
Log message:
* stuff on search space range
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsProblem.hpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsProblem.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: ometah/problem/itsProblem.cpp
diff -u ometah/problem/itsProblem.cpp:1.2 ometah/problem/itsProblem.cpp:1.3
--- ometah/problem/itsProblem.cpp:1.2 Mon Feb 7 13:07:43 2005
+++ ometah/problem/itsProblem.cpp Sat Mar 5 22:43:34 2005
@@ -1,9 +1,8 @@
-/*
-Open Metaheuristic is a library aimed at the conception of
-metaheuristics for difficult optimization.
-
-Copyrights 2005 Johann Dréo
-*/
+/***************************************************************************
+ * $Id: itsProblem.cpp,v 1.3 2005/03/05 22:43:34 nojhan Exp $
+ * Copyright 2005 Université Paris 12 Val-de-Marne
+ * Author : Johann Dréo <address@hidden>
+ ****************************************************************************/
/*
This program is free software; you can redistribute it and/or
@@ -28,11 +27,20 @@
//! the default constructor
itsProblem::itsProblem()
{
- this->name = "";
- this->description = "";
- this->citation = "";
+ setName("");
+ setDescription("");
+ setCitation("");
+ setFormula("f(x)");
- this->dimension = 0;
+ setDimension(1);
+
+ setRangeMaximaAll(0);
+ setRangeMinimaAll(0);
+
+ itsPoint optim();
+ optim.setSolution(vector<double> sol);
+ optim.setValues(vector<double> val);
+ setOptima(optim);
}
string itsProblem::getName()
@@ -76,10 +84,13 @@
void itsProblem::setDimension(int dimension)
{
this->dimension = dimension;
+
+ // reinitialization of range
+ setRangeMinima(-1);
}
-string getInformations()
+string itsProblem::getInformations()
{
// separator used to format output
string separator = " ; ";
@@ -91,3 +102,100 @@
// return only the string
return msg.str();
}
+
+vector<itsPoint> itsProblem::getOptima()
+{
+ return this->optima;
+}
+
+void itsProblem::setOptima(vector<itsPoint> optima)
+{
+ this->optima = optima;
+}
+
+vector<vector<double> > itsProblem::getRange()
+{
+ vector<vector<double> > range;
+ range.reserve(getDimension());
+
+ for(unsigned int i=0, i < getDimension(); i++) {
+ double mini = getRangeMinima()[i];
+ double maxi = getRangeMaxima()[i];
+ vector<double> v;
+ v.reserve(2);
+ v.push_back(mini);
+ v.push_back(maxi);
+ range.push_back(v);
+ }
+
+ return range;
+}
+
+void itsProblem::setRange(vector<vector<double> > range)
+{
+ vector<double> mins, maxs;
+ mins.reserve(getDimension());
+ maxs.reserve(getDimension());
+
+ for(unsigned int i=0, i < getDimension(); i++) {
+ mins.push_back(range[i][0]);
+ maxs.push_back(range[i][1]);
+ }
+
+ setRangeMinima(mins);
+ setRangeMaxima(maxs);
+}
+
+vector<double> itsProblem::getRangeMinima()
+{
+ return this->rangeMinima;
+}
+
+void itsProblem::setRangeMinima(vector<double> minima)
+{
+ if(minima.size() != getDimension() ) {
+ throw "ErrorSize";
+ } else {
+ this->rangeMinima = minima;
+ }
+}
+
+vector<double> itsProblem::getRangeMaxima()
+{
+ return this->rangeMaxima;
+}
+
+void itsProblem::setRangeMaxima(vector<double> maxima)
+{
+ if(maxima.size() != getDimension() ) {
+ throw "ErrorSize";
+ } else {
+ this->rangeMaxima = maxima;
+ }
+}
+
+void itsProblem::setRangeMinimaAll(double min)
+{
+ // empty vector
+ vector<double> v;
+ v.reserve(getDimension());
+
+ // fill with min
+ for(unsigned int i=0; i < getDimension(); i++ ) {
+ v.push_back(min);
+ }
+
+ // update
+ setRangeMinima(v);
+}
+
+void itsProblem::setRangeMaximaAll(double max)
+{
+ vector<double> v;
+ v.reserve(getDimension());
+
+ for(unsigned int i=0; i < getDimension(); i++ ) {
+ v.push_back(max);
+ }
+ setRangeMaxima(v);
+}
Index: ometah/problem/itsProblem.hpp
diff -u ometah/problem/itsProblem.hpp:1.4 ometah/problem/itsProblem.hpp:1.5
--- ometah/problem/itsProblem.hpp:1.4 Mon Feb 21 09:42:58 2005
+++ ometah/problem/itsProblem.hpp Sat Mar 5 22:43:34 2005
@@ -1,9 +1,8 @@
-/*
-Open Metaheuristic is a library aimed at the conception of
-metaheuristics for difficult optimization.
-
-Copyrights 2005 Johann Dréo
-*/
+/***************************************************************************
+ * $Id: itsProblem.hpp,v 1.5 2005/03/05 22:43:34 nojhan Exp $
+ * Copyright 2005 Université Paris 12 Val-de-Marne
+ * Author : Johann Dréo <address@hidden>
+ ****************************************************************************/
/*
This program is free software; you can redistribute it and/or
@@ -62,6 +61,25 @@
//! Number of variables
int dimension;
+ //! The global optima
+ /*!
+ This vector store all the known global optima
+ */
+ vector<itsPoint> optima;
+
+ //! Search space range minima
+ /*!
+ This vector is of the form :
+ [ min_1, min_2, ... , min_n ]
+ */
+ vector<double> rangeMinima;
+
+ //! Search space range maxima
+ /*!
+ This vector is of the form :
+ [ max_1, max_2, ... , max_n ]
+ */
+ vector<double> rangeMaxima;
public:
@@ -92,8 +110,43 @@
//! Return the formula
int getFormula();
//! Change the formula
- void setFormula(int dimension);
+ void setFormula(int formula);
+ //! Return the informations about the global optima
+ vector<itsPoint> getOptima();
+ //! Change the informations about the global optima
+ void setOptima(vector<itsPoint> optima);
+
+ //! Return the search space range
+ /*!
+ Return a matrix of the form :
+ [
+ [ min_1, max_1 ],
+ [ min_2, max_2 ],
+ [ ... ]
+ [ min_n, max_n ],
+ ]
+ */
+ vector<vector<double> > getRange();
+ //! Change the whole search space range
+ void setRange(vector<vector<double> > range);
+
+ //! Return the search space range minima
+ vector<double> getRangeMinima();
+ //! Change the search space range minima
+ void setRangeMinima(vector<double> minima);
+
+ //! Search space range maxima
+ vector<double> getRangeMaxima();
+ //! Search space range maxima
+ void setRangeMaxima(vector<double> maxima);
+
+ //! Change all the range minima to the same value
+ void setRangeMinimaAll(double min);
+
+ //! Change all the range maxima to the same value
+ void setRangeMaximaAll(double max);
+
//@}
@@ -109,7 +162,7 @@
This is the main part of the problem. This function computes the
value of the point and return it.
*/
- virtual vector<double> objectiveFunction(itsPoint);
+ virtual itsPoint objectiveFunction(itsPoint);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [oMetah-devel] ometah/problem itsProblem.hpp itsProblem.cpp,
Johann <=