Page MenuHomec4science

micpsolver_structs.hpp
No OneTemporary

File Metadata

Created
Thu, May 23, 10:12

micpsolver_structs.hpp

/*-------------------------------------------------------
- Module : micpsolver
- File : micpsolver_structs.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#ifndef SPECMICP_MICPSOLVER_MICPSOLVERSTRUCTS_HPP
#define SPECMICP_MICPSOLVER_MICPSOLVERSTRUCTS_HPP
//! \file micpsolver_structs.hpp structures and enum used by the micpsolver
// this file exists to reduce the header dependancy
#include <float.h>
namespace specmicp {
namespace micpsolver {
//! \brief Options for the MiCPSolver
struct MiCPSolverOptions
{
int max_iter; //!< Maximum number of iterations allowed
// tolerances
double fvectol; //!< Tolerance for minimization of residuals
double steptol; //!< Tolerance for minimization of error
// misc ...
double condition_limit; //!< Condition number limit
double penalization_factor; //!< Penalization factor for the penalized Fisher-Burmeister function
double maxstep; //!< the maximum step allowed
int maxiter_maxstep; //!< the maximum number of step of length maxstep allowed
double factor_descent_condition; //!< > 0
double power_descent_condition; //!< > 2
bool use_crashing; //! Use a crashing step to improve the starting guess
double coeff_accept_newton_step; //! Accept the newton step without line search if merit(x+d)<coeff*merit(x^k)
bool use_scaling; //! Use scaling to improve convergence
double factor_gradient_search_direction; //! factor which multiply the gradient in the search direction system
double projection_min_variable; //! threshold under which a mineral is considered to be 0
double threshold_stationary_point; //! If norm(residual)>threshold_stationary_point and ErrorMinimized -> stationary point
int max_factorization_step; //! Max number of factorization in an iteration
//! \brief Constructor - also defines the default value used by the algorithm
MiCPSolverOptions():
max_iter(100),
fvectol(1e-8),
steptol(1e-10),
condition_limit(1e6),
penalization_factor(0.8),
maxstep(100), // this is quite restrictif
maxiter_maxstep(20),
factor_descent_condition(1e-4),
power_descent_condition(2),
use_crashing(false),
coeff_accept_newton_step(0.95),
use_scaling(true),
factor_gradient_search_direction(5.0),
projection_min_variable(DBL_EPSILON),
threshold_stationary_point(1e-6),
max_factorization_step(4)
{}
};
//! \brief Return code of the MiCP solver
//!
//! A positive return code means that the algorithm converged (but maybe to a stationnary points)
//! A negative return code means that something wrong happened and was detected
enum class MiCPSolverReturnCode
{
LolItsNotSupposedToHappen = -10, //!< bummer..
MaxStepTakenTooManyTimes = -4, //!< Propably detect a divergence
FailedToSolveLinearSystem = -3, //!< Problem in the decomposition... shouldn't be raised, use of the gradient step
MaxIterations = -2, //!< Algorithm has reached the maximum number of iterations
StationaryPoint = -1, //!< Algorithm is stuck in a stationnary point of the merit function
NotConvergedYet = 0, //!< Keep going...
Success = 1, //!< Test success (well be careful of stationnary points)
ResidualMinimized = 2, //!< The residual is minimized (i.e. close to zero)
ErrorMinimized = 3 //!< The error is minimized, may indicate a stationary point
};
//! \brief This structure contains counter to check/query the performance of the algorithm
//!
//! It should be updated after each operations, not at the end
struct MiCPPerformance
{
int nb_call_residuals; //! Number of calls of the residual
int nb_call_jacobian; //! Number of calls of the jacobian
int nb_factorization; //! Number of factorization performed (may be > number of iterations)
int nb_gradient_step; //! Number of gradient steps (too many gradient steps indicate a bad starting guess)
int nb_crashing_iterations; //! Number of crashing iterations
int nb_iterations; //! Number of iterations
bool max_taken; //! Maximum step has been taken
int nb_max_taken; //! Number of time the maximum has been taken
int nb_consecutive_max_taken;
MiCPSolverReturnCode return_code; //! Return code
MiCPPerformance():
nb_call_residuals(0),
nb_call_jacobian(0),
nb_factorization(0),
nb_gradient_step(0),
nb_crashing_iterations(0),
nb_iterations(0),
max_taken(false),
nb_max_taken(0),
nb_consecutive_max_taken(0),
return_code(MiCPSolverReturnCode::NotConvergedYet)
{}
//! \brief add two performance instances - useful when restarting a computation in case of failure
MiCPPerformance& operator+=(const MiCPPerformance& other)
{
nb_call_residuals += other.nb_call_residuals;
nb_call_jacobian += other.nb_call_jacobian;
nb_factorization += other.nb_factorization;
nb_gradient_step += other.nb_gradient_step;
nb_crashing_iterations += other.nb_crashing_iterations;
nb_iterations += other.nb_iterations;
return_code = other.return_code; // we take the last one
return *this;
}
};
enum class NCPfunction
{
penalizedFB,
min
};
} // end namespace micpsolver
} // end namespace specmicp
#endif //SPECMICP_MICPSOLVER_MICPSOLVERSTRUCTS_HPP

Event Timeline