Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99653066
micpprog.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 26, 00:13
Size
2 KB
Mime Type
text/x-c++
Expires
Tue, Jan 28, 00:13 (23 h, 1 m)
Engine
blob
Format
Raw Data
Handle
23827116
Attached To
rSPECMICP SpecMiCP / ReactMiCP
micpprog.hpp
View Options
/*-------------------------------------------------------
- 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
Log In to Comment