Page MenuHomec4science

micpprog.hpp
No OneTemporary

File Metadata

Created
Tue, May 14, 18:24

micpprog.hpp

/*-------------------------------------------------------
- Module : micpsolver
- File : micpprog.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#ifndef SPECMICP_MICPSOLVER_MICPPROG_HPP
#define SPECMICP_MICPSOLVER_MICPPROG_HPP
//! \file micpprog.hpp The static interface of a MiCP solver
namespace specmicp {
namespace micpsolver {
//! \brief Traits used by the MiCPProg class
struct traits_MiCPProg
{
//! A scalar
using scalar_t = double;
//! A vector
using vector_t = Eigen::Matrix<double, Eigen::Dynamic, 1>;
//! A matrix
using matrix_t = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>;
};
//! \brief A MiCP program
//!
//! This class described a static interface.
//! Any MiCP program should derived from this class
template <class Derived>
class MiCPProg
{
public:
//! \brief common types used by a program
using types = traits_MiCPProg;
//! \brief Return the value used for infinity
static double infinity() {return HUGE_VAL;}
//! Return the derived class
Derived& derived() {return static_cast<Derived*>(*this);}
//! Return the number of variables
int total_variables();
//! Return the number of free variables
int nb_free_variables();
//! Return the number of constrained variables
int nb_complementarity_variables() {return total_variables() - nb_free_variables();}
//! Return the residual (R(X))
void get_residuals(const types::vector_t& x,
types::vector_t& residual);
//! Return the jacobian (J(x))
void get_jacobian(types::vector_t& x,
types::matrix_t& jacobian);
//! \brief Called at the beginning of an iteration
//!
//! Do nothing by default
void hook_start_iteration(const types::vector_t& x, double norm_residual) {}
//! \brief Return the maximum update length that the algorithm can take
//!
//! This is usually used to impose nonnegativity conditions
double max_lambda(const types::vector_t& x, const types::vector_t& update) {return 1.0;}
};
} // end namespace micpsolver
} // end namespace specmicp
#endif // SPECMICP_MICPSOLVER_MICPPROG_HPP

Event Timeline