/*
 *  Open BEAGLE
 *  Copyright (C) 2001-2004 by Christian Gagne and Marc Parizeau
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Contact:
 *  Laboratoire de Vision et Systemes Numeriques
 *  Departement de genie electrique et de genie informatique
 *  Universite Laval, Quebec, Canada, G1V 4J7
 *  http://vision.gel.ulaval.ca
 *
 */

/*!
 *  \file   beagle/DecimateOp.hpp
 *  \brief  Definition of the class DecimateOp.
 *  \author Christian Gagne
 *  \author Marc Parizeau
 *  $Revision: 1.1 $
 *  $Date: 2004/03/31 19:09:39 $
 */

#ifndef Beagle_DecimateOp_hpp
#define Beagle_DecimateOp_hpp

#include <string>

#include "beagle/config.hpp"
#include "beagle/macros.hpp"
#include "beagle/Object.hpp"
#include "beagle/AbstractAllocT.hpp"
#include "beagle/PointerT.hpp"
#include "beagle/ContainerT.hpp"
#include "beagle/Operator.hpp"
#include "beagle/IntegerVector.hpp"
#include "beagle/String.hpp"
#include "beagle/Individual.hpp"
#include "beagle/Float.hpp"


namespace Beagle {

/*!
 *  \class DecimateOp beagle/DecimateOp.hpp "beagle/DecimateOp.hpp"
 *  \brief Population decimation operator class.
 *  \ingroup ECF
 *  \ingroup Op
 *
 *  The operator shrink the population size by the parametrized factor given as
 *  parameter. The decimation is done by keeping (ratio * population size) best individuals
 *  of the population, where ratio is the decimation ratio, which is less than 1.0.
 */
class DecimateOp : public Operator {

public:

  //! DecimateOp allocator type.
  typedef AllocatorT<DecimateOp,Operator::Alloc>
          Alloc;
  //! DecimateOp handle type.
  typedef PointerT<DecimateOp,Operator::Handle>
          Handle;
  //! DecimateOp bag type.
  typedef ContainerT<DecimateOp,Operator::Bag>
          Bag;

  explicit DecimateOp(std::string inDecimationRatioName="ec.decimation.ratio",
                      std::string inName="DecimateOp");
  virtual ~DecimateOp() { }

  virtual void initialize(System& ioSystem);
  virtual void operate(Deme& ioDeme, Context& ioContext);

protected:
  IntegerVector::Handle mPopSize;              //!< Population size for the evolution.
  Float::Handle         mDecimationRatio;      //!< Decimation ratio for the actual population.
  std::string           mDecimationRatioName;  //!< Decimation ratio parameter name.

};

}

#endif // Beagle_DecimateOp_hpp

