Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F83670249
micpsolver_structs.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
Wed, Sep 18, 10:08
Size
7 KB
Mime Type
text/x-c
Expires
Fri, Sep 20, 10:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20876121
Attached To
rSPECMICP SpecMiCP / ReactMiCP
micpsolver_structs.hpp
View Options
/*-------------------------------------------------------
- Module : micpsolver
- File : micpsolver_structs.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget <fabieng@princeton.edu>, Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Princeton University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------*/
#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, -1 to disable it
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
;
//!< factor in front of the descent condition > 0
double
power_descent_condition
;
//!< power used in the traditional format of the 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
double
threshold_cycling_linesearch
;
//! factor to detect cycling in linesearch
int
max_factorization_step
;
//! Max number of factorization in an iteration
bool
non_monotone_linesearch
;
//! Use non monotone linesearch
//! \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
),
threshold_cycling_linesearch
(
1e-5
),
max_factorization_step
(
4
),
non_monotone_linesearch
(
true
)
{}
};
//! \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...
LinesearchFailure
=
-
5
,
//!< Failure in linesearch
MaxStepTakenTooManyTimes
=
-
4
,
//!< Probably 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
;
//! Number of consecutive step at max length
double
current_residual
;
//! Current residual
double
current_update
;
//! Current update
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
),
current_residual
(
INFINITY
),
current_update
(
INFINITY
),
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
;
}
};
//! The NCP function that are implemented
enum
class
NCPfunction
{
penalizedFB
,
// Penalized Fischer-Burmeister function
min
// The minimum function
};
}
// end namespace micpsolver
}
// end namespace specmicp
#endif
//SPECMICP_MICPSOLVER_MICPSOLVERSTRUCTS_HPP
Event Timeline
Log In to Comment