/*
 *  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, G1K 7P4
 *  http://vision.gel.ulaval.ca
 *
 */

/*!
 *  \file   beagle/GA/CrossoverBlendFltVecOp.hpp
 *  \brief  Definition of the class GA::CrossoverBlendFltVecOp.
 *  \author Christian Gagne
 *  \author Marc Parizeau
 *  $Revision: 1.5 $
 *  $Date: 2004/04/25 23:12:19 $
 */

#ifndef Beagle_GA_CrossoverBlendFltVecOp_hpp
#define Beagle_GA_CrossoverBlendFltVecOp_hpp

#include <string>

#include "beagle/config.hpp"
#include "beagle/macros.hpp"
#include "beagle/Object.hpp"
#include "beagle/CrossoverOp.hpp"

namespace Beagle {
namespace GA {

/*!
 *  \class CrossoverBlendFltVecOp beagle/GA/CrossoverBlendFltVecOp.hpp
 *    "beagle/GA/CrossoverBlendFltVecOp.hpp"
 *  \brief Real-valued GA blend crossover operator class.
 *  \ingroup GAF
 *
 *  Real-valued GA blend crossover proceed by blending two float vectors, \f$(p_1,p_2)\f$,
 *  using a randomly choosen factor \f$\alpha\in[0,1]\f$. The resulting children are equal
 *  to \f$c_1=p_1+(\alpha(p_2-p_1))\f$ and \f$c_2=p_2-(\alpha(p_2-p_1))\f$. So it consists
 *  to generate two children that have values that are on the line connecting the two
 *  parents, with an factor determining how near (or far) the children will be from the parents.
 *  \f$\alpha\f$ factor near 0.0 and 1.0 produces children very similar to the parents,
 *  while \f$\alpha\f$ factor near 0.5 produces children different the parents (children with
 *  parameter values on a point in the parameter space located half-way the two parents location).
 *
 */
class CrossoverBlendFltVecOp : public CrossoverOp {

public:

  //! GA::CrossoverBlendFltVecOp allocator type.
  typedef AllocatorT<CrossoverBlendFltVecOp,CrossoverOp::Alloc>
          Alloc;
  //! GA::CrossoverBlendFltVecOp handle type.
  typedef PointerT<CrossoverBlendFltVecOp,CrossoverOp::Handle>
          Handle;
  //! GA::CrossoverBlendFltVecOp bag type.
  typedef ContainerT<CrossoverBlendFltVecOp,CrossoverOp::Bag>
          Bag;

  explicit CrossoverBlendFltVecOp(std::string inMatingPbName="ga.cxblend.prob",
                                  std::string inName="GA-CrossoverBlendFltVecOp");
  virtual ~CrossoverBlendFltVecOp() { }

  virtual void initialize(System& ioSystem);
  virtual bool mate(Individual& ioIndiv1, Context& ioContext1,
                    Individual& ioIndiv2, Context& ioContext2);
                                 
};

}
}


#endif // Beagle_GA_CrossoverBlendFltVecOp_hpp
