Permalink
Browse files

Working on 0.6 in trunk. Fixing constness of moves and solutions star…

…ting from the move_manager iterator and going across the aspiration criteria, moves, and so on.
  • Loading branch information...
baol committed Mar 14, 2013
1 parent 411ef02 commit 66ba2f1336bbd03208cb9b8d74d0e0d59b4417bc
View
@@ -24,21 +24,14 @@ m4/ax_prefix_config_h.m4 -text
m4/shave.m4 -text
/metslib.pc.in -text
metslib/Makefile.am -text
metslib/abstract-search.cc -text
metslib/abstract-search.hh -text
metslib/local-search.cc -text
metslib/local-search.hh -text
metslib/mets.cc -text
metslib/mets.hh -text
metslib/metslib_config.hh -text
metslib/model.cc -text
metslib/model.hh -text
metslib/observer.hh -text
metslib/simulated-annealing.cc -text
metslib/simulated-annealing.hh -text
metslib/tabu-search.cc -text
metslib/tabu-search.hh -text
metslib/termination-criteria.cc -text
metslib/termination-criteria.hh -text
/shave-libtool.in -text
/shave.in -text
View
@@ -1,3 +1,11 @@
2013-03-14 Mirko Maischberger <mirko.maischberger@gmail.com>
* *: changed constness of the moves and the solutions
passed around. The mets::move_manager now iterates over
const mets::move*
2011-05-05 Mirko Maischberger <mirko.maischberger@gmail.com>
* *: header only library (with fixed bugs)
2009-10-20 Mirko Maischberger <mirko.maischberger@gmail.com>
* debian/*: added packaging file for Debian. You can create deb
package for your GNU/Debian or derived distro using
View
333 INSTALL

Large diffs are not rendered by default.

Oops, something went wrong.
View
24 README
@@ -55,11 +55,11 @@ Complete API Documentation
- http://www.coin-or.org/metslib/docs/
Sample programs
---------------
Tutorial
--------
There is a quick Tabu Search tutorial here
- https://projects.coin-or.org/metslib/wiki/TabuSearchTutorial
A METSlib Tutorial is available here:
- http://www.coin-or.org/metslib/docs/releases/0.5.2/metslib-tr.pdf
You can also look in the distributed examples (in the Examples
subproject in svn).
@@ -101,18 +101,18 @@ Cumming <murrayc@usa.net> and Cedric Gustin <gustin@pcpm.ucl.ac.be>
If you use the library you should cite it in your work:
=======================================================
- Mirko Maischberger, "METSlib metaheuristic framework version
0.4.3". [online] Available http://projects.coin-or.org/metslib,
(the date you visited the site)
- Mirko Maischberger, "COIN-OR METSlib, a Metaheuristics Framework
in Modern C++" April 2011
BibTex Entry:
@misc{metslib2008,
@misc{metslib2011,
author={Mirko Maischberger},
title={{METSlib} metaheuristic framework version 0.4.3},
month={October},
year={2009},
howpublished = {http://projects.coin-or.org/metslib},
title={{COIN-OR} {METSlib}, a Metaheuristics Framework
in Modern C++},
month={April},
year={2011},
howpublished = {http://www.coin-or.org/metslib/docs/releases/0.5.2/metslib-tr.pdf},
}
- Mirko Maischberger
View
@@ -2,7 +2,7 @@ dnl --------------------------------
dnl Initialization macros.
dnl --------------------------------
AC_INIT([metslib], [0.5.0], [mirko.maischberger@gmail.com])
AC_INIT([metslib], [0.6.0], [mirko.maischberger@gmail.com])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])
@@ -14,44 +14,13 @@ GENERIC_LIBRARY_NAME=metslib
#release versioning
GENERIC_MAJOR_VERSION=0
GENERIC_MINOR_VERSION=5
GENERIC_MINOR_VERSION=6
GENERIC_MICRO_VERSION=0
#API version (often = GENERIC_MAJOR_VERSION.GENERIC_MINOR_VERSION)
GENERIC_API_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
AC_SUBST(GENERIC_API_VERSION)
# shared library versioning
# =========================
#
# libtool library versions are described by three integers:
# current
# The most recent interface number that this library implements.
# revision
# The implementation number of the current interface.
# age
# The difference between the newest and oldest interfaces that this
# library implements. In other words, the library implements all
# the interface numbers in the range from number current - age to
# current.
#
# If two libraries have identical current and age numbers, then the
# dynamic linker chooses the library with the greater revision number.
#
GENERIC_LIBRARY_VERSION=5:0:0
# | | |
# +------+ | +---+
# | | |
# current:revision:age
# | | |
# | | +- increment if interfaces have been added
# | | set to zero if interfaces have been removed
# or changed
# | +- increment if source code has changed
# | set to zero if current is incremented
# +- increment if interfaces have been added, removed or changed
dnl --------------------------------
dnl Package name and version number
dnl --------------------------------
@@ -79,9 +48,7 @@ dnl -----------------------------------------------
PKG_PROG_PKG_CONFIG([0.9])
AC_PROG_CXX
AM_PROG_LIBTOOL
AM_SANITY_CHECK
AC_LANG_CPLUSPLUS
@@ -136,7 +103,7 @@ dnl Generates Makefile's, configuration files and scripts
dnl -----------------------------------------------
SHAVE_INIT
AC_CONFIG_FILES([shave shave-libtool])
AC_CONFIG_FILES([shave])
AC_OUTPUT(Makefile \
metslib.pc \
metslib/Makefile \
View
@@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = METSlib
PROJECT_NUMBER = 0.4.4
PROJECT_NUMBER = 0.6
OUTPUT_DIRECTORY = doxydoc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
View
@@ -6,5 +6,4 @@ includedir=@includedir@
Name: METS tabu search generic library.
Description: METS Tabu Search Metaheuristic C++ generic library.
Version: @VERSION@
Libs: -L${libdir} -l@GENERIC_LIBRARY_NAME@
Cflags: -I${includedir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@ -I${libdir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@/include
View
@@ -3,15 +3,8 @@
h_sources = mets.hh model.hh abstract-search.hh local-search.hh \
simulated-annealing.hh tabu-search.hh termination-criteria.hh \
observer.hh metslib_config.hh metslib_ah.hh
cc_sources = mets.cc model.cc abstract-search.cc local-search.cc \
tabu-search.cc simulated-annealing.cc termination-criteria.cc
library_includedir= $(includedir)/$(GENERIC_LIBRARY_NAME)-$(GENERIC_API_VERSION)/$(GENERIC_LIBRARY_NAME)
library_include_HEADERS = $(h_sources)
INCLUDES = -I$(top_srcdir)
lib_LTLIBRARIES= libmetslib.la
libmetslib_la_SOURCES= $(h_sources) $(cc_sources)
libmetslib_la_LDFLAGS= -version-info $(GENERIC_LIBRARY_VERSION) -release $(GENERIC_RELEASE)
View

This file was deleted.

Oops, something went wrong.
View
@@ -3,12 +3,14 @@
// the CPL 1.0 as published by the Open Source Initiative
// http://www.opensource.org/licenses/cpl1.0.php
#include <iostream>
#ifndef METS_ABSTRACT_SEARCH_HH_
#define METS_ABSTRACT_SEARCH_HH_
namespace mets {
/// @defgroup common Common pieces
/// @defgroup common Common components
/// @{
/// @brief The solution recorder is used by search algorithm, at the
@@ -54,8 +56,8 @@ namespace mets {
/// @brief Set some common values needed for neighborhood based
/// metaheuristics.
///
/// @param working The working solution (this will be modified
/// during search)
/// @param working The starting point solution (this will be modified
/// during search as the working solution)
///
/// @param recorder A solution recorder instance used to record
/// the best solution found
@@ -161,7 +163,7 @@ namespace mets {
/// @}
/// @defgroup common Common pieces
/// @defgroup common Common components
/// @{
/// @brief The best ever solution recorder can be used as a simple
@@ -171,6 +173,12 @@ namespace mets {
class best_ever_solution : public solution_recorder
{
public:
/// @brief The mets::evaluable_solution will be stored as a
/// reference: please provide an instance that is not
/// modified/needed elsewhere.
///
/// @param best The instance used to store the best solution found
/// (will be modified).
best_ever_solution(evaluable_solution& best) :
solution_recorder(),
best_ever_m(best)
@@ -184,13 +192,15 @@ namespace mets {
best_ever_solution& operator=(const best_ever_solution&);
/// @brief Accept is called at the end of each iteration for an
/// opportunity to record the best move ever.
/// opportunity to record the best solution found during the
/// search.
bool accept(const feasible_solution& sol);
/// @brief Returns the best solution found since the beginning.
const evaluable_solution& best_seen() const
{ return best_ever_m; }
/// @brief Best cost seen.
gol_type best_cost() const
{ return best_ever_m.cost_function(); }
protected:
@@ -227,8 +237,91 @@ namespace mets {
update(search_type* algorithm) = 0;
};
template<typename neighborhood_t>
struct iteration_logger : public mets::search_listener<neighborhood_t>
{
explicit
iteration_logger(std::ostream& o)
: mets::search_listener<neighborhood_t>(),
iteration(0),
os(o)
{ }
void
update(mets::abstract_search<neighborhood_t>* as)
{
const mets::feasible_solution& p = as->working();
if(as->step() == mets::abstract_search<neighborhood_t>::MOVE_MADE)
{
os << iteration++ << "\t"
<< dynamic_cast<const mets::evaluable_solution&>(p).cost_function()
<< "\n";
}
}
protected:
int iteration;
std::ostream& os;
};
template<typename neighborhood_t>
struct improvement_logger : public mets::search_listener<neighborhood_t>
{
explicit
improvement_logger(std::ostream& o, gol_type epsilon = 1e-7)
: mets::search_listener<neighborhood_t>(),
iteration_m(0),
best_m(std::numeric_limits<double>::max()),
os_m(o),
epsilon_m(epsilon)
{ }
void
update(mets::abstract_search<neighborhood_t>* as)
{
const mets::feasible_solution& p = as->working();
if(as->step() == mets::abstract_search<neighborhood_t>::MOVE_MADE)
{
iteration_m++;
double val = dynamic_cast<const mets::evaluable_solution&>(p)
.cost_function();
if(val < best_m - epsilon_m)
{
best_m = val;
os_m << iteration_m << "\t"
<< best_m
<< " (*)\n";
}
}
}
protected:
int iteration_m;
double best_m;
std::ostream& os_m;
gol_type epsilon_m;
};
/// @}
}
inline mets::solution_recorder::~solution_recorder()
{ }
inline bool
mets::best_ever_solution::accept(const mets::feasible_solution& sol)
{
const evaluable_solution& s = dynamic_cast<const mets::evaluable_solution&>(sol);
if(s.cost_function() < best_ever_m.cost_function())
{
best_ever_m.copy_from(s);
return true;
}
return false;
}
#endif
Oops, something went wrong.

0 comments on commit 66ba2f1

Please sign in to comment.