//$Header: /home/ben/Mapper/include/RCS/total_energy_function.h,v 6.4 2002/06/25 16:13:54 ben Exp $
#ifndef TOTAL_ENERGY_FUNCTION_H
#define TOTAL_ENERGY_FUNCTION_H
// Copyright Benedict Adamson 2002.
// This file is part of Mapper.
// Mapper is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// Mapper 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Mapper; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <map>
#include <set>
#include <vector>
#include "constraint.h"
#include "func.h"
#include "vector2.h"
class total_energy_function
:
public func::multi_dimensional_with_derivatives
{
public: //Constructors and destructors
total_energy_function(
const double t
);
virtual ~total_energy_function(void);
public: //Attributes
virtual double operator() (
const vector<double> &x
) const;
virtual void evaluate(
const vector<double> &x,
double &f, //output
vector<double> &gradient //output
) const;
inline double tol(void) const;
inline unsigned n_vars(void) const;
vector<double> current_var(void) const;
public: //Relationships
inline const vector< vector2 * > *points(void) const;
inline const set< vector2 * > *fixed_points(void) const;
inline const vector< constraint * > *constraints(void) const;
public: //Messages
void set_tol(
const double t
);
void move_points(
const vector<double> & x
) const;
private: //State
static const unsigned fixed_point;
double tol_;
const vector< vector2 * > *points_;
const set< vector2 * > *fixed_points_;
const vector< constraint * > *constraints_;
vector< vector< unsigned > > constraint_to_var;
map< vector2 *, unsigned > point_to_var;
friend void assoc(
total_energy_function &f,
const vector< vector2 *> &po,
const set< vector2 *> &fp,
const vector< constraint *> &co
);
};
inline double total_energy_function::tol(void) const
{
return this->tol_;
}
inline unsigned total_energy_function::n_vars(void) const
{
//preconditions:
//assert( this->points() );
//assert( this->fixed_points() );
return (this->points()->size() - this->fixed_points()->size()) * 2;
}
inline const vector< vector2 * > *total_energy_function::points(void) const
{
return this->points_;
}
inline const set< vector2 * > *total_energy_function::fixed_points(void) const
{
return this->fixed_points_;
}
inline const vector< constraint * > *total_energy_function::constraints(void) const
{
return this->constraints_;
}
void assoc(
total_energy_function &f,
const vector< vector2 *> &p,
const set< vector2 *> &fp,
const vector< constraint *> &c
);
#endif