diff options
author | Harpreet | 2015-09-23 18:22:28 +0530 |
---|---|---|
committer | Harpreet | 2015-09-23 18:22:28 +0530 |
commit | e34332a406e4f3fba9b99c6f9ec5138edfcc6aa2 (patch) | |
tree | a7dd948f18ddb1927d482a56b4a3b56486cb7e3d /thirdparty/linux/include/coin | |
parent | 33bdd144438436b759bc8d0b0beba715f0e39e5d (diff) | |
download | FOSSEE-Optimization-toolbox-e34332a406e4f3fba9b99c6f9ec5138edfcc6aa2.tar.gz FOSSEE-Optimization-toolbox-e34332a406e4f3fba9b99c6f9ec5138edfcc6aa2.tar.bz2 FOSSEE-Optimization-toolbox-e34332a406e4f3fba9b99c6f9ec5138edfcc6aa2.zip |
qpipopt added
Diffstat (limited to 'thirdparty/linux/include/coin')
53 files changed, 14958 insertions, 0 deletions
diff --git a/thirdparty/linux/include/coin/HSLLoader.h b/thirdparty/linux/include/coin/HSLLoader.h new file mode 100644 index 0000000..c38915c --- /dev/null +++ b/thirdparty/linux/include/coin/HSLLoader.h @@ -0,0 +1,378 @@ +/* Copyright (C) 2008, 2011 GAMS Development and others + All Rights Reserved. + This code is published under the Eclipse Public License. + + $Id: HSLLoader.h 2317 2013-06-01 13:16:07Z stefan $ + + Author: Stefan Vigerske +*/ + +#ifndef HSLLOADER_H_ +#define HSLLOADER_H_ + +#include "IpoptConfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ma77_default_control +#define ma77_control ma77_control_d +#define ma77_info ma77_info_d +#define ma77_default_control ma77_default_control_d +#define ma77_open_nelt ma77_open_nelt_d +#define ma77_open ma77_open_d +#define ma77_input_vars ma77_input_vars_d +#define ma77_input_reals ma77_input_reals_d +#define ma77_analyse ma77_analyse_d +#define ma77_factor ma77_factor_d +#define ma77_factor_solve ma77_factor_solve_d +#define ma77_solve ma77_solve_d +#define ma77_resid ma77_resid_d +#define ma77_scale ma77_scale_d +#define ma77_enquire_posdef ma77_enquire_posdef_d +#define ma77_enquire_indef ma77_enquire_indef_d +#define ma77_alter ma77_alter_d +#define ma77_restart ma77_restart_d +#define ma77_finalise ma77_finalise_d +#endif + +struct ma77_control; +struct ma77_info; +typedef double ma77pkgtype_d_; + + +#ifndef ma86_default_control +#define ma86_control ma86_control_d +#define ma86_info ma86_info_d +#define ma86_default_control ma86_default_control_d +#define ma86_analyse ma86_analyse_d +#define ma86_factor ma86_factor_d +#define ma86_factor_solve ma86_factor_solve_d +#define ma86_solve ma86_solve_d +#define ma86_finalise ma86_finalise_d +#endif + +struct ma86_control; +struct ma86_info; +typedef double ma86pkgtype_d_; +typedef double ma86realtype_d_; + +#ifndef ma97_default_control +#define ma97_control ma97_control_d +#define ma97_info ma97_info_d +#define ma97_default_control ma97_default_control_d +#define ma97_analyse ma97_analyse_d +#define ma97_factor ma97_factor_d +#define ma97_factor_solve ma97_factor_solve_d +#define ma97_solve ma97_solve_d +#define ma97_finalise ma97_finalise_d +#define ma97_free_akeep ma97_free_akeep_d +#endif + +struct ma97_control; +struct ma97_info; +typedef double ma97pkgtype_d_; +typedef double ma97realtype_d_; + +struct mc68_control_i; +struct mc68_info_i; + +#ifndef __IPTYPES_HPP__ +/* Type of Fortran integer translated into C */ +typedef FORTRAN_INTEGER_TYPE ipfint; +#endif + +typedef void (*ma27ad_t)(ipfint *N, ipfint *NZ, const ipfint *IRN, const ipfint* ICN, + ipfint *IW, ipfint* LIW, ipfint* IKEEP, ipfint *IW1, + ipfint* NSTEPS, ipfint* IFLAG, ipfint* ICNTL, + double* CNTL, ipfint *INFO, double* OPS); +typedef void (*ma27bd_t)(ipfint *N, ipfint *NZ, const ipfint *IRN, const ipfint* ICN, + double* A, ipfint* LA, ipfint* IW, ipfint* LIW, + ipfint* IKEEP, ipfint* NSTEPS, ipfint* MAXFRT, + ipfint* IW1, ipfint* ICNTL, double* CNTL, + ipfint* INFO); +typedef void (*ma27cd_t)(ipfint *N, double* A, ipfint* LA, ipfint* IW, + ipfint* LIW, double* W, ipfint* MAXFRT, + double* RHS, ipfint* IW1, ipfint* NSTEPS, + ipfint* ICNTL, double* CNTL); +typedef void (*ma27id_t)(ipfint* ICNTL, double* CNTL); + +typedef void (*ma28ad_t)(void* nsize, void* nz, void* rw, void* licn, void* iw, + void* lirn, void* iw2, void* pivtol, void* iw3, void* iw4, void* rw2, void* iflag); + +typedef void (*ma57ad_t) ( + ipfint *n, /* Order of matrix. */ + ipfint *ne, /* Number of entries. */ + const ipfint *irn, /* Matrix nonzero row structure */ + const ipfint *jcn, /* Matrix nonzero column structure */ + ipfint *lkeep, /* Workspace for the pivot order of lenght 3*n */ + ipfint *keep, /* Workspace for the pivot order of lenght 3*n */ + /* Automatically iflag = 0; ikeep pivot order iflag = 1 */ + ipfint *iwork, /* Integer work space. */ + ipfint *icntl, /* Integer Control parameter of length 30*/ + ipfint *info, /* Statistical Information; Integer array of length 20 */ + double *rinfo); /* Double Control parameter of length 5 */ + +typedef void (*ma57bd_t) ( + ipfint *n, /* Order of matrix. */ + ipfint *ne, /* Number of entries. */ + double *a, /* Numerical values. */ + double *fact, /* Entries of factors. */ + ipfint *lfact, /* Length of array `fact'. */ + ipfint *ifact, /* Indexing info for factors. */ + ipfint *lifact, /* Length of array `ifact'. */ + ipfint *lkeep, /* Length of array `keep'. */ + ipfint *keep, /* Integer array. */ + ipfint *iwork, /* Workspace of length `n'. */ + ipfint *icntl, /* Integer Control parameter of length 20. */ + double *cntl, /* Double Control parameter of length 5. */ + ipfint *info, /* Statistical Information; Integer array of length 40. */ + double *rinfo); /* Statistical Information; Real array of length 20. */ + +typedef void (*ma57cd_t) ( + ipfint *job, /* Solution job. Solve for... */ + ipfint *n, /* Order of matrix. */ + double *fact, /* Entries of factors. */ + ipfint *lfact, /* Length of array `fact'. */ + ipfint *ifact, /* Indexing info for factors. */ + ipfint *lifact, /* Length of array `ifact'. */ + ipfint *nrhs, /* Number of right hand sides. */ + double *rhs, /* Numerical Values. */ + ipfint *lrhs, /* Leading dimensions of `rhs'. */ + double *work, /* Real workspace. */ + ipfint *lwork, /* Length of `work', >= N*NRHS. */ + ipfint *iwork, /* Integer array of length `n'. */ + ipfint *icntl, /* Integer Control parameter array of length 20. */ + ipfint *info); /* Statistical Information; Integer array of length 40. */ + +typedef void (*ma57ed_t) ( + ipfint *n, + ipfint *ic, /* 0: copy real array. >=1: copy integer array. */ + ipfint *keep, + double *fact, + ipfint *lfact, + double *newfac, + ipfint *lnew, + ipfint *ifact, + ipfint *lifact, + ipfint *newifc, + ipfint *linew, + ipfint *info); + +typedef void (*ma57id_t) (double *cntl, ipfint *icntl); + +typedef void (*ma77_default_control_t)(struct ma77_control_d *control); +typedef void (*ma77_open_nelt_t)(const int n, const char* fname1, const char* fname2, + const char *fname3, const char *fname4, void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info, + const int nelt); +typedef void (*ma77_open_t)(const int n, const char* fname1, const char* fname2, + const char *fname3, const char *fname4, void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_input_vars_t)(const int idx, const int nvar, const int list[], + void **keep, const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_input_reals_t)(const int idx, const int length, + const double reals[], void **keep, const struct ma77_control_d *control, + struct ma77_info_d *info); +typedef void (*ma77_analyse_t)(const int order[], void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_factor_t)(const int posdef, void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info, + const double *scale); +typedef void (*ma77_factor_solve_t)(const int posdef, void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info, + const double *scale, const int nrhs, const int lx, + double rhs[]); +typedef void (*ma77_solve_t)(const int job, const int nrhs, const int lx, double x[], + void **keep, const struct ma77_control_d *control, struct ma77_info_d *info, + const double *scale); +typedef void (*ma77_resid_t)(const int nrhs, const int lx, const double x[], + const int lresid, double resid[], void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info, + double *anorm_bnd); +typedef void (*ma77_scale_t)(double scale[], void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info, + double *anorm); +typedef void (*ma77_enquire_posdef_t)(double d[], void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_enquire_indef_t)(int piv_order[], double d[], void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_alter_t)(const double d[], void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_restart_t)(const char *restart_file, const char *fname1, + const char *fname2, const char *fname3, const char *fname4, void **keep, + const struct ma77_control_d *control, struct ma77_info_d *info); +typedef void (*ma77_finalise_t)(void **keep, const struct ma77_control_d *control, + struct ma77_info_d *info); + +typedef void (*ma86_default_control_t)(struct ma86_control *control); +typedef void (*ma86_analyse_t)(const int n, const int ptr[], const int row[], + int order[], void **keep, const struct ma86_control *control, + struct ma86_info *info); +typedef void (*ma86_factor_t)(const int n, const int ptr[], const int row[], + const ma86pkgtype_d_ val[], const int order[], void **keep, + const struct ma86_control *control, struct ma86_info *info, + const ma86pkgtype_d_ scale[]); +typedef void (*ma86_factor_solve_t)(const int n, const int ptr[], + const int row[], const ma86pkgtype_d_ val[], const int order[], void **keep, + const struct ma86_control *control, struct ma86_info *info, const int nrhs, + const int ldx, ma86pkgtype_d_ x[], const ma86pkgtype_d_ scale[]); +typedef void (*ma86_solve_t)(const int job, const int nrhs, const int ldx, + ma86pkgtype_d_ *x, const int order[], void **keep, + const struct ma86_control *control, struct ma86_info *info, + const ma86pkgtype_d_ scale[]); +typedef void (*ma86_finalise_t)(void **keep, + const struct ma86_control *control); + +typedef void (*ma97_default_control_t)(struct ma97_control *control); +typedef void (*ma97_analyse_t)(const int check, const int n, const int ptr[], + const int row[], ma97pkgtype_d_ val[], void **akeep, + const struct ma97_control *control, struct ma97_info *info, int order[]); +typedef void (*ma97_factor_t)(const int matrix_type, const int ptr[], + const int row[], const ma97pkgtype_d_ val[], void **akeep, void **fkeep, + const struct ma97_control *control, struct ma97_info *info, + const ma97pkgtype_d_ scale[]); +typedef void (*ma97_factor_solve_t)(const int matrix_type, const int ptr[], + const int row[], const ma97pkgtype_d_ val[], const int nrhs, + ma97pkgtype_d_ x[], const int ldx, void **akeep, void **fkeep, + const struct ma97_control *control, struct ma97_info *info, + const ma97pkgtype_d_ scale[]); +typedef void (*ma97_solve_t)(const int job, const int nrhs, ma97pkgtype_d_ *x, + const int ldx, void **akeep, void **fkeep, + const struct ma97_control *control, struct ma97_info *info); +typedef void (*ma97_finalise_t)(void **akeep, void **fkeep); +typedef void (*ma97_free_akeep_t)(void **akeep); + +typedef void (*mc19ad_t)(ipfint *N, ipfint *NZ, double* A, ipfint *IRN, ipfint* ICN, float* R, float* C, float* W); + +typedef void (*mc68_default_control_t)(struct mc68_control_i *control); +typedef void (*mc68_order_t)(int ord, int n, const int ptr[], + const int row[], int perm[], const struct mc68_control_i *control, + struct mc68_info_i *info); + + /** Tries to load a dynamically linked library with HSL routines. + * Also tries to load symbols for those HSL routines that are not linked into Ipopt, i.e., HAVE_... is not defined. + * Return a failure if the library cannot be loaded, but not if a symbol is not found. + * @see LSL_isMA27available + * @see LSL_isMA28available + * @see LSL_isMA57available + * @see LSL_isMA77available + * @see LSL_isMA86available + * @see LSL_isMA97available + * @see LSL_isMC19available + * @param libname The name under which the HSL lib can be found, or NULL to use a default name (libhsl.SHAREDLIBEXT). + * @param msgbuf A buffer where we can store a failure message. Assumed to be NOT NULL! + * @param msglen Length of the message buffer. + * @return Zero on success, nonzero on failure. + */ + int LSL_loadHSL(const char* libname, char* msgbuf, int msglen); + + /** Unloads a loaded HSL library. + * @return Zero on success, nonzero on failure. + */ + int LSL_unloadHSL(); + + /** Indicates whether a HSL library has been loaded. + * @return Zero if not loaded, nonzero if handle is loaded + */ + int LSL_isHSLLoaded(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use MA27 have been found. + * @return Zero if not available, nonzero if MA27 is available in the loaded library. + */ + int LSL_isMA27available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use MA28 have been found. + * @return Zero if not available, nonzero if MA28 is available in the loaded library. + */ + int LSL_isMA28available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use MA57 have been found. + * @return Zero if not available, nonzero if MA57 is available in the loaded library. + */ + int LSL_isMA57available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use MA77 have been found. + * @return Zero if not available, nonzero if HSL_MA77 is available in the loaded library. + */ + int LSL_isMA77available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use HSL_MA86 have been found. + * @return Zero if not available, nonzero if HSL_MA86 is available in the loaded library. + */ + int LSL_isMA86available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use HSL_MA97 have been found. + * @return Zero if not available, nonzero if HSL_MA97 is available in the loaded library. + */ + int LSL_isMA97available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use MA57 have been found. + * @return Zero if not available, nonzero if MC19 is available in the loaded library. + */ + int LSL_isMC19available(); + + /** Indicates whether a HSL library is loaded and all symbols necessary to use HSL_MC68 have been found. + * @return Zero if not available, nonzero if MC68 is available in the loaded library. + */ + int LSL_isMC68available(); + + /** Returns name of the shared library that should contain HSL */ + char* LSL_HSLLibraryName(); + + /** sets pointers to MA27 functions */ + void LSL_setMA27(ma27ad_t ma27ad, ma27bd_t ma27bd, ma27cd_t ma27cd, ma27id_t ma27id); + + /** sets pointers to MA28 functions */ + void LSL_setMA28(ma28ad_t ma28ad); + + /** sets pointers to MA57 functions */ + void LSL_setMA57(ma57ad_t ma57ad, ma57bd_t ma57bd, ma57cd_t ma57cd, ma57ed_t ma57ed, ma57id_t ma57id); + + /** sets pointers to MA77 functions */ + void LSL_setMA77(ma77_default_control_t ma77_default_control, + ma77_open_nelt_t ma77_open_nelt, + ma77_open_t ma77_open, + ma77_input_vars_t ma77_input_vars, + ma77_input_reals_t ma77_input_reals, + ma77_analyse_t ma77_analyse, + ma77_factor_t ma77_factor, + ma77_factor_solve_t ma77_factor_solve, + ma77_solve_t ma77_solve, + ma77_resid_t ma77_resid, + ma77_scale_t ma77_scale, + ma77_enquire_posdef_t ma77_enquire_posdef, + ma77_enquire_indef_t ma77_enquire_indef, + ma77_alter_t ma77_alter, + ma77_restart_t ma77_restart, + ma77_finalise_t ma77_finalise); + + /** sets pointers to MA86 functions */ + void LSL_setMA86(ma86_default_control_t ma86_default_control, + ma86_analyse_t ma86_analyse, + ma86_factor_t ma86_factor, + ma86_factor_solve_t ma86_factor_solve, + ma86_solve_t ma86_solve, + ma86_finalise_t ma86_finalise); + + /** sets pointers to MA97 functions */ + void LSL_setMA97(ma97_default_control_t ma97_default_control, + ma97_analyse_t ma97_analyse, + ma97_factor_t ma97_factor, + ma97_factor_solve_t ma97_factor_solve, + ma97_solve_t ma97_solve, + ma97_finalise_t ma97_finalise, + ma97_free_akeep_t ma97_free_akeep); + + /** sets pointer to MC19 function */ + void LSL_setMC19(mc19ad_t mc19ad); + + /** sets pointers to MC68 functions */ + void LSL_setMC68(mc68_default_control_t mc68_default_control, mc68_order_t mc68_order); + +#ifdef __cplusplus +} +#endif + +#endif /*HSLLOADER_H_*/ diff --git a/thirdparty/linux/include/coin/IpAlgTypes.hpp b/thirdparty/linux/include/coin/IpAlgTypes.hpp new file mode 100644 index 0000000..53e8ea5 --- /dev/null +++ b/thirdparty/linux/include/coin/IpAlgTypes.hpp @@ -0,0 +1,66 @@ +// Copyright (C) 2005, 2010 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpAlgTypes.hpp 2551 2015-02-13 02:51:47Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2005-07-19 + +#ifndef __IPALGTYPES_HPP__ +#define __IPALGTYPES_HPP__ + +#include "IpTypes.hpp" +#include "IpException.hpp" + +namespace Ipopt +{ + + /**@name Enumerations */ + //@{ + /** enum for the return from the optimize algorithm + * (obviously we need to add more) */ + enum SolverReturn { + SUCCESS, + MAXITER_EXCEEDED, + CPUTIME_EXCEEDED, + STOP_AT_TINY_STEP, + STOP_AT_ACCEPTABLE_POINT, + LOCAL_INFEASIBILITY, + USER_REQUESTED_STOP, + FEASIBLE_POINT_FOUND, + DIVERGING_ITERATES, + RESTORATION_FAILURE, + ERROR_IN_STEP_COMPUTATION, + INVALID_NUMBER_DETECTED, + TOO_FEW_DEGREES_OF_FREEDOM, + INVALID_OPTION, + OUT_OF_MEMORY, + INTERNAL_ERROR, + UNASSIGNED + }; + //@} + + /** @name Some exceptions used in multiple places */ + //@{ + DECLARE_STD_EXCEPTION(LOCALLY_INFEASIBLE); + DECLARE_STD_EXCEPTION(TOO_FEW_DOF); + DECLARE_STD_EXCEPTION(TINY_STEP_DETECTED); + DECLARE_STD_EXCEPTION(ACCEPTABLE_POINT_REACHED); + DECLARE_STD_EXCEPTION(FEASIBILITY_PROBLEM_SOLVED); + DECLARE_STD_EXCEPTION(INVALID_WARMSTART); + DECLARE_STD_EXCEPTION(INTERNAL_ABORT); + DECLARE_STD_EXCEPTION(NO_FREE_VARIABLES_BUT_FEASIBLE); + DECLARE_STD_EXCEPTION(NO_FREE_VARIABLES_AND_INFEASIBLE); + DECLARE_STD_EXCEPTION(INCONSISTENT_BOUNDS); + /** Exception FAILED_INITIALIZATION for problem during + * initialization of a strategy object (or other problems). This + * is thrown by a strategy object, if a problem arises during + * initialization, such as a value out of a feasible range. + */ + DECLARE_STD_EXCEPTION(FAILED_INITIALIZATION); + //@} + + +} + +#endif diff --git a/thirdparty/linux/include/coin/IpBlas.hpp b/thirdparty/linux/include/coin/IpBlas.hpp new file mode 100644 index 0000000..517057b --- /dev/null +++ b/thirdparty/linux/include/coin/IpBlas.hpp @@ -0,0 +1,78 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpBlas.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPBLAS_HPP__ +#define __IPBLAS_HPP__ + +#include "IpUtils.hpp" + +namespace Ipopt +{ + // If CBLAS is not available, this is our own interface to the Fortran + // implementation + + /** Wrapper for BLAS function DDOT. Compute dot product of vector x + and vector y */ + Number IpBlasDdot(Index size, const Number *x, Index incX, const Number *y, + Index incY); + + /** Wrapper for BLAS function DNRM2. Compute 2-norm of vector x*/ + Number IpBlasDnrm2(Index size, const Number *x, Index incX); + + /** Wrapper for BLAS function DASUM. Compute 1-norm of vector x*/ + Number IpBlasDasum(Index size, const Number *x, Index incX); + + /** Wrapper for BLAS function IDAMAX. Compute index for largest + absolute element of vector x */ + Index IpBlasIdamax(Index size, const Number *x, Index incX); + + /** Wrapper for BLAS subroutine DCOPY. Copying vector x into vector + y */ + void IpBlasDcopy(Index size, const Number *x, Index incX, Number *y, + Index incY); + + /** Wrapper for BLAS subroutine DAXPY. Adding the alpha multiple of + vector x to vector y */ + void IpBlasDaxpy(Index size, Number alpha, const Number *x, Index incX, + Number *y, Index incY); + + /** Wrapper for BLAS subroutine DSCAL. Scaling vector x by scalar + alpha */ + void IpBlasDscal(Index size, Number alpha, Number *x, Index incX); + + /** Wrapper for BLAS subroutine DGEMV. Multiplying a matrix with a + vector. */ + void IpBlasDgemv(bool trans, Index nRows, Index nCols, Number alpha, + const Number* A, Index ldA, const Number* x, + Index incX, Number beta, Number* y, Index incY); + + /** Wrapper for BLAS subroutine DSYMV. Multiplying a symmetric + matrix with a vector. */ + void IpBlasDsymv(Index n, Number alpha, const Number* A, Index ldA, + const Number* x, Index incX, Number beta, Number* y, + Index incY); + + /** Wrapper for BLAS subroutine DGEMM. Multiplying two matrices */ + void IpBlasDgemm(bool transa, bool transb, Index m, Index n, Index k, + Number alpha, const Number* A, Index ldA, const Number* B, + Index ldB, Number beta, Number* C, Index ldC); + + /** Wrapper for BLAS subroutine DSYRK. Adding a high-rank update to + * a matrix */ + void IpBlasDsyrk(bool trans, Index ndim, Index nrank, + Number alpha, const Number* A, Index ldA, + Number beta, Number* C, Index ldC); + + /** Wrapper for BLAS subroutine DTRSM. Backsolve for a lower triangular + * matrix. */ + void IpBlasDtrsm(bool trans, Index ndim, Index nrhs, Number alpha, + const Number* A, Index ldA, Number* B, Index ldB); + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpCachedResults.hpp b/thirdparty/linux/include/coin/IpCachedResults.hpp new file mode 100644 index 0000000..b9f5f15 --- /dev/null +++ b/thirdparty/linux/include/coin/IpCachedResults.hpp @@ -0,0 +1,779 @@ +// Copyright (C) 2004, 2011 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpCachedResults.hpp 2472 2014-04-05 17:47:20Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPCACHEDRESULTS_HPP__ +#define __IPCACHEDRESULTS_HPP__ + +#include "IpTaggedObject.hpp" +#include "IpObserver.hpp" +#include <algorithm> +#include <vector> +#include <list> + +namespace Ipopt +{ + +#if COIN_IPOPT_CHECKLEVEL > 2 +# define IP_DEBUG_CACHE +#endif +#ifdef IP_DEBUG_CACHE +# include "IpDebug.hpp" +#endif + + // Forward Declarations + + template <class T> + class DependentResult; + + // AW: I'm taking this out, since this is by far the most used + // class. We should keep it as simple as possible. + // /** Cache Priority Enum */ + // enum CachePriority + // { + // CP_Lowest, + // CP_Standard, + // CP_Trial, + // CP_Iterate + // }; + + /** Templated class for Cached Results. This class stores up to a + * given number of "results", entities that are stored here + * together with identifiers, that can be used to later retrieve the + * information again. + * + * Typically, T is a SmartPtr for some calculated quantity that + * should be stored (such as a Vector). The identifiers (or + * dependencies) are a (possibly varying) number of Tags from + * TaggedObjects, and a number of Numbers. Results are added to + * the cache using the AddCachedResults methods, and the can be + * retrieved with the GetCachedResults methods. The second set of + * methods checks whether a result has been cached for the given + * identifiers. If a corresponding result is found, a copy of it + * is returned and the method evaluates to true, otherwise it + * evaluates to false. + * + * Note that cached results can become "stale", namely when a + * TaggedObject that is used to identify this CachedResult is + * changed. When this happens, the cached result can never be + * asked for again, so that there is no point in storing it any + * longer. For this purpose, a cached result, which is stored as a + * DependentResult, inherits off an Observer. This Observer + * retrieves notification whenever a TaggedObject dependency has + * changed. Stale results are later removed from the cache. + */ + template <class T> + class CachedResults + { + public: +#ifdef IP_DEBUG_CACHE + /** (Only if compiled in DEBUG mode): debug verbosity level */ + static const Index dbg_verbosity; +#endif + + /** @name Constructors and Destructors. */ + //@{ + /** Constructor, where max_cache_size is the maximal number of + * results that should be cached. If max_cache_size is negative, + * we allow an infinite amount of cache. + */ + CachedResults(Int max_cache_size); + + /** Destructor */ + virtual ~CachedResults(); + //@} + + /** @name Generic methods for adding and retrieving cached results. */ + //@{ + /** Generic method for adding a result to the cache, given a + * std::vector of TaggesObjects and a std::vector of Numbers. + */ + void AddCachedResult(const T& result, + const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents); + + /** Generic method for retrieving a cached results, given the + * dependencies as a std::vector of TaggesObjects and a + * std::vector of Numbers. + */ + bool GetCachedResult(T& retResult, + const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) const; + + /** Method for adding a result, providing only a std::vector of + * TaggedObjects. + */ + void AddCachedResult(const T& result, + const std::vector<const TaggedObject*>& dependents); + + /** Method for retrieving a cached result, providing only a + * std::vector of TaggedObjects. + */ + bool GetCachedResult(T& retResult, + const std::vector<const TaggedObject*>& dependents) const; + //@} + + /** @name Pointer-based methods for adding and retrieving cached + * results, providing dependencies explicitly. + */ + //@{ + /** Method for adding a result to the cache, proving one + * dependency as a TaggedObject explicitly. + */ + void AddCachedResult1Dep(const T& result, + const TaggedObject* dependent1); + + /** Method for retrieving a cached result, proving one dependency + * as a TaggedObject explicitly. + */ + bool GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1); + + /** Method for adding a result to the cache, proving two + * dependencies as a TaggedObject explicitly. + */ + void AddCachedResult2Dep(const T& result, + const TaggedObject* dependent1, + const TaggedObject* dependent2); + + /** Method for retrieving a cached result, proving two + * dependencies as a TaggedObject explicitly. + */ + bool GetCachedResult2Dep(T& retResult, + const TaggedObject* dependent1, + const TaggedObject* dependent2); + + /** Method for adding a result to the cache, proving three + * dependencies as a TaggedObject explicitly. + */ + void AddCachedResult3Dep(const T& result, + const TaggedObject* dependent1, + const TaggedObject* dependent2, + const TaggedObject* dependent3); + + /** Method for retrieving a cached result, proving three + * dependencies as a TaggedObject explicitly. + */ + bool GetCachedResult3Dep(T& retResult, + const TaggedObject* dependent1, + const TaggedObject* dependent2, + const TaggedObject* dependent3); + + /** @name Pointer-free version of the Add and Get methods */ + //@{ + bool GetCachedResult1Dep(T& retResult, const TaggedObject& dependent1) + { + return GetCachedResult1Dep(retResult, &dependent1); + } + bool GetCachedResult2Dep(T& retResult, + const TaggedObject& dependent1, + const TaggedObject& dependent2) + { + return GetCachedResult2Dep(retResult, &dependent1, &dependent2); + } + bool GetCachedResult3Dep(T& retResult, + const TaggedObject& dependent1, + const TaggedObject& dependent2, + const TaggedObject& dependent3) + { + return GetCachedResult3Dep(retResult, &dependent1, &dependent2, &dependent3); + } + void AddCachedResult1Dep(const T& result, + const TaggedObject& dependent1) + { + AddCachedResult1Dep(result, &dependent1); + } + void AddCachedResult2Dep(const T& result, + const TaggedObject& dependent1, + const TaggedObject& dependent2) + { + AddCachedResult2Dep(result, &dependent1, &dependent2); + } + void AddCachedResult3Dep(const T& result, + const TaggedObject& dependent1, + const TaggedObject& dependent2, + const TaggedObject& dependent3) + { + AddCachedResult3Dep(result, &dependent1, &dependent2, &dependent3); + } + //@} + + /** Invalidates the result for given dependencies. Sets the stale + * flag for the corresponding cached result to true if it is + * found. Returns true, if the result was found. */ + bool InvalidateResult(const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents); + + /** Invalidates all cached results */ + void Clear(); + + /** Invalidate all cached results and changes max_cache_size */ + void Clear(Int max_cache_size); + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + CachedResults(); + + /** Copy Constructor */ + CachedResults(const CachedResults&); + + /** Overloaded Equals Operator */ + void operator=(const CachedResults&); + //@} + + /** maximum number of cached results */ + Int max_cache_size_; + + /** list of currently cached results. */ + mutable std::list<DependentResult<T>*>* cached_results_; + + /** internal method for removing stale DependentResults from the + * list. It is called at the beginning of every + * GetDependentResult method. + */ + void CleanupInvalidatedResults() const; + + /** Print list of currently cached results */ + void DebugPrintCachedResults() const; + }; + + /** Templated class which stores one entry for the CachedResult + * class. It stores the result (of type T), together with its + * dependencies (vector of TaggedObjects and vector of Numbers). + * It also stores a priority. + */ + template <class T> + class DependentResult : public Observer + { + public: + +#ifdef IP_DEBUG_CACHE + static const Index dbg_verbosity; +#endif + + /** @name Constructor, Destructors */ + //@{ + /** Constructor, given all information about the result. */ + DependentResult(const T& result, const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents); + + /** Destructor. */ + ~DependentResult(); + //@} + + /** @name Accessor method. */ + //@{ + /** This returns true, if the DependentResult is no longer valid. */ + bool IsStale() const; + + /** Invalidates the cached result. */ + void Invalidate(); + + /** Returns the cached result. */ + const T& GetResult() const; + //@} + + /** This method returns true if the dependencies provided to this + * function are identical to the ones stored with the + * DependentResult. + */ + bool DependentsIdentical(const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) const; + + /** Print information about this DependentResults. */ + void DebugPrint() const; + + protected: + /** This method is overloading the pure virtual method from the + * Observer base class. This method is called when a Subject + * registered for this Observer sends a notification. In this + * particular case, if this method is called with + * notify_type==NT_Changed or NT_BeingDeleted, then this results + * is marked as stale. + */ + virtual void RecieveNotification(NotifyType notify_type, const Subject* subject); + + private: + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + DependentResult(); + + /** Copy Constructor */ + DependentResult(const DependentResult&); + + /** Overloaded Equals Operator */ + void operator=(const DependentResult&); + //@} + + /** Flag indicating, if the cached result is still valid. A + result becomes invalid, if the RecieveNotification method is + called with NT_Changed */ + bool stale_; + /** The value of the dependent results */ + const T result_; + /** Dependencies in form of TaggedObjects */ + std::vector<TaggedObject::Tag> dependent_tags_; + /** Dependencies in form a Numbers */ + std::vector<Number> scalar_dependents_; + }; + +#ifdef IP_DEBUG_CACHE + template <class T> + const Index CachedResults<T>::dbg_verbosity = 0; + + template <class T> + const Index DependentResult<T>::dbg_verbosity = 0; +#endif + + template <class T> + DependentResult<T>::DependentResult( + const T& result, + const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) + : + stale_(false), + result_(result), + dependent_tags_(dependents.size()), + scalar_dependents_(scalar_dependents) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("DependentResult<T>::DependentResult()", dbg_verbosity); +#endif + + for (Index i=0; i<(Index)dependents.size(); i++) { + if (dependents[i]) { + // Call the RequestAttach method of the Observer base class. + // This will add this dependent result in the Observer list + // for the Subject dependents[i]. As a consequence, the + // RecieveNotification method of this DependentResult will be + // called with notify_type=NT_Changed, whenever the + // TaggedResult dependents[i] is changed (i.e. its HasChanged + // method is called). + RequestAttach(NT_Changed, dependents[i]); + dependent_tags_[i] = dependents[i]->GetTag(); + } + else { + dependent_tags_[i] = 0; + } + } + } + + template <class T> + DependentResult<T>::~DependentResult() + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("DependentResult<T>::~DependentResult()", dbg_verbosity); + //DBG_ASSERT(stale_ == true); +#endif + // Nothing to be done here, destructor + // of T should sufficiently remove + // any memory, etc. + } + + template <class T> + bool DependentResult<T>::IsStale() const + { + return stale_; + } + + template <class T> + void DependentResult<T>::Invalidate() + { + stale_ = true; + } + + template <class T> + void DependentResult<T>::RecieveNotification(NotifyType notify_type, const Subject* subject) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("DependentResult<T>::RecieveNotification", dbg_verbosity); +#endif + + if (notify_type == NT_Changed || notify_type==NT_BeingDestroyed) { + stale_ = true; + // technically, I could unregister the notifications here, but they + // aren't really hurting anything + } + } + + template <class T> + bool DependentResult<T>::DependentsIdentical(const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) const + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("DependentResult<T>::DependentsIdentical", dbg_verbosity); + DBG_ASSERT(stale_ == false); + DBG_ASSERT(dependents.size() == dependent_tags_.size()); +#endif + + bool retVal = true; + + if (dependents.size() != dependent_tags_.size() + || scalar_dependents.size() != scalar_dependents_.size()) { + retVal = false; + } + else { + for (Index i=0; i<(Index)dependents.size(); i++) { + if ( (dependents[i] && dependents[i]->GetTag() != dependent_tags_[i]) + || (!dependents[i] && dependent_tags_[i] != 0) ) { + retVal = false; + break; + } + } + if (retVal) { + for (Index i=0; i<(Index)scalar_dependents.size(); i++) { + if (scalar_dependents[i] != scalar_dependents_[i]) { + retVal = false; + break; + } + } + } + } + + return retVal; + } + + template <class T> + const T& DependentResult<T>::GetResult() const + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("DependentResult<T>::GetResult()", dbg_verbosity); + DBG_ASSERT(stale_ == false); +#endif + + return result_; + } + + template <class T> + void DependentResult<T>::DebugPrint() const + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("DependentResult<T>::DebugPrint", dbg_verbosity); +#endif + + } + + template <class T> + CachedResults<T>::CachedResults(Int max_cache_size) + : + max_cache_size_(max_cache_size), + cached_results_(NULL) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::CachedResults", dbg_verbosity); +#endif + + } + + template <class T> + CachedResults<T>::~CachedResults() + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::!CachedResults()", dbg_verbosity); +#endif + + if (cached_results_) { + for (typename std::list< DependentResult<T>* >::iterator iter = cached_results_-> + begin(); + iter != cached_results_->end(); + iter++) { + delete *iter; + } + delete cached_results_; + } + /* + while (!cached_results_.empty()) { + DependentResult<T>* result = cached_results_.back(); + cached_results_.pop_back(); + delete result; + } + */ + } + + template <class T> + void CachedResults<T>::AddCachedResult(const T& result, + const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::AddCachedResult", dbg_verbosity); +#endif + + CleanupInvalidatedResults(); + + // insert the new one here + DependentResult<T>* newResult = new DependentResult<T>(result, dependents, scalar_dependents); + if (!cached_results_) { + cached_results_ = new std::list<DependentResult<T>*>; + } + cached_results_->push_front(newResult); + + // keep the list small enough + if (max_cache_size_ >= 0) { // if negative, allow infinite cache + // non-negative - limit size of list to max_cache_size + DBG_ASSERT((Int)cached_results_->size()<=max_cache_size_+1); + if ((Int)cached_results_->size() > max_cache_size_) { + delete cached_results_->back(); + cached_results_->pop_back(); + } + } + +#ifdef IP_DEBUG_CACHE + DBG_EXEC(2, DebugPrintCachedResults()); +#endif + + } + + template <class T> + void CachedResults<T>::AddCachedResult(const T& result, + const std::vector<const TaggedObject*>& dependents) + { + std::vector<Number> scalar_dependents; + AddCachedResult(result, dependents, scalar_dependents); + } + + template <class T> + bool CachedResults<T>::GetCachedResult(T& retResult, const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) const + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::GetCachedResult", dbg_verbosity); +#endif + + if (!cached_results_) + return false; + + CleanupInvalidatedResults(); + + bool retValue = false; + typename std::list< DependentResult<T>* >::const_iterator iter; + for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) { + if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) { + retResult = (*iter)->GetResult(); + retValue = true; + break; + } + } + +#ifdef IP_DEBUG_CACHE + DBG_EXEC(2, DebugPrintCachedResults()); +#endif + + return retValue; + } + + template <class T> + bool CachedResults<T>::GetCachedResult( + T& retResult, const std::vector<const TaggedObject*>& dependents) const + { + std::vector<Number> scalar_dependents; + return GetCachedResult(retResult, dependents, scalar_dependents); + } + + template <class T> + void CachedResults<T>::AddCachedResult1Dep(const T& result, + const TaggedObject* dependent1) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::AddCachedResult1Dep", dbg_verbosity); +#endif + + std::vector<const TaggedObject*> dependents(1); + dependents[0] = dependent1; + + AddCachedResult(result, dependents); + } + + template <class T> + bool CachedResults<T>::GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::GetCachedResult1Dep", dbg_verbosity); +#endif + + std::vector<const TaggedObject*> dependents(1); + dependents[0] = dependent1; + + return GetCachedResult(retResult, dependents); + } + + template <class T> + void CachedResults<T>::AddCachedResult2Dep(const T& result, const TaggedObject* dependent1, + const TaggedObject* dependent2) + + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity); +#endif + + std::vector<const TaggedObject*> dependents(2); + dependents[0] = dependent1; + dependents[1] = dependent2; + + AddCachedResult(result, dependents); + } + + template <class T> + bool CachedResults<T>::GetCachedResult2Dep(T& retResult, const TaggedObject* dependent1, const TaggedObject* dependent2) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::GetCachedResult2Dep", dbg_verbosity); +#endif + + std::vector<const TaggedObject*> dependents(2); + dependents[0] = dependent1; + dependents[1] = dependent2; + + return GetCachedResult(retResult, dependents); + } + + template <class T> + void CachedResults<T>::AddCachedResult3Dep(const T& result, const TaggedObject* dependent1, + const TaggedObject* dependent2, + const TaggedObject* dependent3) + + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity); +#endif + + std::vector<const TaggedObject*> dependents(3); + dependents[0] = dependent1; + dependents[1] = dependent2; + dependents[2] = dependent3; + + AddCachedResult(result, dependents); + } + + template <class T> + bool CachedResults<T>::GetCachedResult3Dep(T& retResult, const TaggedObject* dependent1, + const TaggedObject* dependent2, + const TaggedObject* dependent3) + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::GetCachedResult2Dep", dbg_verbosity); +#endif + + std::vector<const TaggedObject*> dependents(3); + dependents[0] = dependent1; + dependents[1] = dependent2; + dependents[2] = dependent3; + + return GetCachedResult(retResult, dependents); + } + + template <class T> + bool CachedResults<T>::InvalidateResult(const std::vector<const TaggedObject*>& dependents, + const std::vector<Number>& scalar_dependents) + { + if (!cached_results_) + return false; + + CleanupInvalidatedResults(); + + bool retValue = false; + typename std::list< DependentResult<T>* >::const_iterator iter; + for (iter = cached_results_->begin(); iter != cached_results_->end(); + iter++) { + if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) { + (*iter)->Invalidate(); + retValue = true; + break; + } + } + + return retValue; + } + + template <class T> + void CachedResults<T>::Clear() + { + if (!cached_results_) + return; + + typename std::list< DependentResult<T>* >::const_iterator iter; + for (iter = cached_results_->begin(); iter != cached_results_->end(); + iter++) { + (*iter)->Invalidate(); + } + + CleanupInvalidatedResults(); + } + + template <class T> + void CachedResults<T>::Clear(Int max_cache_size) + { + Clear(); + max_cache_size_ = max_cache_size; + } + + template <class T> + void CachedResults<T>::CleanupInvalidatedResults() const + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::CleanupInvalidatedResults", dbg_verbosity); +#endif + + if (!cached_results_) + return; + + typename std::list< DependentResult<T>* >::iterator iter; + iter = cached_results_->begin(); + while (iter != cached_results_->end()) { + if ((*iter)->IsStale()) { + typename std::list< DependentResult<T>* >::iterator + iter_to_remove = iter; + iter++; + DependentResult<T>* result_to_delete = (*iter_to_remove); + cached_results_->erase(iter_to_remove); + delete result_to_delete; + } + else { + iter++; + } + } + } + + template <class T> + void CachedResults<T>::DebugPrintCachedResults() const + { +#ifdef IP_DEBUG_CACHE + DBG_START_METH("CachedResults<T>::DebugPrintCachedResults", dbg_verbosity); + if (DBG_VERBOSITY()>=2 ) { + if (!cached_results_) { + DBG_PRINT((2,"Currentlt no cached results:\n")); + } + else { + typename std::list< DependentResult<T>* >::const_iterator iter; + DBG_PRINT((2,"Current set of cached results:\n")); + for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) { + DBG_PRINT((2," DependentResult:0x%x\n", (*iter))); + } + } + } +#endif + + } + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpCompoundVector.hpp b/thirdparty/linux/include/coin/IpCompoundVector.hpp new file mode 100644 index 0000000..a4c52ab --- /dev/null +++ b/thirdparty/linux/include/coin/IpCompoundVector.hpp @@ -0,0 +1,339 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpCompoundVector.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPCOMPOUNDVECTOR_HPP__ +#define __IPCOMPOUNDVECTOR_HPP__ + +#include "IpUtils.hpp" +#include "IpVector.hpp" +#include <vector> + +namespace Ipopt +{ + + /* forward declarations */ + class CompoundVectorSpace; + + /** Class of Vectors consisting of other vectors. This vector is a + * vector that consists of zero, one or more Vector's which are + * stacked on each others: \f$ x_{\rm compound} = + * \left(\begin{array}{c}x_0\\\dots\\x_{{\rm + * ncomps} - 1}\end{array}\right)\f$. The individual components can be + * associated to different VectorSpaces. The individual components + * can also be const and non-const Vectors. + */ + class CompoundVector : public Vector + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor, given the corresponding CompoundVectorSpace. + * Before this constructor can be called, all components of the + * CompoundVectorSpace have to be set, so that the constructors + * for the individual components can be called. If the flag + * create_new is true, then the individual components of the new + * CompoundVector are initialized with the MakeNew methods of + * each VectorSpace (and are non-const). Otherwise, the + * individual components can later be set using the SetComp and + * SetCompNonConst method. + */ + CompoundVector(const CompoundVectorSpace* owner_space, bool create_new); + + /** Default destructor */ + virtual ~CompoundVector(); + //@} + + /** Method for setting the pointer for a component that is a const + * Vector + */ + void SetComp(Index icomp, const Vector& vec); + + /** Method for setting the pointer for a component that is a + * non-const Vector + */ + void SetCompNonConst(Index icomp, Vector& vec); + + /** Number of components of this compound vector */ + inline Index NComps() const; + + /** Check if a particular component is const or not */ + bool IsCompConst(Index i) const + { + DBG_ASSERT(i > 0 && i < NComps()); + DBG_ASSERT(IsValid(comps_[i]) || IsValid(const_comps_[i])); + if (IsValid(const_comps_[i])) { + return true; + } + return false; + } + + /** Check if a particular component is null or not */ + bool IsCompNull(Index i) const + { + DBG_ASSERT(i >= 0 && i < NComps()); + if (IsValid(comps_[i]) || IsValid(const_comps_[i])) { + return false; + } + return true; + } + + /** Return a particular component (const version) */ + SmartPtr<const Vector> GetComp(Index i) const + { + return ConstComp(i); + } + + /** Return a particular component (non-const version). Note that + * calling this method with mark the CompoundVector as changed. + * Therefore, only use this method if you are intending to change + * the Vector that you receive. + */ + SmartPtr<Vector> GetCompNonConst(Index i) + { + ObjectChanged(); + return Comp(i); + } + + protected: + /** @name Overloaded methods from Vector base class */ + //@{ + /** Copy the data of the vector x into this vector (DCOPY). */ + virtual void CopyImpl(const Vector& x); + + /** Scales the vector by scalar alpha (DSCAL) */ + virtual void ScalImpl(Number alpha); + + /** Add the multiple alpha of vector x to this vector (DAXPY) */ + virtual void AxpyImpl(Number alpha, const Vector &x); + + /** Computes inner product of vector x with this (DDOT) */ + virtual Number DotImpl(const Vector &x) const; + + /** Computes the 2-norm of this vector (DNRM2) */ + virtual Number Nrm2Impl() const; + + /** Computes the 1-norm of this vector (DASUM) */ + virtual Number AsumImpl() const; + + /** Computes the max-norm of this vector (based on IDAMAX) */ + virtual Number AmaxImpl() const; + + /** Set each element in the vector to the scalar alpha. */ + virtual void SetImpl(Number value); + + /** Element-wise division \f$y_i \gets y_i/x_i\f$.*/ + virtual void ElementWiseDivideImpl(const Vector& x); + + /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$.*/ + virtual void ElementWiseMultiplyImpl(const Vector& x); + + /** Element-wise max against entries in x */ + virtual void ElementWiseMaxImpl(const Vector& x); + + /** Element-wise min against entries in x */ + virtual void ElementWiseMinImpl(const Vector& x); + + /** Element-wise reciprocal */ + virtual void ElementWiseReciprocalImpl(); + + /** Element-wise absolute values */ + virtual void ElementWiseAbsImpl(); + + /** Element-wise square-root */ + virtual void ElementWiseSqrtImpl(); + + /** Replaces entries with sgn of the entry */ + virtual void ElementWiseSgnImpl(); + + /** Add scalar to every component of the vector.*/ + virtual void AddScalarImpl(Number scalar); + + /** Max value in the vector */ + virtual Number MaxImpl() const; + + /** Min value in the vector */ + virtual Number MinImpl() const; + + /** Computes the sum of the lements of vector */ + virtual Number SumImpl() const; + + /** Computes the sum of the logs of the elements of vector */ + virtual Number SumLogsImpl() const; + + /** @name Implemented specialized functions */ + //@{ + /** Add two vectors (a * v1 + b * v2). Result is stored in this + vector. */ + void AddTwoVectorsImpl(Number a, const Vector& v1, + Number b, const Vector& v2, Number c); + /** Fraction to the boundary parameter. */ + Number FracToBoundImpl(const Vector& delta, Number tau) const; + /** Add the quotient of two vectors, y = a * z/s + c * y. */ + void AddVectorQuotientImpl(Number a, const Vector& z, const Vector& s, + Number c); + //@} + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + /** @name Output methods */ + //@{ + /* Print the entire vector with padding */ + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. + */ + //@{ + /** Default Constructor */ + CompoundVector(); + + /** Copy Constructor */ + CompoundVector(const CompoundVector&); + + /** Overloaded Equals Operator */ + void operator=(const CompoundVector&); + //@} + + /** Components of the compound vector. The components + * are stored by SmartPtrs in a std::vector + */ + std::vector< SmartPtr<Vector> > comps_; + std::vector< SmartPtr<const Vector> > const_comps_; + + const CompoundVectorSpace* owner_space_; + + bool vectors_valid_; + + bool VectorsValid(); + + inline const Vector* ConstComp(Index i) const; + + inline Vector* Comp(Index i); + }; + + /** This vectors space is the vector space for CompoundVector. + * Before a CompoundVector can be created, all components of this + * CompoundVectorSpace have to be set. When calling the constructor, + * the number of component has to be specified. The individual + * VectorSpaces can be set with the SetComp method. + */ + class CompoundVectorSpace : public VectorSpace + { + public: + /** @name Constructors/Destructors. */ + //@{ + /** Constructor, has to be given the number of components and the + * total dimension of all components combined. */ + CompoundVectorSpace(Index ncomp_spaces, Index total_dim); + + /** Destructor */ + ~CompoundVectorSpace() + {} + //@} + + /** Method for setting the individual component VectorSpaces */ + virtual void SetCompSpace(Index icomp /** Number of the component to be set */ , + const VectorSpace& vec_space /** VectorSpace for component icomp */ + ); + + /** Method for obtaining an individual component VectorSpace */ + SmartPtr<const VectorSpace> GetCompSpace(Index icomp) const; + + /** Accessor method to obtain the number of components */ + Index NCompSpaces() const + { + return ncomp_spaces_; + } + + /** Method for creating a new vector of this specific type. */ + virtual CompoundVector* MakeNewCompoundVector(bool create_new = true) const + { + return new CompoundVector(this, create_new); + } + + /** Overloaded MakeNew method for the VectorSpace base class. + */ + virtual Vector* MakeNew() const + { + return MakeNewCompoundVector(); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + CompoundVectorSpace(); + + /** Copy Constructor */ + CompoundVectorSpace(const CompoundVectorSpace&); + + /** Overloaded Equals Operator */ + CompoundVectorSpace& operator=(const CompoundVectorSpace&); + //@} + + /** Number of components */ + const Index ncomp_spaces_; + + /** std::vector of vector spaces for the components */ + std::vector< SmartPtr<const VectorSpace> > comp_spaces_; + }; + + /* inline methods */ + inline + Index CompoundVector::NComps() const + { + return owner_space_->NCompSpaces(); + } + + inline + const Vector* CompoundVector::ConstComp(Index i) const + { + DBG_ASSERT(i < NComps()); + DBG_ASSERT(IsValid(comps_[i]) || IsValid(const_comps_[i])); + if (IsValid(comps_[i])) { + return GetRawPtr(comps_[i]); + } + else if (IsValid(const_comps_[i])) { + return GetRawPtr(const_comps_[i]); + } + + DBG_ASSERT(false && "shouldn't be here"); + return NULL; + } + + inline + Vector* CompoundVector::Comp(Index i) + { + DBG_ASSERT(i < NComps()); + DBG_ASSERT(IsValid(comps_[i])); + return GetRawPtr(comps_[i]); + } + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpDebug.hpp b/thirdparty/linux/include/coin/IpDebug.hpp new file mode 100644 index 0000000..b8aae13 --- /dev/null +++ b/thirdparty/linux/include/coin/IpDebug.hpp @@ -0,0 +1,150 @@ +// Copyright (C) 2004, 2007 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpDebug.hpp 2005 2011-06-06 12:55:16Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPDEBUG_HPP__ +#define __IPDEBUG_HPP__ + +#include "IpoptConfig.h" +#include "IpTypes.hpp" + +#ifdef COIN_IPOPT_CHECKLEVEL +#ifdef HAVE_CASSERT +# include <cassert> +#else +# ifdef HAVE_ASSERT_H +# include <assert.h> +# else +# error "don't have header file for assert" +# endif +#endif +#else +#define COIN_IPOPT_CHECKLEVEL 0 +#endif + +#if COIN_IPOPT_CHECKLEVEL > 0 +# ifdef NDEBUG +# undef NDEBUG +# endif +# define DBG_ASSERT(test) assert(test) +# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \ + ASSERT_EXCEPTION( (__condition), __except_type, __msg); +# define DBG_DO(__cmd) __cmd +#else +# define DBG_ASSERT(test) +# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) +# define DBG_DO(__cmd) +#endif + +#ifndef COIN_IPOPT_VERBOSITY +#define COIN_IPOPT_VERBOSITY 0 +#endif + +#if COIN_IPOPT_VERBOSITY < 1 +# define DBG_START_FUN(__func_name, __verbose_level) +# define DBG_START_METH(__func_name, __verbose_level) +# define DBG_PRINT(__printf_args) +# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) +# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) +# define DBG_EXEC(__verbosity, __cmd) +# define DBG_VERBOSITY() 0 +#else +#include <string> + +namespace Ipopt +{ + // forward definition + class Journalist; + + /** Class that lives throughout the execution of a method or + * function for which debug output is to be generated. The output + * is sent to the unique debug journalist that is set with + * SetJournalist at the beginning of program execution. */ + class DebugJournalistWrapper + { + public: + /** @name Constructors/Destructors. */ + //@{ + DebugJournalistWrapper(std::string func_name, Index verbose_level); + DebugJournalistWrapper(std::string func_name, Index verbose_level, + const void* const method_owner); + ~DebugJournalistWrapper(); + //@} + + /** @name accessor methods */ + //@{ + Index Verbosity() + { + return verbose_level_; + } + const Journalist* Jnlst() + { + return jrnl_; + } + Index IndentationLevel() + { + return indentation_level_; + } + //@} + + /** Printing */ + void DebugPrintf(Index verbosity, const char* pformat, ...); + + /* Method for initialization of the static GLOBAL journalist, + * through with all debug printout is to be written. This needs + * to be set before any debug printout can be done. */ + static void SetJournalist(Journalist* jrnl); + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** default constructor */ + DebugJournalistWrapper(); + + /** copy contructor */ + DebugJournalistWrapper(const DebugJournalistWrapper&); + + /** Overloaded Equals Operator */ + DebugJournalistWrapper& operator=(const DebugJournalistWrapper&); + //@} + + static Index indentation_level_; + std::string func_name_; + Index verbose_level_; + const void* method_owner_; + + static Journalist* jrnl_; + }; +} + +# define DBG_START_FUN(__func_name, __verbose_level) \ + DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \ + +# define DBG_START_METH(__func_name, __verbose_level) \ + DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this); + +# define DBG_PRINT(__args) \ + dbg_jrnl.DebugPrintf __args; + +# define DBG_EXEC(__verbose_level, __cmd) \ + if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \ + (__cmd); \ + } + +# define DBG_VERBOSITY() \ + dbg_jrnl.Verbosity() + +#endif + + +#endif diff --git a/thirdparty/linux/include/coin/IpDenseVector.hpp b/thirdparty/linux/include/coin/IpDenseVector.hpp new file mode 100644 index 0000000..380a06c --- /dev/null +++ b/thirdparty/linux/include/coin/IpDenseVector.hpp @@ -0,0 +1,550 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpDenseVector.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPDENSEVECTOR_HPP__ +#define __IPDENSEVECTOR_HPP__ + +#include "IpUtils.hpp" +#include "IpVector.hpp" +#include <map> + +namespace Ipopt +{ + + /* forward declarations */ + class DenseVectorSpace; + + /** @name Exceptions */ + //@{ + DECLARE_STD_EXCEPTION(METADATA_ERROR); + //@} + + /** Dense Vector Implementation. This is the default Vector class + * in Ipopt. It stores vectors in contiguous Number arrays, unless + * the vector has the same value in all entires. In the latter + * case, we call the vector "homogeneous", and we store only the + * values that is repeated in all elements. If you want to obtain + * the values of vector, use the IsHomogeneous() method to find out + * what status the vector is in, and then use either Values() const + * or Scalar() const methods to get the values. To set the values + * of a homogeneous method, use the Set method. To set the values + * of a non-homogeneous vector, use the SetValues method, or use + * the non-const Values method to get an array that you can + * overwrite. In the latter case, storage is ensured. + */ + class DenseVector : public Vector + { + public: + + /**@name Constructors / Destructors */ + //@{ + /** Default Constructor + */ + DenseVector(const DenseVectorSpace* owner_space); + + /** Destructor + */ + virtual ~DenseVector(); + //@} + + /** @name Additional public methods not in Vector base class. */ + //@{ + /** Create a new DenseVector from same VectorSpace */ + SmartPtr<DenseVector> MakeNewDenseVector() const; + + /** Set elements in the vector to the Number array x. */ + void SetValues(const Number *x); + + /** Obtain pointer to the internal Number array with vector + * elements with the indention to change the vector data (USE + * WITH CARE!). This does not produce a copy, and lifetime is not + * guaranteed!. + */ + inline Number* Values(); + + /** Obtain pointer to the internal Number array with vector + * elements without the intention to change the vector data (USE + * WITH CARE!). This does not produce a copy, and lifetime is not + * guaranteed! IMPORTANT: If this method is currently + * homogeneous (i.e. IsHomogeneous returns true), then you cannot + * call this method. Instead, you need to use the Scalar() + * method. + */ + inline const Number* Values() const; + + /** The same as the const version of Values, but we ensure that we + * always return a valid array, even if IsHomogeneous returns + * true. */ + const Number* ExpandedValues() const; + + /** This is the same as Values, but we add it here so that + * ExpandedValues can also be used for the non-const case. */ + inline Number* ExpandedValues() + { + return Values(); + } + + /** Indicates if the vector is homogeneous (i.e., all entries have + * the value Scalar() */ + bool IsHomogeneous() const + { + return homogeneous_; + } + + /** Scalar value of all entries in a homogeneous vector */ + Number Scalar() const + { + DBG_ASSERT(homogeneous_); + return scalar_; + } + //@} + + /** @name Modifying subranges of the vector. */ + //@{ + /** Copy the data in x into the subrange of this vector starting + * at position Pos in this vector. Position count starts at 0. + */ + void CopyToPos(Index Pos, const Vector& x); + /** Copy a subrange of x, starting at Pos, into the full data of + * this vector. Position count starts at 0. + */ + void CopyFromPos(Index Pos, const Vector& x); + //@} + + protected: + /** @name Overloaded methods from Vector base class */ + //@{ + /** Copy the data of the vector x into this vector (DCOPY). */ + virtual void CopyImpl(const Vector& x); + + /** Scales the vector by scalar alpha (DSCAL) */ + virtual void ScalImpl(Number alpha); + + /** Add the multiple alpha of vector x to this vector (DAXPY) */ + virtual void AxpyImpl(Number alpha, const Vector &x); + + /** Computes inner product of vector x with this (DDOT) */ + virtual Number DotImpl(const Vector &x) const; + + /** Computes the 2-norm of this vector (DNRM2) */ + virtual Number Nrm2Impl() const; + + /** Computes the 1-norm of this vector (DASUM) */ + virtual Number AsumImpl() const; + + /** Computes the max-norm of this vector (based on IDAMAX) */ + virtual Number AmaxImpl() const; + + /** Set each element in the vector to the scalar alpha. */ + virtual void SetImpl(Number value); + + /** Element-wise division \f$y_i \gets y_i/x_i\f$.*/ + virtual void ElementWiseDivideImpl(const Vector& x); + + /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$.*/ + virtual void ElementWiseMultiplyImpl(const Vector& x); + + /** Set entry to max of itself and the corresponding element in x */ + virtual void ElementWiseMaxImpl(const Vector& x); + + /** Set entry to min of itself and the corresponding element in x */ + virtual void ElementWiseMinImpl(const Vector& x); + + /** reciprocates the elements of the vector */ + virtual void ElementWiseReciprocalImpl(); + + /** take abs of the elements of the vector */ + virtual void ElementWiseAbsImpl(); + + /** take square-root of the elements of the vector */ + virtual void ElementWiseSqrtImpl(); + + /** Changes each entry in the vector to its sgn value */ + virtual void ElementWiseSgnImpl(); + + /** Add scalar to every component of the vector.*/ + virtual void AddScalarImpl(Number scalar); + + /** Max value in the vector */ + virtual Number MaxImpl() const; + + /** Min value in the vector */ + virtual Number MinImpl() const; + + /** Computes the sum of the lements of vector */ + virtual Number SumImpl() const; + + /** Computes the sum of the logs of the elements of vector */ + virtual Number SumLogsImpl() const; + + /** @name Implemented specialized functions */ + //@{ + /** Add two vectors (a * v1 + b * v2). Result is stored in this + vector. */ + void AddTwoVectorsImpl(Number a, const Vector& v1, + Number b, const Vector& v2, Number c); + /** Fraction to the boundary parameter. */ + Number FracToBoundImpl(const Vector& delta, Number tau) const; + /** Add the quotient of two vectors, y = a * z/s + c * y. */ + void AddVectorQuotientImpl(Number a, const Vector& z, const Vector& s, + Number c); + //@} + + /** @name Output methods */ + //@{ + /* Print the entire vector with padding */ + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const + { + PrintImplOffset(jnlst, level, category, name, indent, prefix, 1); + } + /* Print the entire vector with padding, and start counting with + an offset. */ + void PrintImplOffset(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix, + Index offset) const; + //@} + friend class ParVector; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + DenseVector(); + + /** Copy Constructor */ + DenseVector(const DenseVector&); + + /** Overloaded Equals Operator */ + void operator=(const DenseVector&); + //@} + + /** Copy of the owner_space ptr as a DenseVectorSpace instead + * of a VectorSpace + */ + const DenseVectorSpace* owner_space_; + + /** Dense Number array of vector values. */ + Number* values_; + + /** Dense Number array pointer that is used for ExpandedValues */ + mutable Number* expanded_values_; + + /** Method of getting the internal values array, making sure that + * memory has been allocated */ + inline + Number* values_allocated(); + + /** Flag for Initialization. This flag is false, if the data has + not yet been initialized. */ + bool initialized_; + + /** Flag indicating whether the vector is currently homogeneous + * (that is, all elements have the same value). This flag is used + * to determine whether the elements of the vector are stored in + * values_ or in scalar_ */ + bool homogeneous_; + + /** Homogeneous value of all elements if the vector is currently + * homogenous */ + Number scalar_; + + /** Auxilliary method for setting explicitly all elements in + * values_ to the current scalar value. */ + void set_values_from_scalar(); + }; + + /** typedefs for the map variables that define meta data for the + * DenseVectorSpace + */ + typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType; + typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType; + typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType; + + /** This vectors space is the vector space for DenseVector. + */ + class DenseVectorSpace : public VectorSpace + { + public: + /** @name Constructors/Destructors. */ + //@{ + /** Constructor, requires dimension of all vector for this + * VectorSpace + */ + DenseVectorSpace(Index dim) + : + VectorSpace(dim) + {} + + /** Destructor */ + ~DenseVectorSpace() + {} + //@} + + /** Method for creating a new vector of this specific type. */ + inline + DenseVector* MakeNewDenseVector() const + { + return new DenseVector(this); + } + + /** Instantiation of the generate MakeNew method for the + * VectorSpace base class. + */ + virtual Vector* MakeNew() const + { + return MakeNewDenseVector(); + } + + /**@name Methods called by DenseVector for memory management. + * This could allow to have sophisticated memory management in the + * VectorSpace. + */ + //@{ + /** Allocate internal storage for the DenseVector */ + inline + Number* AllocateInternalStorage() const; + + /** Deallocate internal storage for the DenseVector */ + inline + void FreeInternalStorage(Number* values) const; + //@} + + /**@name Methods for dealing with meta data on the vector + */ + //@{ + /** Check if string meta exists for tag */ + inline + bool HasStringMetaData(const std::string tag) const; + + /** Check if Integer meta exists for tag */ + inline + bool HasIntegerMetaData(const std::string tag) const; + + /** Check if Numeric meta exists for tag */ + inline + bool HasNumericMetaData(const std::string tag) const; + + /** Get meta data of type std::string by tag */ + inline + const std::vector<std::string>& GetStringMetaData(const std::string& tag) const; + + /** Get meta data of type Index by tag */ + inline + const std::vector<Index>& GetIntegerMetaData(const std::string& tag) const; + + /** Get meta data of type Number by tag */ + inline + const std::vector<Number>& GetNumericMetaData(const std::string& tag) const; + + /** Set meta data of type std::string by tag */ + inline + void SetStringMetaData(std::string tag, std::vector<std::string> meta_data); + + /** Set meta data of type Index by tag */ + inline + void SetIntegerMetaData(std::string tag, std::vector<Index> meta_data); + + /** Set meta data of type Number by tag */ + inline + void SetNumericMetaData(std::string tag, std::vector<Number> meta_data); + + /** Get map of meta data of type Number */ + inline + const StringMetaDataMapType& GetStringMetaData() const; + + /** Get map of meta data of type Number */ + inline + const IntegerMetaDataMapType& GetIntegerMetaData() const; + + /** Get map of meta data of type Number */ + inline + const NumericMetaDataMapType& GetNumericMetaData() const; + //@} + + private: + // variables to store vector meta data + StringMetaDataMapType string_meta_data_; + IntegerMetaDataMapType integer_meta_data_; + NumericMetaDataMapType numeric_meta_data_; + + }; + + // inline functions + inline Number* DenseVector::Values() + { + // Here we assume that every time someone requests this direct raw + // pointer, the data is going to change and the Tag for this + // vector has to be updated. + + if (initialized_ && homogeneous_) { + // If currently the vector is a homogeneous vector, set all elements + // explicitly to this value + set_values_from_scalar(); + } + ObjectChanged(); + initialized_= true; + homogeneous_ = false; + return values_allocated(); + } + + inline const Number* DenseVector::Values() const + { + DBG_ASSERT(initialized_ && (Dim()==0 || values_)); + return values_; + } + + inline Number* DenseVector::values_allocated() + { + if (values_==NULL) { + values_ = owner_space_->AllocateInternalStorage(); + } + return values_; + } + + inline + Number* DenseVectorSpace::AllocateInternalStorage() const + { + if (Dim()>0) { + return new Number[Dim()]; + } + else { + return NULL; + } + } + + inline + void DenseVectorSpace::FreeInternalStorage(Number* values) const + { + delete [] values; + } + + inline + SmartPtr<DenseVector> DenseVector::MakeNewDenseVector() const + { + return owner_space_->MakeNewDenseVector(); + } + + inline + bool DenseVectorSpace::HasStringMetaData(const std::string tag) const + { + StringMetaDataMapType::const_iterator iter; + iter = string_meta_data_.find(tag); + + if (iter != string_meta_data_.end()) { + return true; + } + + return false; + } + + inline + bool DenseVectorSpace::HasIntegerMetaData(const std::string tag) const + { + IntegerMetaDataMapType::const_iterator iter; + iter = integer_meta_data_.find(tag); + + if (iter != integer_meta_data_.end()) { + return true; + } + + return false; + } + + inline + bool DenseVectorSpace::HasNumericMetaData(const std::string tag) const + { + NumericMetaDataMapType::const_iterator iter; + iter = numeric_meta_data_.find(tag); + + if (iter != numeric_meta_data_.end()) { + return true; + } + + return false; + } + + inline + const std::vector<std::string>& DenseVectorSpace::GetStringMetaData(const std::string& tag) const + { + DBG_ASSERT(HasStringMetaData(tag)); + StringMetaDataMapType::const_iterator iter; + iter = string_meta_data_.find(tag); + return iter->second; + } + + inline + const std::vector<Index>& DenseVectorSpace::GetIntegerMetaData(const std::string& tag) const + { + DBG_ASSERT(HasIntegerMetaData(tag)); + IntegerMetaDataMapType::const_iterator iter; + iter = integer_meta_data_.find(tag); + return iter->second; + } + + inline + const std::vector<Number>& DenseVectorSpace::GetNumericMetaData(const std::string& tag) const + { + DBG_ASSERT(HasNumericMetaData(tag)); + NumericMetaDataMapType::const_iterator iter; + iter = numeric_meta_data_.find(tag); + return iter->second; + } + + inline + void DenseVectorSpace::SetStringMetaData(std::string tag, std::vector<std::string> meta_data) + { + string_meta_data_[tag] = meta_data; + } + + inline + void DenseVectorSpace::SetIntegerMetaData(std::string tag, std::vector<Index> meta_data) + { + integer_meta_data_[tag] = meta_data; + } + + inline + void DenseVectorSpace::SetNumericMetaData(std::string tag, std::vector<Number> meta_data) + { + numeric_meta_data_[tag] = meta_data; + } + + inline + const StringMetaDataMapType& DenseVectorSpace::GetStringMetaData() const + { + return string_meta_data_; + } + + inline + const IntegerMetaDataMapType& DenseVectorSpace::GetIntegerMetaData() const + { + return integer_meta_data_; + } + + inline + const NumericMetaDataMapType& DenseVectorSpace::GetNumericMetaData() const + { + return numeric_meta_data_; + } + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpException.hpp b/thirdparty/linux/include/coin/IpException.hpp new file mode 100644 index 0000000..e64226f --- /dev/null +++ b/thirdparty/linux/include/coin/IpException.hpp @@ -0,0 +1,147 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpException.hpp 2023 2011-06-18 18:49:49Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPEXCEPTION_HPP__ +#define __IPEXCEPTION_HPP__ + +#include "IpUtils.hpp" +#include "IpJournalist.hpp" + +/* This file contains a base class for all exceptions + * and a set of macros to help with exceptions + */ + +namespace Ipopt +{ + + /** This is the base class for all exceptions. The easiest way to + * use this class is by means of the following macros: + * + * \verbatim + + DECLARE_STD_EXCEPTION(ExceptionType); + \endverbatim + * + * This macro defines a new class with the name ExceptionType, + * inherited from the base class IpoptException. After this, + * exceptions of this type can be thrown using + * + * \verbatim + + THROW_EXCEPTION(ExceptionType, Message); + \endverbatim + * + * where Message is a std::string with a message that gives an + * indication of what caused the exception. Exceptions can also be + * thrown using the macro + * + * \verbatim + + ASSERT_EXCEPTION(Condition, ExceptionType, Message); + \endverbatim + * + * where Conditions is an expression. If Condition evaluates to + * false, then the exception of the type ExceptionType is thrown + * with Message. + * + * When an exception is caught, the method ReportException can be + * used to write the information about the exception to the + * Journalist, using the level J_ERROR and the category J_MAIN. + * + */ + class IpoptException + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor */ + IpoptException(std::string msg, std::string file_name, Index line_number, std::string type="IpoptException") + : + msg_(msg), + file_name_(file_name), + line_number_(line_number), + type_(type) + {} + + /** Copy Constructor */ + IpoptException(const IpoptException& copy) + : + msg_(copy.msg_), + file_name_(copy.file_name_), + line_number_(copy.line_number_), + type_(copy.type_) + {} + + /** Default destructor */ + virtual ~IpoptException() + {} + //@} + + /** Method to report the exception to a journalist */ + void ReportException(const Journalist& jnlst, + EJournalLevel level = J_ERROR) const + { + jnlst.Printf(level, J_MAIN, + "Exception of type: %s in file \"%s\" at line %d:\n Exception message: %s\n", + type_.c_str(), file_name_.c_str(), line_number_, msg_.c_str()); + } + + const std::string& Message() const + { + return msg_; + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + IpoptException(); + + /** Overloaded Equals Operator */ + void operator=(const IpoptException&); + //@} + + std::string msg_; + std::string file_name_; + Index line_number_; + std::string type_; + }; + +} // namespace Ipopt + +#define THROW_EXCEPTION(__except_type, __msg) \ + throw __except_type( (__msg), (__FILE__), (__LINE__) ); + +#define ASSERT_EXCEPTION(__condition, __except_type, __msg) \ + if (! (__condition) ) { \ + std::string newmsg = #__condition; \ + newmsg += " evaluated false: "; \ + newmsg += __msg; \ + throw __except_type( (newmsg), (__FILE__), (__LINE__) ); \ + } + +#define DECLARE_STD_EXCEPTION(__except_type) \ + class __except_type : public Ipopt::IpoptException \ + { \ + public: \ + __except_type(std::string msg, std::string fname, Ipopt::Index line) \ + : Ipopt::IpoptException(msg,fname,line, #__except_type) {} \ + __except_type(const __except_type& copy) \ + : Ipopt::IpoptException(copy) {} \ + private: \ + __except_type(); \ + void operator=(const __except_type&); \ + } + +#endif diff --git a/thirdparty/linux/include/coin/IpExpansionMatrix.hpp b/thirdparty/linux/include/coin/IpExpansionMatrix.hpp new file mode 100644 index 0000000..cbb9a99 --- /dev/null +++ b/thirdparty/linux/include/coin/IpExpansionMatrix.hpp @@ -0,0 +1,212 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpExpansionMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPEXPANSIONMATRIX_HPP__ +#define __IPEXPANSIONMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpMatrix.hpp" + +namespace Ipopt +{ + + /** forward declarations */ + class ExpansionMatrixSpace; + + /** Class for expansion/projection matrices. These matrices allow + * to lift a vector to a vector with larger dimension, keeping + * some elements of the larger vector zero. This operation is achieved + * by the MultVector operation. The transpose operation then + * filters some elements from a large vector into a smaller vector. + */ + class ExpansionMatrix : public Matrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the owner_space. + */ + ExpansionMatrix(const ExpansionMatrixSpace* owner_space); + + /** Destructor */ + ~ExpansionMatrix(); + //@} + + /** Return the vector of indices marking the expanded position. + * The result is the Index array (of length NSmallVec=NCols()) + * that stores the mapping from the small vector to the large + * vector. For each element i=0,..,NSmallVec in the small + * vector, ExpandedPosIndices()[i] give the corresponding index + * in the large vector. + */ + const Index* ExpandedPosIndices() const; + + /** Return the vector of indices marking the compressed position. + * The result is the Index array (of length NLargeVec=NRows()) + * that stores the mapping from the large vector to the small + * vector. For each element i=0,..,NLargeVec in the large + * vector, CompressedPosIndices()[i] gives the corresponding + * index in the small vector, unless CompressedPosIndices()[i] is + * negative. + */ + const Index* CompressedPosIndices() const; + + protected: + /**@name Overloaded methods from Matrix base class*/ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, + Vector &y) const; + + virtual void TransMultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** X = beta*X + alpha*(Matrix S^{-1} Z). Specialized implementation. + */ + virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z, + Vector& X) const; + + /** X = S^{-1} (r + alpha*Z*M^Td). Specialized implementation. + */ + virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector& S, + const Vector& R, const Vector& Z, + const Vector& D, Vector& X) const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const + { + PrintImplOffset(jnlst, level, category, name, indent, prefix, 1, 1); + } + //@} + + void PrintImplOffset(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix, + Index row_offset, + Index col_offset) const; + + friend class ParExpansionMatrix; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + ExpansionMatrix(); + + /** Copy Constructor */ + ExpansionMatrix(const ExpansionMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const ExpansionMatrix&); + //@} + + const ExpansionMatrixSpace* owner_space_; + + }; + + /** This is the matrix space for ExpansionMatrix. + */ + class ExpansionMatrixSpace : public MatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the list of elements of the large vector + * (of size NLargeVec) to be filtered into the small vector (of + * size NSmallVec). For each i=0..NSmallVec-1 the i-th element + * of the small vector will be put into the ExpPos[i] position of + * the large vector. The position counting in the vector is + * assumed to start at 0 (C-like array notation). + */ + ExpansionMatrixSpace(Index NLargeVec, + Index NSmallVec, + const Index *ExpPos, + const int offset = 0); + + /** Destructor */ + ~ExpansionMatrixSpace() + { + delete [] compressed_pos_; + delete [] expanded_pos_; + } + //@} + + /** Method for creating a new matrix of this specific type. */ + ExpansionMatrix* MakeNewExpansionMatrix() const + { + return new ExpansionMatrix(this); + } + + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewExpansionMatrix(); + } + + /** Accessor Method to obtain the Index array (of length + * NSmallVec=NCols()) that stores the mapping from the small + * vector to the large vector. For each element i=0,..,NSmallVec + * in the small vector, ExpandedPosIndices()[i] give the + * corresponding index in the large vector. + */ + const Index* ExpandedPosIndices() const + { + return expanded_pos_; + } + + /** Accessor Method to obtain the Index array (of length + * NLargeVec=NRows()) that stores the mapping from the large + * vector to the small vector. For each element i=0,..,NLargeVec + * in the large vector, CompressedPosIndices()[i] gives the + * corresponding index in the small vector, unless + * CompressedPosIndices()[i] is negative. + */ + const Index* CompressedPosIndices() const + { + return compressed_pos_; + } + + private: + Index *expanded_pos_; + Index *compressed_pos_; + }; + + /* inline methods */ + inline + const Index* ExpansionMatrix::ExpandedPosIndices() const + { + return owner_space_->ExpandedPosIndices(); + } + + inline + const Index* ExpansionMatrix::CompressedPosIndices() const + { + return owner_space_->CompressedPosIndices(); + } + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpIpoptApplication.hpp b/thirdparty/linux/include/coin/IpIpoptApplication.hpp new file mode 100644 index 0000000..5f59292 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIpoptApplication.hpp @@ -0,0 +1,275 @@ +// Copyright (C) 2004, 2010 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIpoptApplication.hpp 2398 2013-10-19 18:08:59Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPIPOPTAPPLICATION_HPP__ +#define __IPIPOPTAPPLICATION_HPP__ + +#ifndef IPOPT_EXPORT +#ifdef _MSC_VER +#ifdef IPOPT_DLL +#define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl +#else +#define IPOPT_EXPORT(type) type __cdecl +#endif +#else +#define IPOPT_EXPORT(type) type +#endif +#endif + +#include <iostream> + +#include "IpJournalist.hpp" +#include "IpTNLP.hpp" +#include "IpNLP.hpp" +/* Return codes for the Optimize call for an application */ +#include "IpReturnCodes.hpp" + +namespace Ipopt +{ + DECLARE_STD_EXCEPTION(IPOPT_APPLICATION_ERROR); + + /* forward declarations */ + class IpoptAlgorithm; + class IpoptNLP; + class IpoptData; + class IpoptCalculatedQuantities; + class AlgorithmBuilder; + class RegisteredOptions; + class OptionsList; + class SolveStatistics; + + /** This is the main application class for making calls to Ipopt. */ + class IpoptApplication : public ReferencedObject + { + public: + IpoptApplication(bool create_console_out = true, + bool create_empty = false); + + /** Another constructor that assumes that the code in the + * (default) constructor has already been executed */ + IpoptApplication(SmartPtr<RegisteredOptions> reg_options, + SmartPtr<OptionsList> options, + SmartPtr<Journalist> jnlst); + + virtual ~IpoptApplication(); + + /** Method for creating a new IpoptApplication that uses the same + * journalist and registered options, and a copy of the options + list. */ + virtual SmartPtr<IpoptApplication> clone(); + + /** Initialization method. This method reads options from the + * input stream and initializes the journalists. It returns + * something other than Solve_Succeeded if there was a + * problem in the initialization (such as an invalid option). + * You should call one of the initialization methods at some + * point before the first optimize call. + */ + virtual ApplicationReturnStatus Initialize(std::istream& is); + /** Initialization method. This method reads options from the + * params file and initializes the journalists. It returns + * something other than Solve_Succeeded if there was a + * problem in the initialization (such as an invalid option). + * You should call one of the initialization methods at some + * point before the first optimize call. + * Note: You can skip the processing of a params file by + * setting params_file to "". + */ + virtual ApplicationReturnStatus Initialize(std::string params_file); + /** Initialize method. This method reads the options file specified + * by the option_file_name option and initializes the journalists. + * You should call this method at some point before the first optimize + * call. + * It returns something other than Solve_Succeeded if there was a + * problem in the initialization (such as an invalid option). + */ + virtual ApplicationReturnStatus Initialize(); + + /**@name Solve methods */ + //@{ + /** Solve a problem that inherits from TNLP */ + virtual ApplicationReturnStatus OptimizeTNLP(const SmartPtr<TNLP>& tnlp); + + /** Solve a problem that inherits from NLP */ + virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp); + + /** Solve a problem that inherits from NLP */ + virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp, SmartPtr<AlgorithmBuilder>& alg_builder); + + /** Solve a problem (that inherits from TNLP) for a repeated time. + * The OptimizeTNLP method must have been called before. The + * TNLP must be the same object, and the structure (number of + * variables and constraints and position of nonzeros in Jacobian + * and Hessian must be the same). */ + virtual ApplicationReturnStatus ReOptimizeTNLP(const SmartPtr<TNLP>& tnlp); + + /** Solve a problem (that inherits from NLP) for a repeated time. + * The OptimizeNLP method must have been called before. The + * NLP must be the same object, and the structure (number of + * variables and constraints and position of nonzeros in Jacobian + * and Hessian must be the same). */ + virtual ApplicationReturnStatus ReOptimizeNLP(const SmartPtr<NLP>& nlp); + //@} + + /** Method for opening an output file with given print_level. + * Returns false if there was a problem. */ + virtual bool OpenOutputFile(std::string file_name, EJournalLevel print_level); + + /**@name Accessor methods */ + //@{ + /** Get the Journalist for printing output */ + virtual SmartPtr<Journalist> Jnlst() + { + return jnlst_; + } + + /** Get a pointer to RegisteredOptions object to + * add new options */ + virtual SmartPtr<RegisteredOptions> RegOptions() + { + return reg_options_; + } + + /** Get the options list for setting options */ + virtual SmartPtr<OptionsList> Options() + { + return options_; + } + + /** Get the options list for setting options (const version) */ + virtual SmartPtr<const OptionsList> Options() const + { + return ConstPtr(options_); + } + + /** Get the object with the statistics about the most recent + * optimization run. */ + virtual SmartPtr<SolveStatistics> Statistics(); + + /** Get the IpoptNLP Object */ + virtual SmartPtr<IpoptNLP> IpoptNLPObject(); + + /** Get the IpoptData Object */ + SmartPtr<IpoptData> IpoptDataObject(); + + /** Get the IpoptCQ Object */ + virtual SmartPtr<IpoptCalculatedQuantities> IpoptCQObject(); + + /** Get the Algorithm Object */ + SmartPtr<IpoptAlgorithm> AlgorithmObject(); + //@} + + /** Method for printing Ipopt copyright message now instead of + * just before the optimization. If you want to have the copy + * right message printed earlier than by default, call this + * method at the convenient time. */ + void PrintCopyrightMessage(); + + /** Method to set whether non-ipopt non-bad_alloc exceptions + * are rethrown by Ipopt. + * By default, non-Ipopt and non-std::bad_alloc exceptions are + * caught by Ipopts initialization and optimization methods + * and the status NonIpopt_Exception_Thrown is returned. + * This function allows to enable rethrowing of such exceptions. + */ + void RethrowNonIpoptException(bool dorethrow) + { + rethrow_nonipoptexception_ = dorethrow; + } + + /** @name Methods for IpoptTypeInfo */ + //@{ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + /** Method to registering all Ipopt options. */ + static void + RegisterAllIpoptOptions(const SmartPtr<RegisteredOptions>& roptions); + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + // IpoptApplication(); + + /** Copy Constructor */ + IpoptApplication(const IpoptApplication&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptApplication&); + //@} + + /** Method for the actual optimize call of the Ipopt algorithm. + * This is used both for Optimize and ReOptimize */ + ApplicationReturnStatus call_optimize(); + + /**@name Variables that customize the application behavior */ + //@{ + /** Decide whether or not the ipopt.opt file should be read */ + bool read_params_dat_; + + /** Decide whether non-ipopt non-bad_alloc exceptions should be rethrown */ + bool rethrow_nonipoptexception_; + //@} + + /** Journalist for reporting output */ + SmartPtr<Journalist> jnlst_; + + /** RegisteredOptions */ + SmartPtr<RegisteredOptions> reg_options_; + + /** OptionsList used for the application */ + SmartPtr<OptionsList> options_; + + /** Object for storing statistics about the most recent + * optimization run. */ + SmartPtr<SolveStatistics> statistics_; + + /** Object with the algorithm sceleton. + */ + SmartPtr<IpoptAlgorithm> alg_; + + /** IpoptNLP Object for the NLP. We keep this around for a + * ReOptimize warm start. */ + SmartPtr<IpoptNLP> ip_nlp_; + + /** IpoptData Object for the NLP. We keep this around for a + * ReOptimize warm start. + */ + SmartPtr<IpoptData> ip_data_; + + /** IpoptCalculatedQuantities Object for the NLP. We keep this + * around for a ReOptimize warm start. + */ + SmartPtr<IpoptCalculatedQuantities> ip_cq_; + + /** Pointer to the TNLPAdapter used to convert the TNLP to an NLP. + * We keep this around for the ReOptimizerTNLP call. */ + SmartPtr<NLP> nlp_adapter_; + + /** @name Algorithmic parameters */ + //@{ + /** Flag indicating if we are to use the inexact linear solver option */ + bool inexact_algorithm_; + /** Flag indicating if all bounds should be replaced by inequality + * constraints. This is necessary for the inexact algorithm. */ + bool replace_bounds_; + //@} + }; + +} // namespace Ipopt + +extern "C" IPOPT_EXPORT(class Ipopt::IpoptApplication *) IpoptApplicationFactory(); + +#endif diff --git a/thirdparty/linux/include/coin/IpIpoptCalculatedQuantities.hpp b/thirdparty/linux/include/coin/IpIpoptCalculatedQuantities.hpp new file mode 100644 index 0000000..3b60b16 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIpoptCalculatedQuantities.hpp @@ -0,0 +1,751 @@ +// Copyright (C) 2004, 2011 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIpoptCalculatedQuantities.hpp 2020 2011-06-16 20:46:16Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPIPOPTCALCULATEDQUANTITIES_HPP__ +#define __IPIPOPTCALCULATEDQUANTITIES_HPP__ + +#include "IpSmartPtr.hpp" +#include "IpCachedResults.hpp" + +#include <string> + +namespace Ipopt +{ + class IpoptNLP; + class IpoptData; + class Vector; + class Matrix; + class SymMatrix; + class Journalist; + class OptionsList; + class RegisteredOptions; + + /** Norm types */ + enum ENormType { + NORM_1=0, + NORM_2, + NORM_MAX + }; + + /** Base class for additional calculated quantities that is special + * to a particular type of algorithm, such as the CG penalty + * function, or using iterative linear solvers. The regular + * IpoptCalculatedQuantities object should be given a derivation of + * this base class when it is created. */ + class IpoptAdditionalCq : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + IpoptAdditionalCq() + {} + + /** Default destructor */ + virtual ~IpoptAdditionalCq() + {} + //@} + + /** This method is called to initialize the global algorithmic + * parameters. The parameters are taken from the OptionsList + * object. */ + virtual bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix) = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + IpoptAdditionalCq(const IpoptAdditionalCq&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptAdditionalCq&); + //@} + }; + + /** Class for all IPOPT specific calculated quantities. + * + */ + class IpoptCalculatedQuantities : public ReferencedObject + { + public: + + /**@name Constructors/Destructors */ + //@{ + /** Constructor */ + IpoptCalculatedQuantities(const SmartPtr<IpoptNLP>& ip_nlp, + const SmartPtr<IpoptData>& ip_data); + /** Default destructor */ + virtual ~IpoptCalculatedQuantities(); + //@} + + /** Method for setting pointer for additional calculated + * quantities. This needs to be called before Initialized. */ + void SetAddCq(SmartPtr<IpoptAdditionalCq> add_cq) + { + DBG_ASSERT(!HaveAddCq()); + add_cq_ = add_cq; + } + + /** Method detecting if additional object for calculated + * quantities has already been set */ + bool HaveAddCq() + { + return IsValid(add_cq_); + } + + /** This method must be called to initialize the global + * algorithmic parameters. The parameters are taken from the + * OptionsList object. */ + bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** @name Slacks */ + //@{ + /** Slacks for x_L (at current iterate) */ + SmartPtr<const Vector> curr_slack_x_L(); + /** Slacks for x_U (at current iterate) */ + SmartPtr<const Vector> curr_slack_x_U(); + /** Slacks for s_L (at current iterate) */ + SmartPtr<const Vector> curr_slack_s_L(); + /** Slacks for s_U (at current iterate) */ + SmartPtr<const Vector> curr_slack_s_U(); + /** Slacks for x_L (at trial point) */ + SmartPtr<const Vector> trial_slack_x_L(); + /** Slacks for x_U (at trial point) */ + SmartPtr<const Vector> trial_slack_x_U(); + /** Slacks for s_L (at trial point) */ + SmartPtr<const Vector> trial_slack_s_L(); + /** Slacks for s_U (at trial point) */ + SmartPtr<const Vector> trial_slack_s_U(); + /** Indicating whether or not we "fudged" the slacks */ + Index AdjustedTrialSlacks(); + /** Reset the flags for "fudged" slacks */ + void ResetAdjustedTrialSlacks(); + //@} + + /** @name Objective function */ + //@{ + /** Value of objective function (at current point) */ + virtual Number curr_f(); + /** Unscaled value of the objective function (at the current point) */ + virtual Number unscaled_curr_f(); + /** Value of objective function (at trial point) */ + virtual Number trial_f(); + /** Unscaled value of the objective function (at the trial point) */ + virtual Number unscaled_trial_f(); + /** Gradient of objective function (at current point) */ + SmartPtr<const Vector> curr_grad_f(); + /** Gradient of objective function (at trial point) */ + SmartPtr<const Vector> trial_grad_f(); + //@} + + /** @name Barrier Objective Function */ + //@{ + /** Barrier Objective Function Value + * (at current iterate with current mu) + */ + virtual Number curr_barrier_obj(); + /** Barrier Objective Function Value + * (at trial point with current mu) + */ + virtual Number trial_barrier_obj(); + + /** Gradient of barrier objective function with respect to x + * (at current point with current mu) */ + SmartPtr<const Vector> curr_grad_barrier_obj_x(); + /** Gradient of barrier objective function with respect to s + * (at current point with current mu) */ + SmartPtr<const Vector> curr_grad_barrier_obj_s(); + + /** Gradient of the damping term with respect to x (times + * kappa_d) */ + SmartPtr<const Vector> grad_kappa_times_damping_x(); + /** Gradient of the damping term with respect to s (times + * kappa_d) */ + SmartPtr<const Vector> grad_kappa_times_damping_s(); + //@} + + /** @name Constraints */ + //@{ + /** c(x) (at current point) */ + SmartPtr<const Vector> curr_c(); + /** unscaled c(x) (at current point) */ + SmartPtr<const Vector> unscaled_curr_c(); + /** c(x) (at trial point) */ + SmartPtr<const Vector> trial_c(); + /** unscaled c(x) (at trial point) */ + SmartPtr<const Vector> unscaled_trial_c(); + /** d(x) (at current point) */ + SmartPtr<const Vector> curr_d(); + /** unscaled d(x) (at current point) */ + SmartPtr<const Vector> unscaled_curr_d(); + /** d(x) (at trial point) */ + SmartPtr<const Vector> trial_d(); + /** d(x) - s (at current point) */ + SmartPtr<const Vector> curr_d_minus_s(); + /** d(x) - s (at trial point) */ + SmartPtr<const Vector> trial_d_minus_s(); + /** Jacobian of c (at current point) */ + SmartPtr<const Matrix> curr_jac_c(); + /** Jacobian of c (at trial point) */ + SmartPtr<const Matrix> trial_jac_c(); + /** Jacobian of d (at current point) */ + SmartPtr<const Matrix> curr_jac_d(); + /** Jacobian of d (at trial point) */ + SmartPtr<const Matrix> trial_jac_d(); + /** Product of Jacobian (evaluated at current point) of C + * transpose with general vector */ + SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec); + /** Product of Jacobian (evaluated at trial point) of C + * transpose with general vector */ + SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec); + /** Product of Jacobian (evaluated at current point) of D + * transpose with general vector */ + SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec); + /** Product of Jacobian (evaluated at trial point) of D + * transpose with general vector */ + SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec); + /** Product of Jacobian (evaluated at current point) of C + * transpose with current y_c */ + SmartPtr<const Vector> curr_jac_cT_times_curr_y_c(); + /** Product of Jacobian (evaluated at trial point) of C + * transpose with trial y_c */ + SmartPtr<const Vector> trial_jac_cT_times_trial_y_c(); + /** Product of Jacobian (evaluated at current point) of D + * transpose with current y_d */ + SmartPtr<const Vector> curr_jac_dT_times_curr_y_d(); + /** Product of Jacobian (evaluated at trial point) of D + * transpose with trial y_d */ + SmartPtr<const Vector> trial_jac_dT_times_trial_y_d(); + /** Product of Jacobian (evaluated at current point) of C + * with general vector */ + SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec); + /** Product of Jacobian (evaluated at current point) of D + * with general vector */ + SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec); + /** Constraint Violation (at current iterate). This value should + * be used in the line search, and not curr_primal_infeasibility(). + * What type of norm is used depends on constr_viol_normtype */ + virtual Number curr_constraint_violation(); + /** Constraint Violation (at trial point). This value should + * be used in the line search, and not curr_primal_infeasibility(). + * What type of norm is used depends on constr_viol_normtype */ + virtual Number trial_constraint_violation(); + /** Real constraint violation in a given norm (at current + * iterate). This considers the inequality constraints without + * slacks. */ + virtual Number curr_nlp_constraint_violation(ENormType NormType); + /** Unscaled real constraint violation in a given norm (at current + * iterate). This considers the inequality constraints without + * slacks. */ + virtual Number unscaled_curr_nlp_constraint_violation(ENormType NormType); + /** Unscaled real constraint violation in a given norm (at trial + * iterate). This considers the inequality constraints without + * slacks. */ + virtual Number unscaled_trial_nlp_constraint_violation(ENormType NormType); + //@} + + /** @name Hessian matrices */ + //@{ + /** exact Hessian at current iterate (uncached) */ + SmartPtr<const SymMatrix> curr_exact_hessian(); + //@} + + /** @name primal-dual error and its components */ + //@{ + /** x-part of gradient of Lagrangian function (at current point) */ + SmartPtr<const Vector> curr_grad_lag_x(); + /** x-part of gradient of Lagrangian function (at trial point) */ + SmartPtr<const Vector> trial_grad_lag_x(); + /** s-part of gradient of Lagrangian function (at current point) */ + SmartPtr<const Vector> curr_grad_lag_s(); + /** s-part of gradient of Lagrangian function (at trial point) */ + SmartPtr<const Vector> trial_grad_lag_s(); + /** x-part of gradient of Lagrangian function (at current point) + including linear damping term */ + SmartPtr<const Vector> curr_grad_lag_with_damping_x(); + /** s-part of gradient of Lagrangian function (at current point) + including linear damping term */ + SmartPtr<const Vector> curr_grad_lag_with_damping_s(); + /** Complementarity for x_L (for current iterate) */ + SmartPtr<const Vector> curr_compl_x_L(); + /** Complementarity for x_U (for current iterate) */ + SmartPtr<const Vector> curr_compl_x_U(); + /** Complementarity for s_L (for current iterate) */ + SmartPtr<const Vector> curr_compl_s_L(); + /** Complementarity for s_U (for current iterate) */ + SmartPtr<const Vector> curr_compl_s_U(); + /** Complementarity for x_L (for trial iterate) */ + SmartPtr<const Vector> trial_compl_x_L(); + /** Complementarity for x_U (for trial iterate) */ + SmartPtr<const Vector> trial_compl_x_U(); + /** Complementarity for s_L (for trial iterate) */ + SmartPtr<const Vector> trial_compl_s_L(); + /** Complementarity for s_U (for trial iterate) */ + SmartPtr<const Vector> trial_compl_s_U(); + /** Relaxed complementarity for x_L (for current iterate and current mu) */ + SmartPtr<const Vector> curr_relaxed_compl_x_L(); + /** Relaxed complementarity for x_U (for current iterate and current mu) */ + SmartPtr<const Vector> curr_relaxed_compl_x_U(); + /** Relaxed complementarity for s_L (for current iterate and current mu) */ + SmartPtr<const Vector> curr_relaxed_compl_s_L(); + /** Relaxed complementarity for s_U (for current iterate and current mu) */ + SmartPtr<const Vector> curr_relaxed_compl_s_U(); + + /** Primal infeasibility in a given norm (at current iterate). */ + virtual Number curr_primal_infeasibility(ENormType NormType); + /** Primal infeasibility in a given norm (at trial point) */ + virtual Number trial_primal_infeasibility(ENormType NormType); + + /** Dual infeasibility in a given norm (at current iterate) */ + virtual Number curr_dual_infeasibility(ENormType NormType); + /** Dual infeasibility in a given norm (at trial iterate) */ + virtual Number trial_dual_infeasibility(ENormType NormType); + /** Unscaled dual infeasibility in a given norm (at current iterate) */ + virtual Number unscaled_curr_dual_infeasibility(ENormType NormType); + + /** Complementarity (for all complementarity conditions together) + * in a given norm (at current iterate) */ + virtual Number curr_complementarity(Number mu, ENormType NormType); + /** Complementarity (for all complementarity conditions together) + * in a given norm (at trial iterate) */ + virtual Number trial_complementarity(Number mu, ENormType NormType); + /** Complementarity (for all complementarity conditions together) + * in a given norm (at current iterate) without NLP scaling. */ + virtual Number unscaled_curr_complementarity(Number mu, ENormType NormType); + + /** Centrality measure (in spirit of the -infinity-neighborhood. */ + Number CalcCentralityMeasure(const Vector& compl_x_L, + const Vector& compl_x_U, + const Vector& compl_s_L, + const Vector& compl_s_U); + /** Centrality measure at current point */ + virtual Number curr_centrality_measure(); + + /** Total optimality error for the original NLP at the current + * iterate, using scaling factors based on multipliers. Note + * that here the constraint violation is measured without slacks + * (nlp_constraint_violation) */ + virtual Number curr_nlp_error(); + /** Total optimality error for the original NLP at the current + * iterate, but using no scaling based on multipliers, and no + * scaling for the NLP. Note that here the constraint violation + * is measured without slacks (nlp_constraint_violation) */ + virtual Number unscaled_curr_nlp_error(); + + /** Total optimality error for the barrier problem at the + * current iterate, using scaling factors based on multipliers. */ + virtual Number curr_barrier_error(); + + /** Norm of the primal-dual system for a given mu (at current + * iterate). The norm is defined as the sum of the 1-norms of + * dual infeasibiliy, primal infeasibility, and complementarity, + * all divided by the number of elements of the vectors of which + * the norm is taken. + */ + virtual Number curr_primal_dual_system_error(Number mu); + /** Norm of the primal-dual system for a given mu (at trial + * iterate). The norm is defined as the sum of the 1-norms of + * dual infeasibiliy, primal infeasibility, and complementarity, + * all divided by the number of elements of the vectors of which + * the norm is taken. + */ + virtual Number trial_primal_dual_system_error(Number mu); + //@} + + /** @name Computing fraction-to-the-boundary step sizes */ + //@{ + /** Fraction to the boundary from (current) primal variables x and s + * for a given step */ + Number primal_frac_to_the_bound(Number tau, + const Vector& delta_x, + const Vector& delta_s); + /** Fraction to the boundary from (current) primal variables x and s + * for internal (current) step */ + Number curr_primal_frac_to_the_bound(Number tau); + /** Fraction to the boundary from (current) dual variables z and v + * for a given step */ + Number dual_frac_to_the_bound(Number tau, + const Vector& delta_z_L, + const Vector& delta_z_U, + const Vector& delta_v_L, + const Vector& delta_v_U); + /** Fraction to the boundary from (current) dual variables z and v + * for a given step, without caching */ + Number uncached_dual_frac_to_the_bound(Number tau, + const Vector& delta_z_L, + const Vector& delta_z_U, + const Vector& delta_v_L, + const Vector& delta_v_U); + /** Fraction to the boundary from (current) dual variables z and v + * for internal (current) step */ + Number curr_dual_frac_to_the_bound(Number tau); + /** Fraction to the boundary from (current) slacks for a given + * step in the slacks. Usually, one will use the + * primal_frac_to_the_bound method to compute the primal fraction + * to the boundary step size, but if it is cheaper to provide the + * steps in the slacks directly (e.g. when the primal step sizes + * are only temporary), the this method is more efficient. This + * method does not cache computations. */ + Number uncached_slack_frac_to_the_bound(Number tau, + const Vector& delta_x_L, + const Vector& delta_x_U, + const Vector& delta_s_L, + const Vector& delta_s_U); + //@} + + /** @name Sigma matrices */ + //@{ + SmartPtr<const Vector> curr_sigma_x(); + SmartPtr<const Vector> curr_sigma_s(); + //@} + + /** average of current values of the complementarities */ + Number curr_avrg_compl(); + /** average of trial values of the complementarities */ + Number trial_avrg_compl(); + + /** inner_product of current barrier obj. fn. gradient with + * current search direction */ + Number curr_gradBarrTDelta(); + + /** Compute the norm of a specific type of a set of vectors (uncached) */ + Number + CalcNormOfType(ENormType NormType, + std::vector<SmartPtr<const Vector> > vecs); + + /** Compute the norm of a specific type of two vectors (uncached) */ + Number + CalcNormOfType(ENormType NormType, + const Vector& vec1, const Vector& vec2); + + /** Norm type used for calculating constraint violation */ + ENormType constr_viol_normtype() const + { + return constr_viol_normtype_; + } + + /** Method returning true if this is a square problem */ + bool IsSquareProblem() const; + + /** Method returning the IpoptNLP object. This should only be + * used with care! */ + SmartPtr<IpoptNLP>& GetIpoptNLP() + { + return ip_nlp_; + } + + IpoptAdditionalCq& AdditionalCq() + { + DBG_ASSERT(IsValid(add_cq_)); + return *add_cq_; + } + + /** Methods for IpoptType */ + //@{ + /** Called by IpoptType to register the options */ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + IpoptCalculatedQuantities(); + + /** Copy Constructor */ + IpoptCalculatedQuantities(const IpoptCalculatedQuantities&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptCalculatedQuantities&); + //@} + + /** @name Pointers for easy access to data and NLP information */ + //@{ + /** Ipopt NLP object */ + SmartPtr<IpoptNLP> ip_nlp_; + /** Ipopt Data object */ + SmartPtr<IpoptData> ip_data_; + /** Chen-Goldfarb specific calculated quantities */ + SmartPtr<IpoptAdditionalCq> add_cq_; + //@} + + /** @name Algorithmic Parameters that can be set throught the + * options list. Those parameters are initialize by calling the + * Initialize method.*/ + //@{ + /** Parameter in formula for computing overall primal-dual + * optimality error */ + Number s_max_; + /** Weighting factor for the linear damping term added to the + * barrier objective funciton. */ + Number kappa_d_; + /** fractional movement allowed in bounds */ + Number slack_move_; + /** Norm type to be used when calculating the constraint violation */ + ENormType constr_viol_normtype_; + /** Flag indicating whether the TNLP with identical structure has + * already been solved before. */ + bool warm_start_same_structure_; + /** Desired value of the barrier parameter */ + Number mu_target_; + //@} + + /** @name Caches for slacks */ + //@{ + CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_; + CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_; + CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_; + CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_; + CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_; + CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_; + CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_; + CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_; + Index num_adjusted_slack_x_L_; + Index num_adjusted_slack_x_U_; + Index num_adjusted_slack_s_L_; + Index num_adjusted_slack_s_U_; + //@} + + /** @name Cached for objective function stuff */ + //@{ + CachedResults<Number> curr_f_cache_; + CachedResults<Number> trial_f_cache_; + CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_; + CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_; + //@} + + /** @name Caches for barrier function stuff */ + //@{ + CachedResults<Number> curr_barrier_obj_cache_; + CachedResults<Number> trial_barrier_obj_cache_; + CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_; + CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_; + CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_; + CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_; + //@} + + /** @name Caches for constraint stuff */ + //@{ + CachedResults< SmartPtr<const Vector> > curr_c_cache_; + CachedResults< SmartPtr<const Vector> > trial_c_cache_; + CachedResults< SmartPtr<const Vector> > curr_d_cache_; + CachedResults< SmartPtr<const Vector> > trial_d_cache_; + CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_; + CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_; + CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_; + CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_; + CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_; + CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_; + CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_; + CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_; + CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_; + CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_; + CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_; + CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_; + CachedResults<Number> curr_constraint_violation_cache_; + CachedResults<Number> trial_constraint_violation_cache_; + CachedResults<Number> curr_nlp_constraint_violation_cache_; + CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_; + CachedResults<Number> unscaled_trial_nlp_constraint_violation_cache_; + //@} + + /** Cache for the exact Hessian */ + CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_; + + /** @name Components of primal-dual error */ + //@{ + CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_; + CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_; + CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_; + CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_; + CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_; + CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_; + CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_; + CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_; + CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_; + CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_; + CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_; + CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_; + CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_; + CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_; + CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_; + CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_; + CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_; + CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_; + CachedResults<Number> curr_primal_infeasibility_cache_; + CachedResults<Number> trial_primal_infeasibility_cache_; + CachedResults<Number> curr_dual_infeasibility_cache_; + CachedResults<Number> trial_dual_infeasibility_cache_; + CachedResults<Number> unscaled_curr_dual_infeasibility_cache_; + CachedResults<Number> curr_complementarity_cache_; + CachedResults<Number> trial_complementarity_cache_; + CachedResults<Number> curr_centrality_measure_cache_; + CachedResults<Number> curr_nlp_error_cache_; + CachedResults<Number> unscaled_curr_nlp_error_cache_; + CachedResults<Number> curr_barrier_error_cache_; + CachedResults<Number> curr_primal_dual_system_error_cache_; + CachedResults<Number> trial_primal_dual_system_error_cache_; + //@} + + /** @name Caches for fraction to the boundary step sizes */ + //@{ + CachedResults<Number> primal_frac_to_the_bound_cache_; + CachedResults<Number> dual_frac_to_the_bound_cache_; + //@} + + /** @name Caches for sigma matrices */ + //@{ + CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_; + CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_; + //@} + + /** Cache for average of current complementarity */ + CachedResults<Number> curr_avrg_compl_cache_; + /** Cache for average of trial complementarity */ + CachedResults<Number> trial_avrg_compl_cache_; + + /** Cache for grad barrier obj. fn inner product with step */ + CachedResults<Number> curr_gradBarrTDelta_cache_; + + /** @name Indicator vectors required for the linear damping terms + * to handle unbounded solution sets. */ + //@{ + /** Indicator vector for selecting the elements in x that have + * only lower bounds. */ + SmartPtr<Vector> dampind_x_L_; + /** Indicator vector for selecting the elements in x that have + * only upper bounds. */ + SmartPtr<Vector> dampind_x_U_; + /** Indicator vector for selecting the elements in s that have + * only lower bounds. */ + SmartPtr<Vector> dampind_s_L_; + /** Indicator vector for selecting the elements in s that have + * only upper bounds. */ + SmartPtr<Vector> dampind_s_U_; + //@} + + /** @name Temporary vectors for intermediate calcuations. We keep + * these around to avoid unnecessarily many new allocations of + * Vectors. */ + //@{ + SmartPtr<Vector> tmp_x_; + SmartPtr<Vector> tmp_s_; + SmartPtr<Vector> tmp_c_; + SmartPtr<Vector> tmp_d_; + SmartPtr<Vector> tmp_x_L_; + SmartPtr<Vector> tmp_x_U_; + SmartPtr<Vector> tmp_s_L_; + SmartPtr<Vector> tmp_s_U_; + + /** Accessor methods for the temporary vectors */ + Vector& Tmp_x(); + Vector& Tmp_s(); + Vector& Tmp_c(); + Vector& Tmp_d(); + Vector& Tmp_x_L(); + Vector& Tmp_x_U(); + Vector& Tmp_s_L(); + Vector& Tmp_s_U(); + //@} + + /** flag indicating if Initialize method has been called (for + * debugging) */ + bool initialize_called_; + + /** @name Auxiliary functions */ + //@{ + /** Compute new vector containing the slack to a lower bound + * (uncached) + */ + SmartPtr<Vector> CalcSlack_L(const Matrix& P, + const Vector& x, + const Vector& x_bound); + /** Compute new vector containing the slack to a upper bound + * (uncached) + */ + SmartPtr<Vector> CalcSlack_U(const Matrix& P, + const Vector& x, + const Vector& x_bound); + /** Compute barrier term at given point + * (uncached) + */ + Number CalcBarrierTerm(Number mu, + const Vector& slack_x_L, + const Vector& slack_x_U, + const Vector& slack_s_L, + const Vector& slack_s_U); + + /** Compute complementarity for slack / multiplier pair */ + SmartPtr<const Vector> CalcCompl(const Vector& slack, + const Vector& mult); + + /** Compute fraction to the boundary parameter for lower and upper bounds */ + Number CalcFracToBound(const Vector& slack_L, + Vector& tmp_L, + const Matrix& P_L, + const Vector& slack_U, + Vector& tmp_U, + const Matrix& P_U, + const Vector& delta, + Number tau); + + /** Compute the scaling factors for the optimality error. */ + void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d, + const Vector& z_L, const Vector& z_U, + const Vector& v_L, const Vector& v_U, + Number s_max, + Number& s_d, Number& s_c); + + /** Check if slacks are becoming too small. If slacks are + * becoming too small, they are change. The return value is the + * number of corrected slacks. */ + Index CalculateSafeSlack(SmartPtr<Vector>& slack, + const SmartPtr<const Vector>& bound, + const SmartPtr<const Vector>& curr_point, + const SmartPtr<const Vector>& multiplier); + + /** Computes the indicator vectors that can be used to filter out + * those entries in the slack_... variables, that correspond to + * variables with only lower and upper bounds. This is required + * for the linear damping term in the barrier objective function + * to handle unbounded solution sets. */ + void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L, + SmartPtr<const Vector>& dampind_x_U, + SmartPtr<const Vector>& dampind_s_L, + SmartPtr<const Vector>& dampind_s_U); + + /** Check if we are in the restoration phase. Returns true, if the + * ip_nlp is of the type RestoIpoptNLP. ToDo: We probably want to + * handle this more elegant and don't have an explicit dependency + * here. Now I added this because otherwise the caching doesn't + * work properly since the restoration phase objective function + * depends on the current barrier parameter. */ + bool in_restoration_phase(); + + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpIpoptData.hpp b/thirdparty/linux/include/coin/IpIpoptData.hpp new file mode 100644 index 0000000..6973bab --- /dev/null +++ b/thirdparty/linux/include/coin/IpIpoptData.hpp @@ -0,0 +1,819 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIpoptData.hpp 2472 2014-04-05 17:47:20Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPIPOPTDATA_HPP__ +#define __IPIPOPTDATA_HPP__ + +#include "IpSymMatrix.hpp" +#include "IpOptionsList.hpp" +#include "IpIteratesVector.hpp" +#include "IpRegOptions.hpp" +#include "IpTimingStatistics.hpp" + +namespace Ipopt +{ + + /* Forward declaration */ + class IpoptNLP; + + /** Base class for additional data that is special to a particular + * type of algorithm, such as the CG penalty function, or using + * iterative linear solvers. The regular IpoptData object should + * be given a derivation of this base class when it is created. */ + class IpoptAdditionalData : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + IpoptAdditionalData() + {} + + /** Default destructor */ + virtual ~IpoptAdditionalData() + {} + //@} + + /** This method is called to initialize the global algorithmic + * parameters. The parameters are taken from the OptionsList + * object. */ + virtual bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix) = 0; + + /** Initialize Data Structures at the beginning. */ + virtual bool InitializeDataStructures() = 0; + + /** Do whatever is necessary to accept a trial point as current + * iterate. This is also used to finish an iteration, i.e., to + * release memory, and to reset any flags for a new iteration. */ + virtual void AcceptTrialPoint() = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + IpoptAdditionalData(const IpoptAdditionalData&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptAdditionalData&); + //@} + }; + + /** Class to organize all the data required by the algorithm. + * Internally, once this Data object has been initialized, all + * internal curr_ vectors must always be set (so that prototyes are + * available). The current values can only be set from the trial + * values. The trial values can be set by copying from a vector or + * by adding some fraction of a step to the current values. This + * object also stores steps, which allows to easily communicate the + * step from the step computation object to the line search object. + */ + class IpoptData : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor */ + IpoptData(SmartPtr<IpoptAdditionalData> add_data = NULL, + Number cpu_time_start = -1.); + + /** Default destructor */ + virtual ~IpoptData(); + //@} + + /** Initialize Data Structures */ + bool InitializeDataStructures(IpoptNLP& ip_nlp, + bool want_x, + bool want_y_c, + bool want_y_d, + bool want_z_L, + bool want_z_U); + + /** This method must be called to initialize the global + * algorithmic parameters. The parameters are taken from the + * OptionsList object. */ + bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** @name Get Methods for Iterates */ + //@{ + /** Current point */ + inline + SmartPtr<const IteratesVector> curr() const; + + /** Get the current point in a copied container that is non-const. + The entries in the container cannot be modified, but + the container can be modified to point to new entries. + */ + // SmartPtr<IteratesVector> curr_container() const; + + /** Get Trial point */ + inline + SmartPtr<const IteratesVector> trial() const; + + /** Get Trial point in a copied container that is non-const. + * The entries in the container can not be modified, but + * the container can be modified to point to new entries. + */ + //SmartPtr<IteratesVector> trial_container() const; + + /** Set the trial point - this method copies the pointer for + * efficiency (no copy and to keep cache tags the same) so + * after you call set you cannot modify the data again + */ + inline + void set_trial(SmartPtr<IteratesVector>& trial); + + /** Set the values of the primal trial variables (x and s) from + * provided Step with step length alpha. + */ + void SetTrialPrimalVariablesFromStep(Number alpha, + const Vector& delta_x, + const Vector& delta_s); + /** Set the values of the trial values for the equality constraint + * multipliers (y_c and y_d) from provided step with step length + * alpha. + */ + void SetTrialEqMultipliersFromStep(Number alpha, + const Vector& delta_y_c, + const Vector& delta_y_d); + /** Set the value of the trial values for the bound multipliers + * (z_L, z_U, v_L, v_U) from provided step with step length + * alpha. + */ + void SetTrialBoundMultipliersFromStep(Number alpha, + const Vector& delta_z_L, + const Vector& delta_z_U, + const Vector& delta_v_L, + const Vector& delta_v_U); + + /** ToDo: I may need to add versions of set_trial like the + * following, but I am not sure + */ + // void set_trial(const SmartPtr<IteratesVector>& trial_iterates); + // void set_trial(SmartPtr<const IteratesVector>& trial_iterates); + + /** get the current delta */ + inline + SmartPtr<const IteratesVector> delta() const; + + /** Set the current delta - like the trial point, this method copies + * the pointer for efficiency (no copy and to keep cache tags the + * same) so after you call set, you cannot modify the data + */ + inline + void set_delta(SmartPtr<IteratesVector>& delta); + + /** Set the current delta - like the trial point, this method + * copies the pointer for efficiency (no copy and to keep cache + * tags the same) so after you call set, you cannot modify the + * data. This is the version that is happy with a pointer to + * const IteratesVector. + */ + inline + void set_delta(SmartPtr<const IteratesVector>& delta); + + /** Affine Delta */ + inline + SmartPtr<const IteratesVector> delta_aff() const; + + /** Set the affine delta - like the trial point, this method copies + * the pointer for efficiency (no copy and to keep cache tags the + * same) so after you call set, you cannot modify the data + */ + inline + void set_delta_aff(SmartPtr<IteratesVector>& delta_aff); + + /** Hessian or Hessian approximation (do not hold on to it, it might be changed) */ + SmartPtr<const SymMatrix> W() + { + DBG_ASSERT(IsValid(W_)); + return W_; + } + + /** Set Hessian approximation */ + void Set_W(SmartPtr<const SymMatrix> W) + { + W_ = W; + } + + /** @name ("Main") Primal-dual search direction. Those fields are + * used to store the search directions computed from solving the + * primal-dual system, and can be used in the line search. They + * are overwritten in every iteration, so do not hold on to the + * pointers (make copies instead) */ + //@{ + + /** Returns true, if the primal-dual step have been already + * computed for the current iteration. This flag is reset after + * every call of AcceptTrialPoint(). If the search direction is + * computed during the computation of the barrier parameter, the + * method computing the barrier parameter should call + * SetHaveDeltas(true) to tell the IpoptAlgorithm object that it + * doesn't need to recompute the primal-dual step. */ + bool HaveDeltas() const + { + return have_deltas_; + } + + /** Method for setting the HaveDeltas flag. This method should be + * called if some method computes the primal-dual step (and + * stores it in the delta_ fields of IpoptData) at an early part + * of the iteration. If that flag is set to true, the + * IpoptAlgorithm object will not recompute the step. */ + void SetHaveDeltas(bool have_deltas) + { + have_deltas_ = have_deltas; + } + //@} + + /** @name Affine-scaling step. Those fields can be used to store + * the affine scaling step. For example, if the method for + * computing the current barrier parameter computes the affine + * scaling steps, then the corrector step in the line search does + * not have to recompute those solutions of the linear system. */ + //@{ + + /** Returns true, if the affine-scaling step have been already + * computed for the current iteration. This flag is reset after + * every call of AcceptTrialPoint(). If the search direction is + * computed during the computation of the barrier parameter, the + * method computing the barrier parameter should call + * SetHaveDeltas(true) to tell the line search does not have to + * recompute them in case it wants to do a corrector step. */ + bool HaveAffineDeltas() const + { + return have_affine_deltas_; + } + + /** Method for setting the HaveDeltas flag. This method should be + * called if some method computes the primal-dual step (and + * stores it in the delta_ fields of IpoptData) at an early part + * of the iteration. If that flag is set to true, the + * IpoptAlgorithm object will not recompute the step. */ + void SetHaveAffineDeltas(bool have_affine_deltas) + { + have_affine_deltas_ = have_affine_deltas; + } + //@} + + /** @name Public Methods for updating iterates */ + //@{ + /** Copy the trial values to the current values */ + inline + void CopyTrialToCurrent(); + + /** Set the current iterate values from the + * trial values. */ + void AcceptTrialPoint(); + //@} + + /** @name General algorithmic data */ + //@{ + Index iter_count() const + { + return iter_count_; + } + void Set_iter_count(Index iter_count) + { + iter_count_ = iter_count; + } + + Number curr_mu() const + { + DBG_ASSERT(mu_initialized_); + return curr_mu_; + } + void Set_mu(Number mu) + { + curr_mu_ = mu; + mu_initialized_ = true; + } + bool MuInitialized() const + { + return mu_initialized_; + } + + Number curr_tau() const + { + DBG_ASSERT(tau_initialized_); + return curr_tau_; + } + void Set_tau(Number tau) + { + curr_tau_ = tau; + tau_initialized_ = true; + } + bool TauInitialized() const + { + return tau_initialized_; + } + + void SetFreeMuMode(bool free_mu_mode) + { + free_mu_mode_ = free_mu_mode; + } + bool FreeMuMode() const + { + return free_mu_mode_; + } + + /** Setting the flag that indicates if a tiny step (below machine + * precision) has been detected */ + void Set_tiny_step_flag(bool flag) + { + tiny_step_flag_ = flag; + } + bool tiny_step_flag() + { + return tiny_step_flag_; + } + //@} + + /** Overall convergence tolerance. It is used in the convergence + * test, but also in some other parts of the algorithm that + * depend on the specified tolerance, such as the minimum value + * for the barrier parameter. */ + //@{ + /** Obtain the tolerance. */ + Number tol() const + { + DBG_ASSERT(initialize_called_); + return tol_; + } + /** Set a new value for the tolerance. One should be very careful + * when using this, since changing the predefined tolerance might + * have unexpected consequences. This method is for example used + * in the restoration convergence checker to tighten the + * restoration phase convergence tolerance, if the restoration + * phase converged to a point that has not a large value for the + * constraint violation. */ + void Set_tol(Number tol) + { + tol_ = tol; + } + //@} + + /** Cpu time counter at the beginning of the optimization. This + * is useful to see how much CPU time has been spent in this + * optimization run. */ + Number cpu_time_start() const + { + return cpu_time_start_; + } + + /** @name Information gathered for iteration output */ + //@{ + Number info_regu_x() const + { + return info_regu_x_; + } + void Set_info_regu_x(Number regu_x) + { + info_regu_x_ = regu_x; + } + Number info_alpha_primal() const + { + return info_alpha_primal_; + } + void Set_info_alpha_primal(Number alpha_primal) + { + info_alpha_primal_ = alpha_primal; + } + char info_alpha_primal_char() const + { + return info_alpha_primal_char_; + } + void Set_info_alpha_primal_char(char info_alpha_primal_char) + { + info_alpha_primal_char_ = info_alpha_primal_char; + } + Number info_alpha_dual() const + { + return info_alpha_dual_; + } + void Set_info_alpha_dual(Number alpha_dual) + { + info_alpha_dual_ = alpha_dual; + } + Index info_ls_count() const + { + return info_ls_count_; + } + void Set_info_ls_count(Index ls_count) + { + info_ls_count_ = ls_count; + } + bool info_skip_output() const + { + return info_skip_output_; + } + void Append_info_string(const std::string& add_str) + { + info_string_ += add_str; + } + const std::string& info_string() const + { + return info_string_; + } + /** Set this to true, if the next time when output is written, the + * summary line should not be printed. */ + void Set_info_skip_output(bool info_skip_output) + { + info_skip_output_ = info_skip_output; + } + + /** gives time when the last summary output line was printed */ + Number info_last_output() + { + return info_last_output_; + } + /** sets time when the last summary output line was printed */ + void Set_info_last_output(Number info_last_output) + { + info_last_output_ = info_last_output; + } + + /** gives number of iteration summaries actually printed + * since last summary header was printed */ + int info_iters_since_header() + { + return info_iters_since_header_; + } + /** increases number of iteration summaries actually printed + * since last summary header was printed */ + void Inc_info_iters_since_header() + { + info_iters_since_header_++; + } + /** sets number of iteration summaries actually printed + * since last summary header was printed */ + void Set_info_iters_since_header(int info_iters_since_header) + { + info_iters_since_header_ = info_iters_since_header; + } + + /** Reset all info fields */ + void ResetInfo() + { + info_regu_x_ = 0; + info_alpha_primal_ = 0; + info_alpha_dual_ = 0.; + info_alpha_primal_char_ = ' '; + info_skip_output_ = false; + info_string_.erase(); + } + //@} + + /** Return Timing Statistics Object */ + TimingStatistics& TimingStats() + { + return timing_statistics_; + } + + /** Check if additional data has been set */ + bool HaveAddData() + { + return IsValid(add_data_); + } + + /** Get access to additional data object */ + IpoptAdditionalData& AdditionalData() + { + return *add_data_; + } + + /** Set a new pointer for additional Ipopt data */ + void SetAddData(SmartPtr<IpoptAdditionalData> add_data) + { + DBG_ASSERT(!HaveAddData()); + add_data_ = add_data; + } + + /** Set the perturbation of the primal-dual system */ + void setPDPert(Number pd_pert_x, Number pd_pert_s, + Number pd_pert_c, Number pd_pert_d) + { + pd_pert_x_ = pd_pert_x; + pd_pert_s_ = pd_pert_s; + pd_pert_c_ = pd_pert_c; + pd_pert_d_ = pd_pert_d; + } + + /** Get the current perturbation of the primal-dual system */ + void getPDPert(Number& pd_pert_x, Number& pd_pert_s, + Number& pd_pert_c, Number& pd_pert_d) + { + pd_pert_x = pd_pert_x_; + pd_pert_s = pd_pert_s_; + pd_pert_c = pd_pert_c_; + pd_pert_d = pd_pert_d_; + } + + /** Methods for IpoptType */ + //@{ + static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions); + //@} + + private: + /** @name Iterates */ + //@{ + /** Main iteration variables + * (current iteration) */ + SmartPtr<const IteratesVector> curr_; + + /** Main iteration variables + * (trial calculations) */ + SmartPtr<const IteratesVector> trial_; + + /** Hessian (approximation) - might be changed elsewhere! */ + SmartPtr<const SymMatrix> W_; + + /** @name Primal-dual Step */ + //@{ + SmartPtr<const IteratesVector> delta_; + /** The following flag is set to true, if some other part of the + * algorithm (like the method for computing the barrier + * parameter) has already computed the primal-dual search + * direction. This flag is reset when the AcceptTrialPoint + * method is called. + * ToDo: we could cue off of a null delta_; + */ + bool have_deltas_; + //@} + + /** @name Affine-scaling step. This used to transfer the + * information about the affine-scaling step from the computation + * of the barrier parameter to the corrector (in the line + * search). */ + //@{ + SmartPtr<const IteratesVector> delta_aff_; + /** The following flag is set to true, if some other part of the + * algorithm (like the method for computing the barrier + * parameter) has already computed the affine-scaling step. This + * flag is reset when the AcceptTrialPoint method is called. + * ToDo: we could cue off of a null delta_aff_; + */ + bool have_affine_deltas_; + //@} + + /** iteration count */ + Index iter_count_; + + /** current barrier parameter */ + Number curr_mu_; + bool mu_initialized_; + + /** current fraction to the boundary parameter */ + Number curr_tau_; + bool tau_initialized_; + + /** flag indicating if Initialize method has been called (for + * debugging) */ + bool initialize_called_; + + /** flag for debugging whether we have already curr_ values + * available (from which new Vectors can be generated */ + bool have_prototypes_; + + /** @name Global algorithm parameters. Those are options that can + * be modified by the user and appear at different places in the + * algorithm. They are set using an OptionsList object in the + * Initialize method. */ + //@{ + /** Overall convergence tolerance */ + Number tol_; + //@} + + /** @name Status data **/ + //@{ + /** flag indicating whether the algorithm is in the free mu mode */ + bool free_mu_mode_; + /** flag indicating if a tiny step has been detected */ + bool tiny_step_flag_; + //@} + + /** @name Gathered information for iteration output */ + //@{ + /** Size of regularization for the Hessian */ + Number info_regu_x_; + /** Primal step size */ + Number info_alpha_primal_; + /** Info character for primal step size */ + char info_alpha_primal_char_; + /** Dual step size */ + Number info_alpha_dual_; + /** Number of backtracking trial steps */ + Index info_ls_count_; + /** true, if next summary output line should not be printed (eg + * after restoration phase. */ + bool info_skip_output_; + /** any string of characters for the end of the output line */ + std::string info_string_; + /** time when the last summary output line was printed */ + Number info_last_output_; + /** number of iteration summaries actually printed since last + * summary header was printed */ + int info_iters_since_header_; + //@} + + /** VectorSpace for all the iterates */ + SmartPtr<IteratesVectorSpace> iterates_space_; + + /** TimingStatistics object collecting all Ipopt timing + * statistics */ + TimingStatistics timing_statistics_; + + /** CPU time counter at initialization. */ + Number cpu_time_start_; + + /** Object for the data specific for the Chen-Goldfarb penalty + * method algorithm */ + SmartPtr<IpoptAdditionalData> add_data_; + + /** @name Information about the perturbation of the primal-dual + * system */ + //@{ + Number pd_pert_x_; + Number pd_pert_s_; + Number pd_pert_c_; + Number pd_pert_d_; + //@} + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + IpoptData(const IpoptData&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptData&); + //@} + +#if COIN_IPOPT_CHECKLEVEL > 0 + /** Some debug flags to make sure vectors are not changed + * behind the IpoptData's back + */ + //@{ + TaggedObject::Tag debug_curr_tag_; + TaggedObject::Tag debug_trial_tag_; + TaggedObject::Tag debug_delta_tag_; + TaggedObject::Tag debug_delta_aff_tag_; + TaggedObject::Tag debug_curr_tag_sum_; + TaggedObject::Tag debug_trial_tag_sum_; + TaggedObject::Tag debug_delta_tag_sum_; + TaggedObject::Tag debug_delta_aff_tag_sum_; + //@} +#endif + + }; + + inline + SmartPtr<const IteratesVector> IpoptData::curr() const + { + DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) ); + + return curr_; + } + + inline + SmartPtr<const IteratesVector> IpoptData::trial() const + { + DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) ); + + return trial_; + } + + inline + SmartPtr<const IteratesVector> IpoptData::delta() const + { + DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) ); + + return delta_; + } + + inline + SmartPtr<const IteratesVector> IpoptData::delta_aff() const + { + DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) ); + + return delta_aff_; + } + + inline + void IpoptData::CopyTrialToCurrent() + { + curr_ = trial_; +#if COIN_IPOPT_CHECKLEVEL > 0 + + if (IsValid(curr_)) { + debug_curr_tag_ = curr_->GetTag(); + debug_curr_tag_sum_ = curr_->GetTagSum(); + } + else { + debug_curr_tag_ = 0; + debug_curr_tag_sum_ = 0; + } +#endif + + } + + inline + void IpoptData::set_trial(SmartPtr<IteratesVector>& trial) + { + trial_ = ConstPtr(trial); + +#if COIN_IPOPT_CHECKLEVEL > 0 + // verify the correct space + DBG_ASSERT(trial_->OwnerSpace() == (VectorSpace*)GetRawPtr(iterates_space_)); + if (IsValid(trial)) { + debug_trial_tag_ = trial->GetTag(); + debug_trial_tag_sum_ = trial->GetTagSum(); + } + else { + debug_trial_tag_ = 0; + debug_trial_tag_sum_ = 0; + } +#endif + + trial = NULL; + } + + inline + void IpoptData::set_delta(SmartPtr<IteratesVector>& delta) + { + delta_ = ConstPtr(delta); +#if COIN_IPOPT_CHECKLEVEL > 0 + + if (IsValid(delta)) { + debug_delta_tag_ = delta->GetTag(); + debug_delta_tag_sum_ = delta->GetTagSum(); + } + else { + debug_delta_tag_ = 0; + debug_delta_tag_sum_ = 0; + } +#endif + + delta = NULL; + } + + inline + void IpoptData::set_delta(SmartPtr<const IteratesVector>& delta) + { + delta_ = delta; +#if COIN_IPOPT_CHECKLEVEL > 0 + + if (IsValid(delta)) { + debug_delta_tag_ = delta->GetTag(); + debug_delta_tag_sum_ = delta->GetTagSum(); + } + else { + debug_delta_tag_ = 0; + debug_delta_tag_sum_ = 0; + } +#endif + + delta = NULL; + } + + inline + void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff) + { + delta_aff_ = ConstPtr(delta_aff); +#if COIN_IPOPT_CHECKLEVEL > 0 + + if (IsValid(delta_aff)) { + debug_delta_aff_tag_ = delta_aff->GetTag(); + debug_delta_aff_tag_sum_ = delta_aff->GetTagSum(); + } + else { + debug_delta_aff_tag_ = 0; + debug_delta_aff_tag_sum_ = delta_aff->GetTagSum(); + } +#endif + + delta_aff = NULL; + } + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpIpoptNLP.hpp b/thirdparty/linux/include/coin/IpIpoptNLP.hpp new file mode 100644 index 0000000..21951c3 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIpoptNLP.hpp @@ -0,0 +1,261 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIpoptNLP.hpp 2594 2015-08-09 14:31:05Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPIPOPTNLP_HPP__ +#define __IPIPOPTNLP_HPP__ + +#include "IpNLP.hpp" +#include "IpJournalist.hpp" +#include "IpNLPScaling.hpp" + +namespace Ipopt +{ + // forward declarations + class IteratesVector; + + /** This is the abstract base class for classes that map + * the traditional NLP into + * something that is more useful by Ipopt. + * This class takes care of storing the + * calculated model results, handles cacheing, + * and (some day) takes care of addition of slacks. + */ + class IpoptNLP : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + IpoptNLP(const SmartPtr<NLPScalingObject> nlp_scaling) + : + nlp_scaling_(nlp_scaling) + {} + + /** Default destructor */ + virtual ~IpoptNLP() + {} + //@} + + /** Initialization method. Set the internal options and + * initialize internal data structures. */ + virtual bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix) + { + bool ret = true; + if (IsValid(nlp_scaling_)) { + ret = nlp_scaling_->Initialize(jnlst, options, prefix); + } + return ret; + } + + /**@name Possible Exceptions */ + //@{ + /** thrown if there is any error evaluating values from the nlp */ + DECLARE_STD_EXCEPTION(Eval_Error); + //@} + /** Initialize (create) structures for + * the iteration data */ + virtual bool InitializeStructures(SmartPtr<Vector>& x, + bool init_x, + SmartPtr<Vector>& y_c, + bool init_y_c, + SmartPtr<Vector>& y_d, + bool init_y_d, + SmartPtr<Vector>& z_L, + bool init_z_L, + SmartPtr<Vector>& z_U, + bool init_z_U, + SmartPtr<Vector>& v_L, + SmartPtr<Vector>& v_U + ) = 0; + + /** Method accessing the GetWarmStartIterate of the NLP */ + virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)=0; + + /** Accessor methods for model data */ + //@{ + /** Objective value */ + virtual Number f(const Vector& x) = 0; + + /** Gradient of the objective */ + virtual SmartPtr<const Vector> grad_f(const Vector& x) = 0; + + /** Equality constraint residual */ + virtual SmartPtr<const Vector> c(const Vector& x) = 0; + + /** Jacobian Matrix for equality constraints */ + virtual SmartPtr<const Matrix> jac_c(const Vector& x) = 0; + + /** Inequality constraint residual (reformulated + * as equalities with slacks */ + virtual SmartPtr<const Vector> d(const Vector& x) = 0; + + /** Jacobian Matrix for inequality constraints */ + virtual SmartPtr<const Matrix> jac_d(const Vector& x) = 0; + + /** Hessian of the Lagrangian */ + virtual SmartPtr<const SymMatrix> h(const Vector& x, + Number obj_factor, + const Vector& yc, + const Vector& yd + ) = 0; + + /** Lower bounds on x */ + virtual SmartPtr<const Vector> x_L() const = 0; + + /** Permutation matrix (x_L_ -> x) */ + virtual SmartPtr<const Matrix> Px_L() const = 0; + + /** Upper bounds on x */ + virtual SmartPtr<const Vector> x_U() const = 0; + + /** Permutation matrix (x_U_ -> x */ + virtual SmartPtr<const Matrix> Px_U() const = 0; + + /** Lower bounds on d */ + virtual SmartPtr<const Vector> d_L() const = 0; + + /** Permutation matrix (d_L_ -> d) */ + virtual SmartPtr<const Matrix> Pd_L() const = 0; + + /** Upper bounds on d */ + virtual SmartPtr<const Vector> d_U() const = 0; + + /** Permutation matrix (d_U_ -> d */ + virtual SmartPtr<const Matrix> Pd_U() const = 0; + + /** x_space */ + virtual SmartPtr<const VectorSpace> x_space() const = 0; + + /** Accessor method to obtain the MatrixSpace for the Hessian + * matrix (or it's approximation) */ + virtual SmartPtr<const SymMatrixSpace> HessianMatrixSpace() const = 0; + //@} + + /** Accessor method for vector/matrix spaces pointers. */ + virtual void GetSpaces(SmartPtr<const VectorSpace>& x_space, + SmartPtr<const VectorSpace>& c_space, + SmartPtr<const VectorSpace>& d_space, + SmartPtr<const VectorSpace>& x_l_space, + SmartPtr<const MatrixSpace>& px_l_space, + SmartPtr<const VectorSpace>& x_u_space, + SmartPtr<const MatrixSpace>& px_u_space, + SmartPtr<const VectorSpace>& d_l_space, + SmartPtr<const MatrixSpace>& pd_l_space, + SmartPtr<const VectorSpace>& d_u_space, + SmartPtr<const MatrixSpace>& pd_u_space, + SmartPtr<const MatrixSpace>& Jac_c_space, + SmartPtr<const MatrixSpace>& Jac_d_space, + SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space) = 0; + + /** Method for adapting the variable bounds. This is called if + * slacks are becoming too small */ + virtual void AdjustVariableBounds(const Vector& new_x_L, + const Vector& new_x_U, + const Vector& new_d_L, + const Vector& new_d_U)=0; + + /** @name Counters for the number of function evaluations. */ + //@{ + virtual Index f_evals() const = 0; + virtual Index grad_f_evals() const = 0; + virtual Index c_evals() const = 0; + virtual Index jac_c_evals() const = 0; + virtual Index d_evals() const = 0; + virtual Index jac_d_evals() const = 0; + virtual Index h_evals() const = 0; + //@} + + /** @name Special method for dealing with the fact that the + * restoration phase objective function depends on the barrier + * parameter */ + //@{ + /** Method for telling the IpoptCalculatedQuantities class whether + * the objective function depends on the barrier function. This + * is only used for the restoration phase NLP + * formulation. Probably only RestoIpoptNLP should overwrite + * this. */ + virtual bool objective_depends_on_mu() const + { + return false; + } + + /** Replacement for the default objective function method which + * knows about the barrier parameter */ + virtual Number f(const Vector& x, Number mu) = 0; + + /** Replacement for the default objective gradient method which + * knows about the barrier parameter */ + virtual SmartPtr<const Vector> grad_f(const Vector& x, Number mu) = 0; + + /** Replacement for the default Lagrangian Hessian method which + * knows about the barrier parameter */ + virtual SmartPtr<const SymMatrix> h(const Vector& x, + Number obj_factor, + const Vector& yc, + const Vector& yd, + Number mu) = 0; + + /** Provides a Hessian matrix from the correct matrix space with + * uninitialized values. This can be used in LeastSquareMults to + * obtain a "zero Hessian". */ + virtual SmartPtr<const SymMatrix> uninitialized_h() = 0; + //@} + + /**@name solution routines */ + //@{ + virtual void FinalizeSolution(SolverReturn status, + const Vector& x, const Vector& z_L, const Vector& z_U, + const Vector& c, const Vector& d, + const Vector& y_c, const Vector& y_d, + Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq)=0; + + virtual bool IntermediateCallBack(AlgorithmMode mode, + Index iter, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, + SmartPtr<const IpoptData> ip_data, + SmartPtr<IpoptCalculatedQuantities> ip_cq)=0; + //@} + + /** Returns the scaling strategy object */ + SmartPtr<NLPScalingObject> NLP_scaling() const + { + DBG_ASSERT(IsValid(nlp_scaling_)); + return nlp_scaling_; + } + + private: + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + + /** Copy Constructor */ + IpoptNLP(const IpoptNLP&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptNLP&); + //@} + + SmartPtr<NLPScalingObject> nlp_scaling_; + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpIteratesVector.hpp b/thirdparty/linux/include/coin/IpIteratesVector.hpp new file mode 100644 index 0000000..2ed7580 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIteratesVector.hpp @@ -0,0 +1,689 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIteratesVector.hpp 2472 2014-04-05 17:47:20Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-06-06 + +#ifndef __IPITERATESVECTOR_HPP__ +#define __IPITERATESVECTOR_HPP__ + +#include "IpCompoundVector.hpp" + +namespace Ipopt +{ + /* forward declarations */ + class IteratesVectorSpace; + + /** Specialized CompoundVector class specifically for the algorithm + * iterates. This class inherits from CompoundVector and is a + * specialized class for handling the iterates of the Ipopt + * Algorithm, that is, x, s, y_c, y_d, z_L, z_U, v_L, and v_U. It + * inherits from CompoundVector so it can behave like a CV in most + * calculations, but it has fixed dimensions and cannot be + * customized + */ + class IteratesVector : public CompoundVector + { + public: + /** Constructors / Destructors */ + //@{ + IteratesVector(const IteratesVectorSpace* owner_space, bool create_new); + + virtual ~IteratesVector(); + //@} + + /** Make New methods */ + //@{ + /** Use this method to create a new iterates vector. The MakeNew + * method on the Vector class also works, but it does not give + * the create_new option. + */ + SmartPtr<IteratesVector> MakeNewIteratesVector(bool create_new = true) const; + + /** Use this method to create a new iterates vector with a copy of + * all the data. + */ + SmartPtr<IteratesVector> MakeNewIteratesVectorCopy() const + { + SmartPtr<IteratesVector> ret = MakeNewIteratesVector(true); + ret->Copy(*this); + return ret; + } + + /** Use this method to create a new iterates vector + * container. This creates a new NonConst container, but the + * elements inside the iterates vector may be const. Therefore, + * the container can be modified to point to new entries, but the + * existing entries may or may not be modifiable. + */ + SmartPtr<IteratesVector> MakeNewContainer() const; + //@} + + /** Iterates Set/Get Methods */ + //@{ + /** Get the x iterate (const) */ + SmartPtr<const Vector> x() const + { + return GetIterateFromComp(0); + } + + /** Get the x iterate (non-const) - this can only be called if the + * vector was created intenally, or the Set_x_NonConst method was + * used. */ + SmartPtr<Vector> x_NonConst() + { + return GetNonConstIterateFromComp(0); + } + + /** Create a new vector in the x entry */ + inline + SmartPtr<Vector> create_new_x(); + + /** Create a new vector in the x entry and copy the current values + * into it. */ + SmartPtr<Vector> create_new_x_copy() + { + SmartPtr<const Vector> curr_x = GetComp(0); + Set_x_NonConst(*curr_x->MakeNew()); + x_NonConst()->Copy(*curr_x); + return x_NonConst(); + } + + /** Set the x iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_x(const Vector& vec) + { + SetComp(0, vec); + } + + /** Set the x iterate (non-const). Sets the pointer, does NOT copy + * data. */ + void Set_x_NonConst(Vector& vec) + { + SetCompNonConst(0, vec); + } + + /** Get the s iterate (const) */ + SmartPtr<const Vector> s() const + { + return GetIterateFromComp(1); + } + + /** Get the s iterate (non-const) - this can only be called if the + * vector was created intenally, or the Set_s_NonConst method was + * used. */ + SmartPtr<Vector> s_NonConst() + { + return GetNonConstIterateFromComp(1); + } + + /** Create a new vector in the s entry */ + inline + SmartPtr<Vector> create_new_s(); + + /** Create a new vector in the s entry and copy the current values + * into it. */ + SmartPtr<Vector> create_new_s_copy() + { + SmartPtr<const Vector> curr_s = GetComp(1); + Set_s_NonConst(*curr_s->MakeNew()); + s_NonConst()->Copy(*curr_s); + return s_NonConst(); + } + + /** Set the s iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_s(const Vector& vec) + { + SetComp(1, vec); + } + + /** Set the s iterate (non-const). Sets the pointer, does NOT copy + * data. */ + void Set_s_NonConst(Vector& vec) + { + SetCompNonConst(1, vec); + } + + /** Get the y_c iterate (const) */ + SmartPtr<const Vector> y_c() const + { + return GetIterateFromComp(2); + } + + /** Get the y_c iterate (non-const) - this can only be called if + * the vector was created intenally, or the Set_y_c_NonConst + * method was used. */ + SmartPtr<Vector> y_c_NonConst() + { + return GetNonConstIterateFromComp(2); + } + + /** Create a new vector in the y_c entry */ + inline + SmartPtr<Vector> create_new_y_c(); + + /** Create a new vector in the y_c entry and copy the current + * values into it. */ + SmartPtr<Vector> create_new_y_c_copy() + { + SmartPtr<const Vector> curr_y_c = GetComp(2); + Set_y_c_NonConst(*curr_y_c->MakeNew()); + y_c_NonConst()->Copy(*curr_y_c); + return y_c_NonConst(); + } + + /** Set the y_c iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_y_c(const Vector& vec) + { + SetComp(2, vec); + } + + /** Set the y_c iterate (non-const). Sets the pointer, does NOT + * copy data. */ + void Set_y_c_NonConst(Vector& vec) + { + SetCompNonConst(2, vec); + } + + /** Get the y_d iterate (const) */ + SmartPtr<const Vector> y_d() const + { + return GetIterateFromComp(3); + } + + /** Get the y_d iterate (non-const) - this can only be called if + * the vector was created intenally, or the Set_y_d_NonConst + * method was used. */ + SmartPtr<Vector> y_d_NonConst() + { + return GetNonConstIterateFromComp(3); + } + + /** Create a new vector in the y_d entry */ + inline + SmartPtr<Vector> create_new_y_d(); + + /** Create a new vector in the y_d entry and copy the current + * values into it. */ + SmartPtr<Vector> create_new_y_d_copy() + { + SmartPtr<const Vector> curr_y_d = GetComp(3); + Set_y_d_NonConst(*curr_y_d->MakeNew()); + y_d_NonConst()->Copy(*curr_y_d); + return y_d_NonConst(); + } + + /** Set the y_d iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_y_d(const Vector& vec) + { + SetComp(3, vec); + } + + /** Set the y_d iterate (non-const). Sets the pointer, does NOT + * copy data. */ + void Set_y_d_NonConst(Vector& vec) + { + SetCompNonConst(3, vec); + } + + /** Get the z_L iterate (const) */ + SmartPtr<const Vector> z_L() const + { + return GetIterateFromComp(4); + } + + /** Get the z_L iterate (non-const) - this can only be called if + * the vector was created intenally, or the Set_z_L_NonConst + * method was used. */ + SmartPtr<Vector> z_L_NonConst() + { + return GetNonConstIterateFromComp(4); + } + + /** Create a new vector in the z_L entry */ + inline + SmartPtr<Vector> create_new_z_L(); + + /** Create a new vector in the z_L entry and copy the current + * values into it. */ + SmartPtr<Vector> create_new_z_L_copy() + { + SmartPtr<const Vector> curr_z_L = GetComp(4); + Set_z_L_NonConst(*curr_z_L->MakeNew()); + z_L_NonConst()->Copy(*curr_z_L); + return z_L_NonConst(); + } + + /** Set the z_L iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_z_L(const Vector& vec) + { + SetComp(4, vec); + } + + /** Set the z_L iterate (non-const). Sets the pointer, does NOT + * copy data. */ + void Set_z_L_NonConst(Vector& vec) + { + SetCompNonConst(4, vec); + } + + /** Get the z_U iterate (const) */ + SmartPtr<const Vector> z_U() const + { + return GetIterateFromComp(5); + } + + /** Get the z_U iterate (non-const) - this can only be called if + * the vector was created intenally, or the Set_z_U_NonConst + * method was used. */ + SmartPtr<Vector> z_U_NonConst() + { + return GetNonConstIterateFromComp(5); + } + + /** Create a new vector in the z_U entry */ + inline + SmartPtr<Vector> create_new_z_U(); + + /** Create a new vector in the z_U entry and copy the current + * values into it. */ + SmartPtr<Vector> create_new_z_U_copy() + { + SmartPtr<const Vector> curr_z_U = GetComp(5); + Set_z_U_NonConst(*curr_z_U->MakeNew()); + z_U_NonConst()->Copy(*curr_z_U); + return z_U_NonConst(); + } + + /** Set the z_U iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_z_U(const Vector& vec) + { + SetComp(5, vec); + } + + /** Set the z_U iterate (non-const). Sets the pointer, does NOT + * copy data. */ + void Set_z_U_NonConst(Vector& vec) + { + SetCompNonConst(5, vec); + } + + /** Get the v_L iterate (const) */ + SmartPtr<const Vector> v_L() const + { + return GetIterateFromComp(6); + } + + /** Get the v_L iterate (non-const) - this can only be called if + * the vector was created intenally, or the Set_v_L_NonConst + * method was used. */ + SmartPtr<Vector> v_L_NonConst() + { + return GetNonConstIterateFromComp(6); + } + + /** Create a new vector in the v_L entry */ + inline + SmartPtr<Vector> create_new_v_L(); + + /** Create a new vector in the v_L entry and copy the current + * values into it. */ + SmartPtr<Vector> create_new_v_L_copy() + { + SmartPtr<const Vector> curr_v_L = GetComp(6); + Set_v_L_NonConst(*curr_v_L->MakeNew()); + v_L_NonConst()->Copy(*curr_v_L); + return v_L_NonConst(); + } + + /** Set the v_L iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_v_L(const Vector& vec) + { + SetComp(6, vec); + } + + /** Set the v_L iterate (non-const). Sets the pointer, does NOT + * copy data. */ + void Set_v_L_NonConst(Vector& vec) + { + SetCompNonConst(6, vec); + } + + /** Get the v_U iterate (const) */ + SmartPtr<const Vector> v_U() const + { + return GetIterateFromComp(7); + } + + /** Get the v_U iterate (non-const) - this can only be called if + * the vector was created intenally, or the Set_v_U_NonConst + * method was used. */ + SmartPtr<Vector> v_U_NonConst() + { + return GetNonConstIterateFromComp(7); + } + + /** Create a new vector in the v_U entry */ + inline + SmartPtr<Vector> create_new_v_U(); + + /** Create a new vector in the v_U entry and copy the current + * values into it. */ + SmartPtr<Vector> create_new_v_U_copy() + { + SmartPtr<const Vector> curr_v_U = GetComp(7); + Set_v_U_NonConst(*curr_v_U->MakeNew()); + v_U_NonConst()->Copy(*curr_v_U); + return v_U_NonConst(); + } + + /** Set the v_U iterate (const). Sets the pointer, does NOT copy + * data. */ + void Set_v_U(const Vector& vec) + { + SetComp(7, vec); + } + + /** Set the v_U iterate (non-const). Sets the pointer, does NOT + * copy data. */ + void Set_v_U_NonConst(Vector& vec) + { + SetCompNonConst(7, vec); + } + + /** Set the primal variables all in one shot. Sets the pointers, + * does NOT copy data */ + void Set_primal(const Vector& x, const Vector& s) + { + SetComp(0, x); + SetComp(1, s); + } + void Set_primal_NonConst(Vector& x, Vector& s) + { + SetCompNonConst(0, x); + SetCompNonConst(1, s); + } + + /** Set the eq multipliers all in one shot. Sets the pointers, + * does not copy data. */ + void Set_eq_mult(const Vector& y_c, const Vector& y_d) + { + SetComp(2, y_c); + SetComp(3, y_d); + } + void Set_eq_mult_NonConst(Vector& y_c, Vector& y_d) + { + SetCompNonConst(2, y_c); + SetCompNonConst(3, y_d); + } + + /** Set the bound multipliers all in one shot. Sets the pointers, + * does not copy data. */ + void Set_bound_mult(const Vector& z_L, const Vector& z_U, const Vector& v_L, const Vector& v_U) + { + SetComp(4, z_L); + SetComp(5, z_U); + SetComp(6, v_L); + SetComp(7, v_U); + } + void Set_bound_mult_NonConst(Vector& z_L, Vector& z_U, Vector& v_L, Vector& v_U) + { + SetCompNonConst(4, z_L); + SetCompNonConst(5, z_U); + SetCompNonConst(6, v_L); + SetCompNonConst(7, v_U); + } + + /** Get a sum of the tags of the contained items. There is no + * guarantee that this is unique, but there is a high chance it + * is unique and it can be used for debug checks relatively + * reliably. + */ + TaggedObject::Tag GetTagSum() const + { + TaggedObject::Tag tag = 0; + + if (IsValid(x())) { + tag += x()->GetTag(); + } + if (IsValid(s())) { + tag += s()->GetTag(); + } + if (IsValid(y_c())) { + tag += y_c()->GetTag(); + } + if (IsValid(y_d())) { + tag += y_d()->GetTag(); + } + if (IsValid(z_L())) { + tag += z_L()->GetTag(); + } + if (IsValid(z_U())) { + tag += z_U()->GetTag(); + } + if (IsValid(v_L())) { + tag += v_L()->GetTag(); + } + if (IsValid(v_U())) { + tag += v_U()->GetTag(); + } + + return tag; + } + //@} + + private: + /**@name Default Compiler Generated Methods (Hidden to avoid + * implicit creation/calling). These methods are not implemented + * and we do not want the compiler to implement them for us, so we + * declare them private and do not define them. This ensures that + * they will not be implicitly created/called. + */ + //@{ + /** Default Constructor */ + IteratesVector(); + + /** Copy Constructor */ + IteratesVector(const IteratesVector&); + + /** Overloaded Equals Operator */ + void operator=(const IteratesVector&); + //@} + + const IteratesVectorSpace* owner_space_; + + /** private method to return the const element from the compound + * vector. This method will return NULL if none is currently + * set. + */ + SmartPtr<const Vector> GetIterateFromComp(Index i) const + { + if (IsCompNull(i)) { + return NULL; + } + return GetComp(i); + } + + /** private method to return the non-const element from the + * compound vector. This method will return NULL if none is + * currently set. + */ + SmartPtr<Vector> GetNonConstIterateFromComp(Index i) + { + if (IsCompNull(i)) { + return NULL; + } + return GetCompNonConst(i); + } + + }; + + /** Vector Space for the IteratesVector class. This is a + * specialized vector space for the IteratesVector class. + */ + class IteratesVectorSpace : public CompoundVectorSpace + { + public: + /** @name Constructors/Destructors. */ + //@{ + /** Constructor that takes the spaces for each of the iterates. + * Warning! None of these can be NULL ! + */ + IteratesVectorSpace(const VectorSpace& x_space, const VectorSpace& s_space, + const VectorSpace& y_c_space, const VectorSpace& y_d_space, + const VectorSpace& z_L_space, const VectorSpace& z_U_space, + const VectorSpace& v_L_space, const VectorSpace& v_U_space + ); + + virtual ~IteratesVectorSpace(); + //@} + + /** Method for creating vectors . */ + //@{ + /** Use this to create a new IteratesVector. You can pass-in + * create_new = false if you only want a container and do not + * want vectors allocated. + */ + virtual IteratesVector* MakeNewIteratesVector(bool create_new = true) const + { + return new IteratesVector(this, create_new); + } + + /** Use this method to create a new const IteratesVector. You must pass in + * valid pointers for all of the entries. + */ + const SmartPtr<const IteratesVector> MakeNewIteratesVector(const Vector& x, const Vector& s, + const Vector& y_c, const Vector& y_d, + const Vector& z_L, const Vector& z_U, + const Vector& v_L, const Vector& v_U) + { + SmartPtr<IteratesVector> newvec = MakeNewIteratesVector(false); + newvec->Set_x(x); + newvec->Set_s(s); + newvec->Set_y_c(y_c); + newvec->Set_y_d(y_d); + newvec->Set_z_L(z_L); + newvec->Set_z_U(z_U); + newvec->Set_v_L(v_L); + newvec->Set_v_U(v_U); + return ConstPtr(newvec); + } + + + /** This method overloads + * ComooundVectorSpace::MakeNewCompoundVector to make sure that + * we get a vector of the correct type + */ + virtual CompoundVector* MakeNewCompoundVector(bool create_new = true) const + { + return MakeNewIteratesVector(create_new); + } + + /** This method creates a new vector (and allocates space in all + * the contained vectors. This is really only used for code that + * does not know what type of vector it is dealing with - for + * example, this method is called from Vector::MakeNew() + */ + virtual Vector* MakeNew() const + { + return MakeNewIteratesVector(); + } + //@} + + /** This method hides the CompoundVectorSpace::SetCompSpace method + * since the components of the Iterates are fixed at + * construction. + */ + virtual void SetCompSpace(Index icomp, const VectorSpace& vec_space) + { + DBG_ASSERT(false && "This is an IteratesVectorSpace - a special compound vector for Ipopt iterates. The contained spaces should not be modified."); + } + + private: + /**@name Default Compiler Generated Methods (Hidden to avoid + * implicit creation/calling). These methods are not implemented + * and we do not want the compiler to implement them for us, so we + * declare them private and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + IteratesVectorSpace(); + + /** Copy Constructor */ + IteratesVectorSpace(const IteratesVectorSpace&); + + /** Overloaded Equals Operator */ + IteratesVectorSpace& operator=(const IteratesVectorSpace&); + //@} + + /** Contained Spaces */ + SmartPtr<const VectorSpace> x_space_; + SmartPtr<const VectorSpace> s_space_; + SmartPtr<const VectorSpace> y_c_space_; + SmartPtr<const VectorSpace> y_d_space_; + SmartPtr<const VectorSpace> z_L_space_; + SmartPtr<const VectorSpace> z_U_space_; + SmartPtr<const VectorSpace> v_L_space_; + SmartPtr<const VectorSpace> v_U_space_; + }; + + + inline + SmartPtr<Vector> IteratesVector::create_new_x() + { + Set_x_NonConst(*owner_space_->GetCompSpace(0)->MakeNew()); + return x_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_s() + { + Set_s_NonConst(*owner_space_->GetCompSpace(1)->MakeNew()); + return s_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_y_c() + { + Set_y_c_NonConst(*owner_space_->GetCompSpace(2)->MakeNew()); + return y_c_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_y_d() + { + Set_y_d_NonConst(*owner_space_->GetCompSpace(3)->MakeNew()); + return y_d_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_z_L() + { + Set_z_L_NonConst(*owner_space_->GetCompSpace(4)->MakeNew()); + return z_L_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_z_U() + { + Set_z_U_NonConst(*owner_space_->GetCompSpace(5)->MakeNew()); + return z_U_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_v_L() + { + Set_v_L_NonConst(*owner_space_->GetCompSpace(6)->MakeNew()); + return v_L_NonConst(); + } + inline + SmartPtr<Vector> IteratesVector::create_new_v_U() + { + Set_v_U_NonConst(*owner_space_->GetCompSpace(7)->MakeNew()); + return v_U_NonConst(); + } +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpJournalist.hpp b/thirdparty/linux/include/coin/IpJournalist.hpp new file mode 100644 index 0000000..266130a --- /dev/null +++ b/thirdparty/linux/include/coin/IpJournalist.hpp @@ -0,0 +1,497 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpJournalist.hpp 2204 2013-04-13 13:49:26Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPJOURNALIST_HPP__ +#define __IPJOURNALIST_HPP__ + +#include "IpoptConfig.h" +#include "IpTypes.hpp" +#include "IpReferenced.hpp" +#include "IpSmartPtr.hpp" + +#ifdef HAVE_CSTDARG +# include <cstdarg> +#else +# ifdef HAVE_STDARG_H +# include <stdarg.h> +# else +# include <cstdarg> // if this header is included by someone who does not define HAVE_CSTDARG or HAVE_STDARG, let's hope that cstdarg is available +# endif +#endif + +#ifdef HAVE_CSTDIO +# include <cstdio> +#else +# ifdef HAVE_STDIO_H +# include <stdio.h> +# else +# include <cstdio> // if this header is included by someone who does not define HAVE_CSTDIO or HAVE_STDIO, let's hope that cstdio is available +# endif +#endif + +#include <string> +#include <vector> +#include <ostream> + +namespace Ipopt +{ + + // forward declarations + class Journal; + class FileJournal; + + /**@name Journalist Enumerations. */ + //@{ + /** Print Level Enum. */ + enum EJournalLevel { + J_INSUPPRESSIBLE=-1, + J_NONE=0, + J_ERROR, + J_STRONGWARNING, + J_SUMMARY, + J_WARNING, + J_ITERSUMMARY, + J_DETAILED, + J_MOREDETAILED, + J_VECTOR, + J_MOREVECTOR, + J_MATRIX, + J_MOREMATRIX, + J_ALL, + J_LAST_LEVEL + }; + + /** Category Selection Enum. */ + enum EJournalCategory { + J_DBG=0, + J_STATISTICS, + J_MAIN, + J_INITIALIZATION, + J_BARRIER_UPDATE, + J_SOLVE_PD_SYSTEM, + J_FRAC_TO_BOUND, + J_LINEAR_ALGEBRA, + J_LINE_SEARCH, + J_HESSIAN_APPROXIMATION, + J_SOLUTION, + J_DOCUMENTATION, + J_NLP, + J_TIMING_STATISTICS, + J_USER_APPLICATION /** This can be used by the user's application*/ , + J_USER1 /** This can be used by the user's application*/ , + J_USER2 /** This can be used by the user's application*/ , + J_USER3 /** This can be used by the user's application*/ , + J_USER4 /** This can be used by the user's application*/ , + J_USER5 /** This can be used by the user's application*/ , + J_USER6 /** This can be used by the user's application*/ , + J_USER7 /** This can be used by the user's application*/ , + J_USER8 /** This can be used by the user's application*/ , + J_USER9 /** This can be used by the user's application*/ , + J_USER10 /** This can be used by the user's application*/ , + J_USER11 /** This can be used by the user's application*/ , + J_USER12 /** This can be used by the user's application*/ , + J_USER13 /** This can be used by the user's application*/ , + J_USER14 /** This can be used by the user's application*/ , + J_USER15 /** This can be used by the user's application*/ , + J_USER16 /** This can be used by the user's application*/ , + J_USER17 /** This can be used by the user's application*/ , + J_LAST_CATEGORY + }; + //@} + + /** Class responsible for all message output. + * This class is responsible for all messaging and output. + * The "printing" code or "author" should send ALL messages to the + * Journalist, indicating an appropriate category and print level. + * The journalist then decides, based on reader specified + * acceptance criteria, which message is actually printed in which + * journals. + * This allows the printing code to send everything, while the + * "reader" can decide what they really want to see. + * + * Authors: + * Authors use the + * Journals: You can add as many Journals as you like to the + * Journalist with the AddJournal or the AddFileJournal methods. + * Each one represents a different printing location (or file). + * Then, you can call the "print" methods of the Journalist to output + * information to each of the journals. + * + * Acceptance Criteria: Each print message should be flagged + * appropriately with an EJournalCategory and EJournalLevel. + * + * The AddFileJournal + * method returns a pointer to the newly created Journal object + * (if successful) so you can set Acceptance criteria for that + * particular location. + * + */ + class Journalist : public ReferencedObject + { + public: + /**@name Constructor / Desructor. */ + //@{ + /** Constructor. */ + Journalist(); + + /** Destructor... */ + virtual ~Journalist(); + //@} + + /**@name Author Methods. + * These methods are used by authoring code, or code that wants + * to report some information. + */ + //@{ + /** Method to print a formatted string */ + virtual void Printf(EJournalLevel level, EJournalCategory category, + const char* format, ...) const; + + /** Method to print a long string including indentation. The + * string is printed starting at the current position. If the + * position (counting started at the current position) exceeds + * max_length, a new line is inserted, and indent_spaces many + * spaces are printed before the string is continued. This is + * for example used during the printing of the option + * documentation. */ + virtual void PrintStringOverLines(EJournalLevel level, EJournalCategory category, + Index indent_spaces, Index max_length, + const std::string& line) const; + + /** Method to print a formatted string with indentation */ + virtual void PrintfIndented(EJournalLevel level, + EJournalCategory category, + Index indent_level, + const char* format, ...) const; + + /** Method to print a formatted string + * using the va_list argument. */ + virtual void VPrintf(EJournalLevel level, + EJournalCategory category, + const char* pformat, + va_list ap) const; + + /** Method to print a formatted string with indentation, + * using the va_list argument. */ + virtual void VPrintfIndented(EJournalLevel level, + EJournalCategory category, + Index indent_level, + const char* pformat, + va_list ap) const; + + /** Method that returns true if there is a Journal that would + * write output for the given JournalLevel and JournalCategory. + * This is useful if expensive computation would be required for + * a particular output. The author code can check with this + * method if the computations are indeed required. + */ + virtual bool ProduceOutput(EJournalLevel level, + EJournalCategory category) const; + + + /** Method that flushes the current buffer for all Journalists. + Calling this method after one optimization run helps to avoid + cluttering output with that produced by other parts of the + program (e.g. written in Fortran) */ + virtual void FlushBuffer() const; + //@} + + /**@name Reader Methods. + * These methods are used by the reader. The reader will setup the + * journalist with each output file and the acceptance + * criteria for that file. + * + * Use these methods to setup the journals (files or other output). + * These are the internal objects that keep track of the print levels + * for each category. Then use the internal Journal objects to + * set specific print levels for each category (or keep defaults). + * + */ + //@{ + /** Add a new journal. The location_name is a string identifier, + * which can be used to obtain the pointer to the new Journal at + * a later point using the GetJournal method. + * The default_level is + * used to initialize the * printing level for all categories. + */ + virtual bool AddJournal(const SmartPtr<Journal> jrnl); + + /** Add a new FileJournal. fname is the name + * of the * file to which this Journal corresponds. Use + * fname="stdout" * for stdout, and use fname="stderr" for + * stderr. This method * returns the Journal pointer so you can + * set specific acceptance criteria. It returns NULL if there + * was a problem creating a new Journal. + */ + virtual SmartPtr<Journal> AddFileJournal( + const std::string& location_name, /**< journal identifier */ + const std::string& fname, /**< file name */ + EJournalLevel default_level = J_WARNING /**< default journal level */ + ); + + /** Get an existing journal. You can use this method to change + * the acceptance criteria at runtime. + */ + virtual SmartPtr<Journal> GetJournal(const std::string& location_name); + + /** Delete all journals curently known by the journalist. */ + virtual void DeleteAllJournals(); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + Journalist(const Journalist&); + + /** Overloaded Equals Operator */ + void operator=(const Journalist&); + //@} + + //** Private Data Members. */ + //@{ + std::vector< SmartPtr<Journal> > journals_; + //@} + }; + + /** Journal class (part of the Journalist implementation.). This + * class is the base class for all Journals. It controls the + * acceptance criteria for print statements etc. Derived classes + * like the FileJournal - output those messages to specific locations + */ + class Journal : public ReferencedObject + { + public: + /** Constructor. */ + Journal(const std::string& name, EJournalLevel default_level); + + /** Destructor. */ + virtual ~Journal(); + + /** Get the name of the Journal */ + virtual std::string Name(); + + /** Set the print level for a particular category. */ + virtual void SetPrintLevel( + EJournalCategory category, EJournalLevel level + ); + + /** Set the print level for all category. */ + virtual void SetAllPrintLevels( + EJournalLevel level + ); + + /**@name Journal Output Methods. These methods are called by the + * Journalist who first checks if the output print level and category + * are acceptable. + * Calling the Print methods explicitly (instead of through the + * Journalist will output the message regardless of print level + * and category. You should use the Journalist to print & flush instead + */ + //@{ + /** Ask if a particular print level/category is accepted by the + * journal. + */ + virtual bool IsAccepted( + EJournalCategory category, EJournalLevel level + ) const; + + /** Print to the designated output location */ + virtual void Print(EJournalCategory category, EJournalLevel level, + const char* str) + { + PrintImpl(category, level, str); + } + + /** Printf to the designated output location */ + virtual void Printf(EJournalCategory category, EJournalLevel level, + const char* pformat, va_list ap) + { + PrintfImpl(category, level, pformat, ap); + } + + /** Flush output buffer.*/ + virtual void FlushBuffer() + { + FlushBufferImpl(); + } + //@} + + protected: + /**@name Implementation version of Print methods. Derived classes + * should overload the Impl methods. + */ + //@{ + /** Print to the designated output location */ + virtual void PrintImpl(EJournalCategory category, EJournalLevel level, + const char* str)=0; + + /** Printf to the designated output location */ + virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, + const char* pformat, va_list ap)=0; + + /** Flush output buffer.*/ + virtual void FlushBufferImpl()=0; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + Journal(); + + /** Copy Constructor */ + Journal(const Journal&); + + /** Overloaded Equals Operator */ + void operator=(const Journal&); + //@} + + /** Name of the output location */ + std::string name_; + + /** vector of integers indicating the level for each category */ + Index print_levels_[J_LAST_CATEGORY]; + }; + + + /** FileJournal class. This is a particular Journal implementation that + * writes to a file for output. It can write to (stdout, stderr, or disk) + * by using "stdout" and "stderr" as filenames. + */ + class FileJournal : public Journal + { + public: + /** Constructor. */ + FileJournal(const std::string& name, EJournalLevel default_level); + + /** Destructor. */ + virtual ~FileJournal(); + + /** Open a new file for the output location. + * Special Names: stdout means stdout, + * : stderr means stderr. + * + * Return code is false only if the file with the given name + * could not be opened. + */ + virtual bool Open(const char* fname); + + protected: + /**@name Implementation version of Print methods - Overloaded from + * Journal base class. + */ + //@{ + /** Print to the designated output location */ + virtual void PrintImpl(EJournalCategory category, EJournalLevel level, + const char* str); + + /** Printf to the designated output location */ + virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, + const char* pformat, va_list ap); + + /** Flush output buffer.*/ + virtual void FlushBufferImpl(); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + FileJournal(); + + /** Copy Constructor */ + FileJournal(const FileJournal&); + + /** Overloaded Equals Operator */ + void operator=(const FileJournal&); + //@} + + /** FILE pointer for the output destination */ + FILE* file_; + }; + + /** StreamJournal class. This is a particular Journal implementation that + * writes to a stream for output. + */ + class StreamJournal : public Journal + { + public: + /** Constructor. */ + StreamJournal(const std::string& name, EJournalLevel default_level); + + /** Destructor. */ + virtual ~StreamJournal() + {} + + /** Setting the output stream pointer */ + void SetOutputStream(std::ostream* os); + + protected: + /**@name Implementation version of Print methods - Overloaded from + * Journal base class. + */ + //@{ + /** Print to the designated output location */ + virtual void PrintImpl(EJournalCategory category, EJournalLevel level, + const char* str); + + /** Printf to the designated output location */ + virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, + const char* pformat, va_list ap); + + /** Flush output buffer.*/ + virtual void FlushBufferImpl(); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + StreamJournal(); + + /** Copy Constructor */ + StreamJournal(const StreamJournal&); + + /** Overloaded Equals Operator */ + void operator=(const StreamJournal&); + //@} + + /** pointer to output stream for the output destination */ + std::ostream* os_; + + /** buffer for sprintf. Being generous in size here... */ + char buffer_[32768]; + }; +} + +#endif diff --git a/thirdparty/linux/include/coin/IpLapack.hpp b/thirdparty/linux/include/coin/IpLapack.hpp new file mode 100644 index 0000000..ef8883c --- /dev/null +++ b/thirdparty/linux/include/coin/IpLapack.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2005, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpLapack.hpp 2449 2013-12-16 00:25:42Z ghackebeil $ +// +// Authors: Andreas Waechter IBM 2005-12-25 + +#ifndef __IPLAPACK_HPP__ +#define __IPLAPACK_HPP__ + +#include "IpUtils.hpp" +#include "IpException.hpp" + +namespace Ipopt +{ + DECLARE_STD_EXCEPTION(LAPACK_NOT_INCLUDED); + + /** Wrapper for LAPACK subroutine DPOTRS. Solving a linear system + * given a Cholesky factorization. We assume that the Cholesky + * factor is lower traiangular. */ + void IpLapackDpotrs(Index ndim, Index nrhs, const Number *a, Index lda, + Number *b, Index ldb); + + /** Wrapper for LAPACK subroutine DPOTRF. Compute Cholesky + * factorization (lower triangular factor). info is the return + * value from the LAPACK routine. */ + void IpLapackDpotrf(Index ndim, Number *a, Index lda, Index& info); + + /** Wrapper for LAPACK subroutine DSYEV. Compute the Eigenvalue + * decomposition for a given matrix. If compute_eigenvectors is + * true, a will contain the eigenvectors in its columns on + * return. */ + void IpLapackDsyev(bool compute_eigenvectors, Index ndim, Number *a, + Index lda, Number *w, Index& info); + + /** Wrapper for LAPACK subroutine DGETRF. Compute LU factorization. + * info is the return value from the LAPACK routine. */ + void IpLapackDgetrf(Index ndim, Number *a, Index* pivot, Index lda, + Index& info); + + /** Wrapper for LAPACK subroutine DGETRS. Solving a linear system + * given a LU factorization. */ + void IpLapackDgetrs(Index ndim, Index nrhs, const Number *a, Index lda, + Index* ipiv, Number *b, Index ldb); + + /** Wrapper for LAPACK subroutine DPPSV. Solves a symmetric positive + * definite linear system in packed storage format (upper triangular). + * info is the return value from the LAPACK routine. */ + void IpLapackDppsv(Index ndim, Index nrhs, const Number *a, + Number *b, Index ldb, Index& info); + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpMatrix.hpp b/thirdparty/linux/include/coin/IpMatrix.hpp new file mode 100644 index 0000000..79018da --- /dev/null +++ b/thirdparty/linux/include/coin/IpMatrix.hpp @@ -0,0 +1,345 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpMatrix.hpp 2472 2014-04-05 17:47:20Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPMATRIX_HPP__ +#define __IPMATRIX_HPP__ + +#include "IpVector.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class MatrixSpace; + + /** Matrix Base Class. This is the base class for all derived matrix + * types. All Matrices, such as Jacobian and Hessian matrices, as + * well as possibly the iteration matrices needed for the step + * computation, are of this type. + * + * Deriving from Matrix: Overload the protected XXX_Impl method. + */ + class Matrix : public TaggedObject + { + public: + /** @name Constructor/Destructor */ + //@{ + /** Constructor. It has to be given a pointer to the + * corresponding MatrixSpace. + */ + Matrix(const MatrixSpace* owner_space) + : + TaggedObject(), + owner_space_(owner_space), + valid_cache_tag_(0) + {} + + /** Destructor */ + virtual ~Matrix() + {} + //@} + + /**@name Operations of the Matrix on a Vector */ + //@{ + /** Matrix-vector multiply. Computes y = alpha * Matrix * x + + * beta * y. Do not overload. Overload MultVectorImpl instead. + */ + void MultVector(Number alpha, const Vector& x, Number beta, + Vector& y) const + { + MultVectorImpl(alpha, x, beta, y); + } + + /** Matrix(transpose) vector multiply. Computes y = alpha * + * Matrix^T * x + beta * y. Do not overload. Overload + * TransMultVectorImpl instead. + */ + void TransMultVector(Number alpha, const Vector& x, Number beta, + Vector& y) const + { + TransMultVectorImpl(alpha, x, beta, y); + } + //@} + + /** @name Methods for specialized operations. A prototype + * implementation is provided, but for efficient implementation + * those should be specially implemented. + */ + //@{ + /** X = X + alpha*(Matrix S^{-1} Z). Should be implemented + * efficiently for the ExansionMatrix + */ + void AddMSinvZ(Number alpha, const Vector& S, const Vector& Z, + Vector& X) const; + + /** X = S^{-1} (r + alpha*Z*M^Td). Should be implemented + * efficiently for the ExansionMatrix + */ + void SinvBlrmZMTdBr(Number alpha, const Vector& S, + const Vector& R, const Vector& Z, + const Vector& D, Vector& X) const; + //@} + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + bool HasValidNumbers() const; + + /** @name Information about the size of the matrix */ + //@{ + /** Number of rows */ + inline + Index NRows() const; + + /** Number of columns */ + inline + Index NCols() const; + //@} + + /** @name Norms of the individual rows and columns */ + //@{ + /** Compute the max-norm of the rows in the matrix. The result is + * stored in rows_norms. The vector is assumed to be initialized + * of init is false. */ + void ComputeRowAMax(Vector& rows_norms, bool init=true) const + { + DBG_ASSERT(NRows() == rows_norms.Dim()); + if (init) rows_norms.Set(0.); + ComputeRowAMaxImpl(rows_norms, init); + } + /** Compute the max-norm of the columns in the matrix. The result + * is stored in cols_norms The vector is assumed to be initialized + * of init is false. */ + void ComputeColAMax(Vector& cols_norms, bool init=true) const + { + DBG_ASSERT(NCols() == cols_norms.Dim()); + if (init) cols_norms.Set(0.); + ComputeColAMaxImpl(cols_norms, init); + } + //@} + + /** Print detailed information about the matrix. Do not overload. + * Overload PrintImpl instead. + */ + //@{ + virtual void Print(SmartPtr<const Journalist> jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent=0, + const std::string& prefix="") const; + virtual void Print(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent=0, + const std::string& prefix="") const; + //@} + + /** Return the owner MatrixSpace*/ + inline + SmartPtr<const MatrixSpace> OwnerSpace() const; + + protected: + /** @name implementation methods (derived classes MUST + * overload these pure virtual protected methods. + */ + //@{ + /** Matrix-vector multiply. Computes y = alpha * Matrix * x + + * beta * y + */ + virtual void MultVectorImpl(Number alpha, const Vector& x, Number beta, Vector& y) const =0; + + /** Matrix(transpose) vector multiply. + * Computes y = alpha * Matrix^T * x + beta * y + */ + virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, Vector& y) const =0; + + /** X = X + alpha*(Matrix S^{-1} Z). Prototype for this + * specialize method is provided, but for efficient + * implementation it should be overloaded for the expansion matrix. + */ + virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z, + Vector& X) const; + + /** X = S^{-1} (r + alpha*Z*M^Td). Should be implemented + * efficiently for the ExpansionMatrix. + */ + virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector& S, + const Vector& R, const Vector& Z, + const Vector& D, Vector& X) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). A default implementation always returning true + * is provided, but if possible it should be implemented. */ + virtual bool HasValidNumbersImpl() const + { + return true; + } + + /** Compute the max-norm of the rows in the matrix. The result is + * stored in rows_norms. The vector is assumed to be + * initialized. */ + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const = 0; + /** Compute the max-norm of the columns in the matrix. The result + * is stored in cols_norms. The vector is assumed to be + * initialized. */ + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const = 0; + + /** Print detailed information about the matrix. */ + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const =0; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** default constructor */ + Matrix(); + + /** Copy constructor */ + Matrix(const Matrix&); + + /** Overloaded Equals Operator */ + Matrix& operator=(const Matrix&); + //@} + + const SmartPtr<const MatrixSpace> owner_space_; + + /**@name CachedResults data members */ + //@{ + mutable TaggedObject::Tag valid_cache_tag_; + mutable bool cached_valid_; + //@} + }; + + + /** MatrixSpace base class, corresponding to the Matrix base class. + * For each Matrix implementation, a corresponding MatrixSpace has + * to be implemented. A MatrixSpace is able to create new Matrices + * of a specific type. The MatrixSpace should also store + * information that is common to all Matrices of that type. For + * example, the dimensions of a Matrix is stored in the MatrixSpace + * base class. + */ + class MatrixSpace : public ReferencedObject + { + public: + /** @name Constructors/Destructors */ + //@{ + /** Constructor, given the number rows and columns of all matrices + * generated by this MatrixSpace. + */ + MatrixSpace(Index nRows, Index nCols) + : + nRows_(nRows), + nCols_(nCols) + {} + + /** Destructor */ + virtual ~MatrixSpace() + {} + //@} + + /** Pure virtual method for creating a new Matrix of the + * corresponding type. + */ + virtual Matrix* MakeNew() const=0; + + /** Accessor function for the number of rows. */ + Index NRows() const + { + return nRows_; + } + /** Accessor function for the number of columns. */ + Index NCols() const + { + return nCols_; + } + + /** Method to test if a given matrix belongs to a particular + * matrix space. + */ + bool IsMatrixFromSpace(const Matrix& matrix) const + { + return (matrix.OwnerSpace() == this); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** default constructor */ + MatrixSpace(); + + /** Copy constructor */ + MatrixSpace(const MatrixSpace&); + + /** Overloaded Equals Operator */ + MatrixSpace& operator=(const MatrixSpace&); + //@} + + /** Number of rows for all matrices of this type. */ + const Index nRows_; + /** Number of columns for all matrices of this type. */ + const Index nCols_; + }; + + + /* Inline Methods */ + inline + Index Matrix::NRows() const + { + return owner_space_->NRows(); + } + + inline + Index Matrix::NCols() const + { + return owner_space_->NCols(); + } + + inline + SmartPtr<const MatrixSpace> Matrix::OwnerSpace() const + { + return owner_space_; + } + +} // namespace Ipopt + +// Macro definitions for debugging matrices +#if COIN_IPOPT_VERBOSITY == 0 +# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) +#else +# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) \ + if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \ + if (dbg_jrnl.Jnlst()!=NULL) { \ + (__mat).Print(dbg_jrnl.Jnlst(), \ + J_ERROR, J_DBG, \ + __mat_name, \ + dbg_jrnl.IndentationLevel()*2, \ + "# "); \ + } \ + } +#endif // #if COIN_IPOPT_VERBOSITY == 0 + +#endif diff --git a/thirdparty/linux/include/coin/IpNLP.hpp b/thirdparty/linux/include/coin/IpNLP.hpp new file mode 100644 index 0000000..1063c01 --- /dev/null +++ b/thirdparty/linux/include/coin/IpNLP.hpp @@ -0,0 +1,243 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpNLP.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPNLP_HPP__ +#define __IPNLP_HPP__ + +#include "IpUtils.hpp" +#include "IpVector.hpp" +#include "IpSmartPtr.hpp" +#include "IpMatrix.hpp" +#include "IpSymMatrix.hpp" +#include "IpOptionsList.hpp" +#include "IpAlgTypes.hpp" +#include "IpReturnCodes.hpp" + +namespace Ipopt +{ + // forward declarations + class IpoptData; + class IpoptCalculatedQuantities; + class IteratesVector; + + /** Brief Class Description. + * Detailed Class Description. + */ + class NLP : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor */ + NLP() + {} + + /** Default destructor */ + virtual ~NLP() + {} + //@} + + /** Exceptions */ + //@{ + DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED); + DECLARE_STD_EXCEPTION(INVALID_NLP); + //@} + + /** @name NLP Initialization (overload in + * derived classes).*/ + //@{ + /** Overload if you want the chance to process options or parameters that + * may be specific to the NLP */ + virtual bool ProcessOptions(const OptionsList& options, + const std::string& prefix) + { + return true; + } + + /** Method for creating the derived vector / matrix types. The + * Hess_lagrangian_space pointer can be NULL if a quasi-Newton + * options is chosen. */ + virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space, + SmartPtr<const VectorSpace>& c_space, + SmartPtr<const VectorSpace>& d_space, + SmartPtr<const VectorSpace>& x_l_space, + SmartPtr<const MatrixSpace>& px_l_space, + SmartPtr<const VectorSpace>& x_u_space, + SmartPtr<const MatrixSpace>& px_u_space, + SmartPtr<const VectorSpace>& d_l_space, + SmartPtr<const MatrixSpace>& pd_l_space, + SmartPtr<const VectorSpace>& d_u_space, + SmartPtr<const MatrixSpace>& pd_u_space, + SmartPtr<const MatrixSpace>& Jac_c_space, + SmartPtr<const MatrixSpace>& Jac_d_space, + SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space)=0; + + /** Method for obtaining the bounds information */ + virtual bool GetBoundsInformation(const Matrix& Px_L, + Vector& x_L, + const Matrix& Px_U, + Vector& x_U, + const Matrix& Pd_L, + Vector& d_L, + const Matrix& Pd_U, + Vector& d_U)=0; + + /** Method for obtaining the starting point for all the + * iterates. ToDo it might not make sense to ask for initial + * values for v_L and v_U? */ + virtual bool GetStartingPoint( + SmartPtr<Vector> x, + bool need_x, + SmartPtr<Vector> y_c, + bool need_y_c, + SmartPtr<Vector> y_d, + bool need_y_d, + SmartPtr<Vector> z_L, + bool need_z_L, + SmartPtr<Vector> z_U, + bool need_z_U + )=0; + + /** Method for obtaining an entire iterate as a warmstart point. + * The incoming IteratesVector has to be filled. The default + * dummy implementation returns false. */ + virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate) + { + return false; + } + //@} + + /** @name NLP evaluation routines (overload + * in derived classes. */ + //@{ + virtual bool Eval_f(const Vector& x, Number& f) = 0; + + virtual bool Eval_grad_f(const Vector& x, Vector& g_f) = 0; + + virtual bool Eval_c(const Vector& x, Vector& c) = 0; + + virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c) = 0; + + virtual bool Eval_d(const Vector& x, Vector& d) = 0; + + virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d) = 0; + + virtual bool Eval_h(const Vector& x, + Number obj_factor, + const Vector& yc, + const Vector& yd, + SymMatrix& h) = 0; + //@} + + /** @name NLP solution routines. Have default dummy + * implementations that can be overloaded. */ + //@{ + /** This method is called at the very end of the optimization. It + * provides the final iterate to the user, so that it can be + * stored as the solution. The status flag indicates the outcome + * of the optimization, where SolverReturn is defined in + * IpAlgTypes.hpp. */ + virtual void FinalizeSolution(SolverReturn status, + const Vector& x, const Vector& z_L, + const Vector& z_U, + const Vector& c, const Vector& d, + const Vector& y_c, const Vector& y_d, + Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq) + {} + + /** This method is called once per iteration, after the iteration + * summary output has been printed. It provides the current + * information to the user to do with it anything she wants. It + * also allows the user to ask for a premature termination of the + * optimization by returning false, in which case Ipopt will + * terminate with a corresponding return status. The basic + * information provided in the argument list has the quantities + * values printed in the iteration summary line. If more + * information is required, a user can obtain it from the IpData + * and IpCalculatedQuantities objects. However, note that the + * provided quantities are all for the problem that Ipopt sees, + * i.e., the quantities might be scaled, fixed variables might be + * sorted out, etc. The status indicates things like whether the + * algorithm is in the restoration phase... In the restoration + * phase, the dual variables are probably not not changing. */ + virtual bool IntermediateCallBack(AlgorithmMode mode, + Index iter, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq) + { + return true; + } + //@} + + /** Routines to get the scaling parameters. These do not need to + * be overloaded unless the options are set for User scaling + */ + //@{ + virtual void GetScalingParameters( + const SmartPtr<const VectorSpace> x_space, + const SmartPtr<const VectorSpace> c_space, + const SmartPtr<const VectorSpace> d_space, + Number& obj_scaling, + SmartPtr<Vector>& x_scaling, + SmartPtr<Vector>& c_scaling, + SmartPtr<Vector>& d_scaling) const + { + THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED, + "You have set options for user provided scaling, but have" + " not implemented GetScalingParameters in the NLP interface"); + } + //@} + + /** Method for obtaining the subspace in which the limited-memory + * Hessian approximation should be done. This is only called if + * the limited-memory Hessian approximation is chosen. Since the + * Hessian is zero in the space of all variables that appear in + * the problem functions only linearly, this allows the user to + * provide a VectorSpace for all nonlinear variables, and an + * ExpansionMatrix to lift from this VectorSpace to the + * VectorSpace of the primal variables x. If the returned values + * are NULL, it is assumed that the Hessian is to be approximated + * in the space of all x variables. The default instantiation of + * this method returns NULL, and a user only has to overwrite + * this method if the approximation is to be done only in a + * subspace. */ + virtual void + GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space, + SmartPtr<Matrix>& P_approx) + { + approx_space = NULL; + P_approx = NULL; + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + NLP(const NLP&); + + /** Overloaded Equals Operator */ + void operator=(const NLP&); + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpNLPScaling.hpp b/thirdparty/linux/include/coin/IpNLPScaling.hpp new file mode 100644 index 0000000..be5f13d --- /dev/null +++ b/thirdparty/linux/include/coin/IpNLPScaling.hpp @@ -0,0 +1,451 @@ +// Copyright (C) 2004, 2007 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpNLPScaling.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPNLPSCALING_HPP__ +#define __IPNLPSCALING_HPP__ + +#include "IpOptionsList.hpp" +#include "IpRegOptions.hpp" + +namespace Ipopt +{ + // forward declarations + class Vector; + class VectorSpace; + class Matrix; + class MatrixSpace; + class SymMatrix; + class SymMatrixSpace; + class ScaledMatrixSpace; + class SymScaledMatrixSpace; + + /** This is the abstract base class for problem scaling. + * It is repsonsible for determining the scaling factors + * and mapping quantities in and out of scaled and unscaled + * versions + */ + class NLPScalingObject : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + NLPScalingObject(); + + /** Default destructor */ + virtual ~NLPScalingObject(); + //@} + + /** Method to initialize the options */ + bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix) + { + jnlst_ = &jnlst; + return InitializeImpl(options, prefix); + } + + /** Methods to map scaled and unscaled matrices */ + //@{ + /** Returns an obj-scaled version of the given scalar */ + virtual Number apply_obj_scaling(const Number& f)=0; + /** Returns an obj-unscaled version of the given scalar */ + virtual Number unapply_obj_scaling(const Number& f)=0; + /** Returns an x-scaled version of the given vector */ + virtual SmartPtr<Vector> + apply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v)=0; + /** Returns an x-scaled version of the given vector */ + virtual SmartPtr<const Vector> + apply_vector_scaling_x(const SmartPtr<const Vector>& v)=0; + /** Returns an x-unscaled version of the given vector */ + virtual SmartPtr<Vector> + unapply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v)=0; + /** Returns an x-unscaled version of the given vector */ + virtual SmartPtr<const Vector> + unapply_vector_scaling_x(const SmartPtr<const Vector>& v)=0; + /** Returns an c-scaled version of the given vector */ + virtual SmartPtr<const Vector> + apply_vector_scaling_c(const SmartPtr<const Vector>& v)=0; + /** Returns an c-unscaled version of the given vector */ + virtual SmartPtr<const Vector> + unapply_vector_scaling_c(const SmartPtr<const Vector>& v)=0; + /** Returns an c-scaled version of the given vector */ + virtual SmartPtr<Vector> + apply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v)=0; + /** Returns an c-unscaled version of the given vector */ + virtual SmartPtr<Vector> + unapply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v)=0; + /** Returns an d-scaled version of the given vector */ + virtual SmartPtr<const Vector> + apply_vector_scaling_d(const SmartPtr<const Vector>& v)=0; + /** Returns an d-unscaled version of the given vector */ + virtual SmartPtr<const Vector> + unapply_vector_scaling_d(const SmartPtr<const Vector>& v)=0; + /** Returns an d-scaled version of the given vector */ + virtual SmartPtr<Vector> + apply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v)=0; + /** Returns an d-unscaled version of the given vector */ + virtual SmartPtr<Vector> + unapply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v)=0; + /** Returns a scaled version of the jacobian for c. If the + * overloaded method does not make a new matrix, make sure to set + * the matrix ptr passed in to NULL. + */ + virtual SmartPtr<const Matrix> + apply_jac_c_scaling(SmartPtr<const Matrix> matrix)=0; + /** Returns a scaled version of the jacobian for d If the + * overloaded method does not create a new matrix, make sure to + * set the matrix ptr passed in to NULL. + */ + virtual SmartPtr<const Matrix> + apply_jac_d_scaling(SmartPtr<const Matrix> matrix)=0; + /** Returns a scaled version of the hessian of the lagrangian If + * the overloaded method does not create a new matrix, make sure + * to set the matrix ptr passed in to NULL. + */ + virtual SmartPtr<const SymMatrix> + apply_hessian_scaling(SmartPtr<const SymMatrix> matrix)=0; + //@} + + /** Methods for scaling bounds - these wrap those above */ + //@{ + /** Returns an x-scaled vector in the x_L or x_U space */ + SmartPtr<Vector> apply_vector_scaling_x_LU_NonConst( + const Matrix& Px_LU, + const SmartPtr<const Vector>& lu, + const VectorSpace& x_space); + /** Returns an x-scaled vector in the x_L or x_U space */ + SmartPtr<const Vector> apply_vector_scaling_x_LU( + const Matrix& Px_LU, + const SmartPtr<const Vector>& lu, + const VectorSpace& x_space); + /** Returns an d-scaled vector in the d_L or d_U space */ + SmartPtr<Vector> apply_vector_scaling_d_LU_NonConst( + const Matrix& Pd_LU, + const SmartPtr<const Vector>& lu, + const VectorSpace& d_space); + /** Returns an d-scaled vector in the d_L or d_U space */ + SmartPtr<const Vector> apply_vector_scaling_d_LU( + const Matrix& Pd_LU, + const SmartPtr<const Vector>& lu, + const VectorSpace& d_space); + /** Returns an d-unscaled vector in the d_L or d_U space */ + SmartPtr<Vector> unapply_vector_scaling_d_LU_NonConst( + const Matrix& Pd_LU, + const SmartPtr<const Vector>& lu, + const VectorSpace& d_space); + /** Returns an d-unscaled vector in the d_L or d_U space */ + SmartPtr<const Vector> unapply_vector_scaling_d_LU( + const Matrix& Pd_LU, + const SmartPtr<const Vector>& lu, + const VectorSpace& d_space); + //@} + + /** Methods for scaling the gradient of the objective - wraps the + * virtual methods above + */ + //@{ + /** Returns a grad_f scaled version (d_f * D_x^{-1}) of the given vector */ + virtual SmartPtr<Vector> + apply_grad_obj_scaling_NonConst(const SmartPtr<const Vector>& v); + /** Returns a grad_f scaled version (d_f * D_x^{-1}) of the given vector */ + virtual SmartPtr<const Vector> + apply_grad_obj_scaling(const SmartPtr<const Vector>& v); + /** Returns a grad_f unscaled version (d_f * D_x^{-1}) of the + * given vector */ + virtual SmartPtr<Vector> + unapply_grad_obj_scaling_NonConst(const SmartPtr<const Vector>& v); + /** Returns a grad_f unscaled version (d_f * D_x^{-1}) of the + * given vector */ + virtual SmartPtr<const Vector> + unapply_grad_obj_scaling(const SmartPtr<const Vector>& v); + //@} + + /** @name Methods for determining whether scaling for entities is + * done */ + //@{ + /** Returns true if the primal x variables are scaled. */ + virtual bool have_x_scaling()=0; + /** Returns true if the equality constraints are scaled. */ + virtual bool have_c_scaling()=0; + /** Returns true if the inequality constraints are scaled. */ + virtual bool have_d_scaling()=0; + //@} + + /** This method is called by the IpoptNLP's at a convenient time to + * compute and/or read scaling factors + */ + virtual void DetermineScaling(const SmartPtr<const VectorSpace> x_space, + const SmartPtr<const VectorSpace> c_space, + const SmartPtr<const VectorSpace> d_space, + const SmartPtr<const MatrixSpace> jac_c_space, + const SmartPtr<const MatrixSpace> jac_d_space, + const SmartPtr<const SymMatrixSpace> h_space, + SmartPtr<const MatrixSpace>& new_jac_c_space, + SmartPtr<const MatrixSpace>& new_jac_d_space, + SmartPtr<const SymMatrixSpace>& new_h_space, + const Matrix& Px_L, const Vector& x_L, + const Matrix& Px_U, const Vector& x_U)=0; + protected: + /** Implementation of the initialization method that has to be + * overloaded by for each derived class. */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix)=0; + + /** Accessor method for the journalist */ + const Journalist& Jnlst() const + { + return *jnlst_; + } + private: + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + + /** Copy Constructor */ + NLPScalingObject(const NLPScalingObject&); + + /** Overloaded Equals Operator */ + void operator=(const NLPScalingObject&); + //@} + + SmartPtr<const Journalist> jnlst_; + }; + + /** This is a base class for many standard scaling + * techniques. The overloaded classes only need to + * provide the scaling parameters + */ + class StandardScalingBase : public NLPScalingObject + { + public: + /**@name Constructors/Destructors */ + //@{ + StandardScalingBase(); + + /** Default destructor */ + virtual ~StandardScalingBase(); + //@} + + /** Methods to map scaled and unscaled matrices */ + //@{ + /** Returns an obj-scaled version of the given scalar */ + virtual Number apply_obj_scaling(const Number& f); + /** Returns an obj-unscaled version of the given scalar */ + virtual Number unapply_obj_scaling(const Number& f); + /** Returns an x-scaled version of the given vector */ + virtual SmartPtr<Vector> + apply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v); + /** Returns an x-scaled version of the given vector */ + virtual SmartPtr<const Vector> + apply_vector_scaling_x(const SmartPtr<const Vector>& v); + /** Returns an x-unscaled version of the given vector */ + virtual SmartPtr<Vector> + unapply_vector_scaling_x_NonConst(const SmartPtr<const Vector>& v); + /** Returns an x-unscaled version of the given vector */ + virtual SmartPtr<const Vector> + unapply_vector_scaling_x(const SmartPtr<const Vector>& v); + /** Returns an c-scaled version of the given vector */ + virtual SmartPtr<const Vector> + apply_vector_scaling_c(const SmartPtr<const Vector>& v); + /** Returns an c-unscaled version of the given vector */ + virtual SmartPtr<const Vector> + unapply_vector_scaling_c(const SmartPtr<const Vector>& v); + /** Returns an c-scaled version of the given vector */ + virtual SmartPtr<Vector> + apply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v); + /** Returns an c-unscaled version of the given vector */ + virtual SmartPtr<Vector> + unapply_vector_scaling_c_NonConst(const SmartPtr<const Vector>& v); + /** Returns an d-scaled version of the given vector */ + virtual SmartPtr<const Vector> + apply_vector_scaling_d(const SmartPtr<const Vector>& v); + /** Returns an d-unscaled version of the given vector */ + virtual SmartPtr<const Vector> + unapply_vector_scaling_d(const SmartPtr<const Vector>& v); + /** Returns an d-scaled version of the given vector */ + virtual SmartPtr<Vector> + apply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v); + /** Returns an d-unscaled version of the given vector */ + virtual SmartPtr<Vector> + unapply_vector_scaling_d_NonConst(const SmartPtr<const Vector>& v); + /** Returns a scaled version of the jacobian for c. If the + * overloaded method does not make a new matrix, make sure to set + * the matrix ptr passed in to NULL. + */ + virtual SmartPtr<const Matrix> + apply_jac_c_scaling(SmartPtr<const Matrix> matrix); + /** Returns a scaled version of the jacobian for d If the + * overloaded method does not create a new matrix, make sure to + * set the matrix ptr passed in to NULL. + */ + virtual SmartPtr<const Matrix> + apply_jac_d_scaling(SmartPtr<const Matrix> matrix); + /** Returns a scaled version of the hessian of the lagrangian If + * the overloaded method does not create a new matrix, make sure + * to set the matrix ptr passed in to NULL. + */ + virtual SmartPtr<const SymMatrix> + apply_hessian_scaling(SmartPtr<const SymMatrix> matrix); + //@} + + /** @name Methods for determining whether scaling for entities is + * done */ + //@{ + virtual bool have_x_scaling(); + virtual bool have_c_scaling(); + virtual bool have_d_scaling(); + //@} + + /** This method is called by the IpoptNLP's at a convenient time to + * compute and/or read scaling factors + */ + virtual void DetermineScaling(const SmartPtr<const VectorSpace> x_space, + const SmartPtr<const VectorSpace> c_space, + const SmartPtr<const VectorSpace> d_space, + const SmartPtr<const MatrixSpace> jac_c_space, + const SmartPtr<const MatrixSpace> jac_d_space, + const SmartPtr<const SymMatrixSpace> h_space, + SmartPtr<const MatrixSpace>& new_jac_c_space, + SmartPtr<const MatrixSpace>& new_jac_d_space, + SmartPtr<const SymMatrixSpace>& new_h_space, + const Matrix& Px_L, const Vector& x_L, + const Matrix& Px_U, const Vector& x_U); + + /** Methods for IpoptType */ + //@{ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + protected: + /** Overloaded initialization method */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix); + + /** This is the method that has to be overloaded by a particular + * scaling method that somehow computes the scaling vectors dx, + * dc, and dd. The pointers to those vectors can be NULL, in + * which case no scaling for that item will be done later. */ + virtual void DetermineScalingParametersImpl( + const SmartPtr<const VectorSpace> x_space, + const SmartPtr<const VectorSpace> c_space, + const SmartPtr<const VectorSpace> d_space, + const SmartPtr<const MatrixSpace> jac_c_space, + const SmartPtr<const MatrixSpace> jac_d_space, + const SmartPtr<const SymMatrixSpace> h_space, + const Matrix& Px_L, const Vector& x_L, + const Matrix& Px_U, const Vector& x_U, + Number& df, + SmartPtr<Vector>& dx, + SmartPtr<Vector>& dc, + SmartPtr<Vector>& dd)=0; + + private: + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + + /** Copy Constructor */ + StandardScalingBase(const StandardScalingBase&); + + /** Overloaded Equals Operator */ + void operator=(const StandardScalingBase&); + //@} + + /** Scaling parameters - we only need to keep copies of + * the objective scaling and the x scaling - the others we can + * get from the scaled matrix spaces. + */ + //@{ + /** objective scaling parameter */ + Number df_; + /** x scaling */ + SmartPtr<Vector> dx_; + //@} + + /** Scaled Matrix Spaces */ + //@{ + /** Scaled jacobian of c space */ + SmartPtr<ScaledMatrixSpace> scaled_jac_c_space_; + /** Scaled jacobian of d space */ + SmartPtr<ScaledMatrixSpace> scaled_jac_d_space_; + /** Scaled hessian of lagrangian spacea */ + SmartPtr<SymScaledMatrixSpace> scaled_h_space_; + //@} + + /** @name Algorithmic parameters */ + //@{ + /** Additional scaling value for the objective function */ + Number obj_scaling_factor_; + //@} + }; + + /** Class implementing the scaling object that doesn't to any scaling */ + class NoNLPScalingObject : public StandardScalingBase + { + public: + /**@name Constructors/Destructors */ + //@{ + NoNLPScalingObject() + {} + + /** Default destructor */ + virtual ~NoNLPScalingObject() + {} + //@} + + + protected: + /** Overloaded from StandardScalingBase */ + virtual void DetermineScalingParametersImpl( + const SmartPtr<const VectorSpace> x_space, + const SmartPtr<const VectorSpace> c_space, + const SmartPtr<const VectorSpace> d_space, + const SmartPtr<const MatrixSpace> jac_c_space, + const SmartPtr<const MatrixSpace> jac_d_space, + const SmartPtr<const SymMatrixSpace> h_space, + const Matrix& Px_L, const Vector& x_L, + const Matrix& Px_U, const Vector& x_U, + Number& df, + SmartPtr<Vector>& dx, + SmartPtr<Vector>& dc, + SmartPtr<Vector>& dd); + + private: + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + + /** Copy Constructor */ + NoNLPScalingObject(const NoNLPScalingObject&); + + /** Overloaded Equals Operator */ + void operator=(const NoNLPScalingObject&); + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpObserver.hpp b/thirdparty/linux/include/coin/IpObserver.hpp new file mode 100644 index 0000000..b16f599 --- /dev/null +++ b/thirdparty/linux/include/coin/IpObserver.hpp @@ -0,0 +1,366 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpObserver.hpp 2161 2013-01-01 20:39:05Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPOBSERVER_HPP__ +#define __IPOBSERVER_HPP__ + +#include "IpUtils.hpp" +#include <vector> +#include <algorithm> + +//#define IP_DEBUG_OBSERVER +#if COIN_IPOPT_CHECKLEVEL > 2 +# define IP_DEBUG_OBSERVER +#endif +#ifdef IP_DEBUG_OBSERVER +# include "IpDebug.hpp" +#endif + +namespace Ipopt +{ + /** Forward declarations */ + class Subject; + + /** Slight Variation of the Observer Design Pattern. + * This class implements the Observer class of the + * Observer Design Pattern. An Observer "Attach"es + * to a Subject, indicating that it would like to + * be notified of changes in the Subject. + * Any derived class wishing to recieve notifications + * from a Subject should inherit off of + * Observer and overload the protected method, + * RecieveNotification_(...). + */ + class Observer + { + public: +#ifdef IP_DEBUG_OBSERVER + + static const Index dbg_verbosity; +#endif + + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + Observer() + {} + + /** Default destructor */ + inline + virtual ~Observer(); + //@} + + /** Enumeration specifying the type of notification */ + enum NotifyType + { + NT_All, + NT_BeingDestroyed, + NT_Changed + }; + + protected: + /** Derived classes should call this method + * to request an "Attach" to a Subject. Do + * not call "Attach" explicitly on the Subject + * since further processing is done here + */ + inline + void RequestAttach(NotifyType notify_type, const Subject* subject); + + /** Derived classes should call this method + * to request a "Detach" to a Subject. Do + * not call "Detach" explicitly on the Subject + * since further processing is done here + */ + inline + void RequestDetach(NotifyType notify_type, const Subject* subject); + + /** Derived classes should overload this method to + * recieve the requested notification from + * attached Subjects + */ + virtual void RecieveNotification(NotifyType notify_type, const Subject* subject)=0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + Observer(const Observer&); + + /** Overloaded Equals Operator */ + void operator=(const Observer&); + //@} + + /** A list of the subjects currently being + * observed. */ + std::vector<const Subject*> subjects_; + + /** Private Method for Recieving Notification + * should only be called by the friend class + * Subject. This method will, in turn, call + * the overloaded RecieveNotification method + * for the derived class to process. + */ + inline + void ProcessNotification(NotifyType notify_type, const Subject* subject); + + friend class Subject; + }; + + /** Slight Variation of the Observer Design Pattern (Subject part). + * This class implements the Subject class of the Observer Design + * Pattern. An Observer "Attach"es to a Subject, indicating that it + * would like to be notified of changes in the Subject. Any + * derived class that is to be observed has to inherit off the + * Subject base class. If the subject needs to notify the + * Observer, it calls the Notify method. + */ + class Subject + { + public: +#ifdef IP_DEBUG_OBSERVER + + static const Index dbg_verbosity; +#endif + + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + Subject() + {} + + /** Default destructor */ + inline + virtual ~Subject(); + //@} + + /**@name Methods to Add and Remove Observers. + * Currently, the notify_type flags are not used, + * and Observers are attached in general and will + * recieve all notifications (of the type requested + * and possibly of types not requested). It is + * up to the observer to ignore the types they + * are not interested in. The NotifyType in the + * parameter list is so a more efficient mechanism + * depending on type could be implemented later if + * necessary.*/ + //@{ + + /** Attach the specified observer + * (i.e., begin recieving notifications). */ + inline + void AttachObserver(Observer::NotifyType notify_type, Observer* observer) const; + + /** Detach the specified observer + * (i.e., no longer recieve notifications). */ + inline + void DetachObserver(Observer::NotifyType notify_type, Observer* observer) const; + //@} + + protected: + + inline + void Notify(Observer::NotifyType notify_type) const; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + Subject(const Subject&); + + /** Overloaded Equals Operator */ + void operator=(const Subject&); + //@} + + mutable std::vector<Observer*> observers_; + + }; + + /* inline methods */ + inline + Observer::~Observer() + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Observer::~Observer", dbg_verbosity); + if (DBG_VERBOSITY()>=1) { + for (Index i=0; i<(Index)subjects_.size(); i++) { + DBG_PRINT((1,"subjects_[%d] = 0x%x\n", i, subjects_[i])); + } + } +#endif + // Detach all subjects + for (Int i=(Int)(subjects_.size()-1); i>=0; i--) { +#ifdef IP_DEBUG_OBSERVER + DBG_PRINT((1,"About to detach subjects_[%d] = 0x%x\n", i, subjects_[i])); +#endif + + RequestDetach(NT_All, subjects_[i]); + } + } + + inline + void Observer::RequestAttach(NotifyType notify_type, const Subject* subject) + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Observer::RequestAttach", dbg_verbosity); + + // Add the subject to the list if it does not already exist + std::vector<const Subject*>::iterator attached_subject; + attached_subject = std::find(subjects_.begin(), subjects_.end(), subject); + DBG_ASSERT(attached_subject == subjects_.end()); + DBG_ASSERT(subject); +#endif + + // add the subject to the list + subjects_.push_back(subject); + // Attach the observer to the subject + subject->AttachObserver(notify_type, this); + } + + inline + void Observer::RequestDetach(NotifyType notify_type, const Subject* subject) + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Observer::RequestDetach", dbg_verbosity); + DBG_PRINT((1, "Requesting detach of subject: 0x%x\n", subject)); + DBG_ASSERT(subject); +#endif + + if (subject) { + std::vector<const Subject*>::iterator attached_subject; + attached_subject = std::find(subjects_.begin(), subjects_.end(), subject); +#ifdef IP_DEBUG_OBSERVER + + DBG_ASSERT(attached_subject != subjects_.end()); +#endif + + if (attached_subject != subjects_.end()) { +#ifdef IP_DEBUG_OBSERVER + DBG_PRINT((1, "Removing subject: 0x%x from the list\n", subject)); +#endif + + subjects_.erase(attached_subject); + } + + // Detach the observer from the subject + subject->DetachObserver(notify_type, this); + } + } + + inline + void Observer::ProcessNotification(NotifyType notify_type, const Subject* subject) + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Observer::ProcessNotification", dbg_verbosity); + DBG_ASSERT(subject); +#endif + + if (subject) { + std::vector<const Subject*>::iterator attached_subject; + attached_subject = std::find(subjects_.begin(), subjects_.end(), subject); + + // We must be processing a notification for a + // subject that was previously attached. +#ifdef IP_DEBUG_OBSERVER + + DBG_ASSERT(attached_subject != subjects_.end()); +#endif + + this->RecieveNotification(notify_type, subject); + + if (notify_type == NT_BeingDestroyed) { + // the subject is going away, remove it from our list + subjects_.erase(attached_subject); + } + } + } + + inline + Subject::~Subject() + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Subject::~Subject", dbg_verbosity); +#endif + + std::vector<Observer*>::iterator iter; + for (iter = observers_.begin(); iter != observers_.end(); iter++) { + (*iter)->ProcessNotification(Observer::NT_BeingDestroyed, this); + } + } + + inline + void Subject::AttachObserver(Observer::NotifyType notify_type, Observer* observer) const + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Subject::AttachObserver", dbg_verbosity); + // current implementation notifies all observers of everything + // they must filter the notifications that they are not interested + // in (i.e. a hub, not a router) + DBG_ASSERT(observer); + + std::vector<Observer*>::iterator attached_observer; + attached_observer = std::find(observers_.begin(), observers_.end(), observer); + DBG_ASSERT(attached_observer == observers_.end()); + + DBG_ASSERT(observer); +#endif + + observers_.push_back(observer); + } + + inline + void Subject::DetachObserver(Observer::NotifyType notify_type, Observer* observer) const + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Subject::DetachObserver", dbg_verbosity); + DBG_ASSERT(observer); +#endif + + if (observer) { + std::vector<Observer*>::iterator attached_observer; + attached_observer = std::find(observers_.begin(), observers_.end(), observer); +#ifdef IP_DEBUG_OBSERVER + + DBG_ASSERT(attached_observer != observers_.end()); +#endif + + if (attached_observer != observers_.end()) { + observers_.erase(attached_observer); + } + } + } + + inline + void Subject::Notify(Observer::NotifyType notify_type) const + { +#ifdef IP_DEBUG_OBSERVER + DBG_START_METH("Subject::Notify", dbg_verbosity); +#endif + + std::vector<Observer*>::iterator iter; + for (iter = observers_.begin(); iter != observers_.end(); iter++) { + (*iter)->ProcessNotification(notify_type, this); + } + } + + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpOptionsList.hpp b/thirdparty/linux/include/coin/IpOptionsList.hpp new file mode 100644 index 0000000..382428e --- /dev/null +++ b/thirdparty/linux/include/coin/IpOptionsList.hpp @@ -0,0 +1,289 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpOptionsList.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPOPTLIST_HPP__ +#define __IPOPTLIST_HPP__ + +#include "IpUtils.hpp" +#include "IpReferenced.hpp" +#include "IpException.hpp" +#include "IpRegOptions.hpp" + +#include <iostream> +#include <map> + +namespace Ipopt +{ + /** Exception that can be used to indicate errors with options */ + DECLARE_STD_EXCEPTION(OPTION_INVALID); + + /** This class stores a list of user set options. Each options is + * identified by a case-insensitive keyword (tag). Its value is + * stored internally as a string (always lower case), but for + * convenience set and get methods are provided to obtain Index and + * Number type values. For each keyword we also keep track of how + * often the value of an option has been requested by a get method. + */ + class OptionsList : public ReferencedObject + { + /** Class for storing the value and counter for each option in + * OptionsList. */ + class OptionValue + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor (needed for the map) */ + OptionValue() + : + initialized_(false) + {} + + /** Constructor given the value */ + OptionValue(std::string value, bool allow_clobber, bool dont_print) + : + value_(value), + counter_(0), + initialized_(true), + allow_clobber_(allow_clobber), + dont_print_(dont_print) + {} + + /** Copy Constructor */ + OptionValue(const OptionValue& copy) + : + value_(copy.value_), + counter_(copy.counter_), + initialized_(copy.initialized_), + allow_clobber_(copy.allow_clobber_), + dont_print_(copy.dont_print_) + {} + + /** Equals operator */ + void operator=(const OptionValue& copy) + { + value_=copy.value_; + counter_=copy.counter_; + initialized_=copy.initialized_; + allow_clobber_=copy.allow_clobber_; + dont_print_=copy.dont_print_; + } + + /** Default Destructor */ + ~OptionValue() + {} + //@} + + /** Method for retrieving the value of an option. Calling this + * method will increase the counter by one. */ + std::string GetValue() const + { + DBG_ASSERT(initialized_); + counter_++; + return value_; + } + + /** Method for retrieving the value without increasing the + * counter */ + std::string Value() const + { + DBG_ASSERT(initialized_); + return value_; + } + + /** Method for accessing current value of the request counter */ + Index Counter() const + { + DBG_ASSERT(initialized_); + return counter_; + } + + /** True if the option can be overwritten */ + bool AllowClobber() const + { + DBG_ASSERT(initialized_); + return allow_clobber_; + } + + /** True if this option is not to show up in the + * print_user_options output */ + bool DontPrint() const + { + DBG_ASSERT(initialized_); + return dont_print_; + } + + private: + /** Value for this option */ + std::string value_; + + /** Counter for requests */ + mutable Index counter_; + + /** for debugging */ + bool initialized_; + + /** True if the option can be overwritten */ + bool allow_clobber_; + + /** True if this option is not to show up in the + * print_user_options output */ + bool dont_print_; + }; + + public: + /**@name Constructors/Destructors */ + //@{ + OptionsList(SmartPtr<RegisteredOptions> reg_options, SmartPtr<Journalist> jnlst) + : reg_options_(reg_options), jnlst_(jnlst) + {} + + OptionsList() + {} + + /** Copy Constructor */ + OptionsList(const OptionsList& copy) + { + // copy all the option strings and values + options_ = copy.options_; + // copy the registered options pointer + reg_options_ = copy.reg_options_; + } + + /** Default destructor */ + virtual ~OptionsList() + {} + + /** Overloaded Equals Operator */ + virtual void operator=(const OptionsList& source) + { + options_ = source.options_; + reg_options_ = source.reg_options_; + jnlst_ = source.jnlst_; + } + //@} + + /** Method for clearing all previously set options */ + virtual void clear() + { + options_.clear(); + } + + /** @name Get / Set Methods */ + //@{ + virtual void SetRegisteredOptions(const SmartPtr<RegisteredOptions> reg_options) + { + reg_options_ = reg_options; + } + virtual void SetJournalist(const SmartPtr<Journalist> jnlst) + { + jnlst_ = jnlst; + } + //@} + /** @name Methods for setting options */ + //@{ + virtual bool SetStringValue(const std::string& tag, const std::string& value, + bool allow_clobber = true, bool dont_print = false); + virtual bool SetNumericValue(const std::string& tag, Number value, + bool allow_clobber = true, bool dont_print = false); + virtual bool SetIntegerValue(const std::string& tag, Index value, + bool allow_clobber = true, bool dont_print = false); + //@} + + /** @name Methods for setting options only if they have not been + * set before*/ + //@{ + virtual bool SetStringValueIfUnset(const std::string& tag, const std::string& value, + bool allow_clobber = true, bool dont_print = false); + virtual bool SetNumericValueIfUnset(const std::string& tag, Number value, + bool allow_clobber = true, bool dont_print = false); + virtual bool SetIntegerValueIfUnset(const std::string& tag, Index value, + bool allow_clobber = true, bool dont_print = false); + //@} + + /** @name Methods for retrieving values from the options list. If + * a tag is not found, the methods return false, and value is set + * to the default value defined in the registered options. */ + //@{ + virtual bool GetStringValue(const std::string& tag, std::string& value, + const std::string& prefix) const; + virtual bool GetEnumValue(const std::string& tag, Index& value, + const std::string& prefix) const; + virtual bool GetBoolValue(const std::string& tag, bool& value, + const std::string& prefix) const; + virtual bool GetNumericValue(const std::string& tag, Number& value, + const std::string& prefix) const; + virtual bool GetIntegerValue(const std::string& tag, Index& value, + const std::string& prefix) const; + //@} + + /** Get a string with the list of all options (tag, value, counter) */ + virtual void PrintList(std::string& list) const; + + /** Get a string with the list of all options set by the user + * (tag, value, use/notused). Here, options with dont_print flag + * set to true are not printed. */ + virtual void PrintUserOptions(std::string& list) const; + + /** Read options from the stream is. Returns false if + * an error was encountered. */ + virtual bool ReadFromStream(const Journalist& jnlst, std::istream& is); + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + // OptionsList(); + + //@} + + /** map for storing the options */ + std::map< std::string, OptionValue > options_; + + /** list of all the registered options to validate against */ + SmartPtr<RegisteredOptions> reg_options_; + + /** Journalist for writing error messages, etc. */ + SmartPtr<Journalist> jnlst_; + + /** auxilliary method for converting sting to all lower-case + * letters */ + const std::string& lowercase(const std::string tag) const; + + /** auxilliary method for finding the value for a tag in the + * options list. This method first looks for the concatenated + * string prefix+tag (if prefix is not ""), and if this is not + * found, it looks for tag. The return value is true iff + * prefix+tag or tag is found. In that case, the corresponding + * string value is copied into value. */ + bool find_tag(const std::string& tag, const std::string& prefix, + std::string& value) const; + + /** tells whether or not we can clobber a particular option. + * returns true if the option does not already exist, or if + * the option exists but is set to allow_clobber + */ + bool will_allow_clobber(const std::string& tag) const; + + /** read the next token from stream is. Returns false, if EOF was + * reached before a tokens was ecountered. */ + bool readnexttoken(std::istream& is, std::string& token); + + /** auxilliary string set by lowercase method */ + mutable std::string lowercase_buffer_; + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpOrigIpoptNLP.hpp b/thirdparty/linux/include/coin/IpOrigIpoptNLP.hpp new file mode 100644 index 0000000..41b10fa --- /dev/null +++ b/thirdparty/linux/include/coin/IpOrigIpoptNLP.hpp @@ -0,0 +1,488 @@ +// Copyright (C) 2004, 2010 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpOrigIpoptNLP.hpp 2594 2015-08-09 14:31:05Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPORIGIPOPTNLP_HPP__ +#define __IPORIGIPOPTNLP_HPP__ + +#include "IpIpoptNLP.hpp" +#include "IpException.hpp" +#include "IpTimingStatistics.hpp" + +namespace Ipopt +{ + + /** enumeration for the Hessian information type. */ + enum HessianApproximationType { + EXACT=0, + LIMITED_MEMORY + }; + + /** enumeration for the Hessian approximation space. */ + enum HessianApproximationSpace { + NONLINEAR_VARS=0, + ALL_VARS + }; + + /** This class maps the traditional NLP into + * something that is more useful by Ipopt. + * This class takes care of storing the + * calculated model results, handles caching, + * and (some day) takes care of addition of slacks. + */ + class OrigIpoptNLP : public IpoptNLP + { + public: + /**@name Constructors/Destructors */ + //@{ + OrigIpoptNLP(const SmartPtr<const Journalist>& jnlst, + const SmartPtr<NLP>& nlp, + const SmartPtr<NLPScalingObject>& nlp_scaling); + + /** Default destructor */ + virtual ~OrigIpoptNLP(); + //@} + + /** Initialize - overloaded from IpoptNLP */ + virtual bool Initialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Initialize (create) structures for + * the iteration data */ + virtual bool InitializeStructures(SmartPtr<Vector>& x, + bool init_x, + SmartPtr<Vector>& y_c, + bool init_y_c, + SmartPtr<Vector>& y_d, + bool init_y_d, + SmartPtr<Vector>& z_L, + bool init_z_L, + SmartPtr<Vector>& z_U, + bool init_z_U, + SmartPtr<Vector>& v_L, + SmartPtr<Vector>& v_U + ); + + /** Method accessing the GetWarmStartIterate of the NLP */ + virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate) + { + return nlp_->GetWarmStartIterate(warm_start_iterate); + } + /** Accessor methods for model data */ + //@{ + /** Objective value */ + virtual Number f(const Vector& x); + + /** Objective value (depending in mu) - incorrect version for + * OrigIpoptNLP */ + virtual Number f(const Vector& x, Number mu); + + /** Gradient of the objective */ + virtual SmartPtr<const Vector> grad_f(const Vector& x); + + /** Gradient of the objective (depending in mu) - incorrect + * version for OrigIpoptNLP */ + virtual SmartPtr<const Vector> grad_f(const Vector& x, Number mu); + + /** Equality constraint residual */ + virtual SmartPtr<const Vector> c(const Vector& x); + + /** Jacobian Matrix for equality constraints */ + virtual SmartPtr<const Matrix> jac_c(const Vector& x); + + /** Inequality constraint residual (reformulated + * as equalities with slacks */ + virtual SmartPtr<const Vector> d(const Vector& x); + + /** Jacobian Matrix for inequality constraints*/ + virtual SmartPtr<const Matrix> jac_d(const Vector& x); + + /** Hessian of the Lagrangian */ + virtual SmartPtr<const SymMatrix> h(const Vector& x, + Number obj_factor, + const Vector& yc, + const Vector& yd + ); + + /** Hessian of the Lagrangian (depending in mu) - incorrect + * version for OrigIpoptNLP */ + virtual SmartPtr<const SymMatrix> h(const Vector& x, + Number obj_factor, + const Vector& yc, + const Vector& yd, + Number mu); + + /** Provides a Hessian matrix from the correct matrix space with + * uninitialized values. This can be used in LeastSquareMults to + * obtain a "zero Hessian". */ + virtual SmartPtr<const SymMatrix> uninitialized_h(); + + /** Lower bounds on x */ + virtual SmartPtr<const Vector> x_L() const + { + return x_L_; + } + + /** Permutation matrix (x_L_ -> x) */ + virtual SmartPtr<const Matrix> Px_L() const + { + return Px_L_; + } + + /** Upper bounds on x */ + virtual SmartPtr<const Vector> x_U() const + { + return x_U_; + } + + /** Permutation matrix (x_U_ -> x */ + virtual SmartPtr<const Matrix> Px_U() const + { + return Px_U_; + } + + /** Lower bounds on d */ + virtual SmartPtr<const Vector> d_L() const + { + return d_L_; + } + + /** Permutation matrix (d_L_ -> d) */ + virtual SmartPtr<const Matrix> Pd_L() const + { + return Pd_L_; + } + + /** Upper bounds on d */ + virtual SmartPtr<const Vector> d_U() const + { + return d_U_; + } + + /** Permutation matrix (d_U_ -> d */ + virtual SmartPtr<const Matrix> Pd_U() const + { + return Pd_U_; + } + + virtual SmartPtr<const SymMatrixSpace> HessianMatrixSpace() const + { + return h_space_; + } + + virtual SmartPtr<const VectorSpace> x_space() const + { + return x_space_; + } + //@} + + /** Accessor method for vector/matrix spaces pointers */ + virtual void GetSpaces(SmartPtr<const VectorSpace>& x_space, + SmartPtr<const VectorSpace>& c_space, + SmartPtr<const VectorSpace>& d_space, + SmartPtr<const VectorSpace>& x_l_space, + SmartPtr<const MatrixSpace>& px_l_space, + SmartPtr<const VectorSpace>& x_u_space, + SmartPtr<const MatrixSpace>& px_u_space, + SmartPtr<const VectorSpace>& d_l_space, + SmartPtr<const MatrixSpace>& pd_l_space, + SmartPtr<const VectorSpace>& d_u_space, + SmartPtr<const MatrixSpace>& pd_u_space, + SmartPtr<const MatrixSpace>& Jac_c_space, + SmartPtr<const MatrixSpace>& Jac_d_space, + SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space); + + /** Method for adapting the variable bounds. This is called if + * slacks are becoming too small */ + virtual void AdjustVariableBounds(const Vector& new_x_L, + const Vector& new_x_U, + const Vector& new_d_L, + const Vector& new_d_U); + + /** @name Counters for the number of function evaluations. */ + //@{ + virtual Index f_evals() const + { + return f_evals_; + } + virtual Index grad_f_evals() const + { + return grad_f_evals_; + } + virtual Index c_evals() const + { + return c_evals_; + } + virtual Index jac_c_evals() const + { + return jac_c_evals_; + } + virtual Index d_evals() const + { + return d_evals_; + } + virtual Index jac_d_evals() const + { + return jac_d_evals_; + } + virtual Index h_evals() const + { + return h_evals_; + } + //@} + + /** Solution Routines - overloaded from IpoptNLP*/ + //@{ + void FinalizeSolution(SolverReturn status, + const Vector& x, const Vector& z_L, const Vector& z_U, + const Vector& c, const Vector& d, + const Vector& y_c, const Vector& y_d, + Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq); + bool IntermediateCallBack(AlgorithmMode mode, + Index iter, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, + SmartPtr<const IpoptData> ip_data, + SmartPtr<IpoptCalculatedQuantities> ip_cq); + //@} + + /** @name Methods for IpoptType */ + //@{ + /** Called by IpoptType to register the options */ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + /** Accessor method to the underlying NLP */ + SmartPtr<NLP> nlp() + { + return nlp_; + } + + /**@name Methods related to function evaluation timing. */ + //@{ + + /** Reset the timing statistics */ + void ResetTimes(); + + void PrintTimingStatistics(Journalist& jnlst, + EJournalLevel level, + EJournalCategory category) const; + + const TimedTask& f_eval_time() const + { + return f_eval_time_; + } + const TimedTask& grad_f_eval_time() const + { + return grad_f_eval_time_; + } + const TimedTask& c_eval_time() const + { + return c_eval_time_; + } + const TimedTask& jac_c_eval_time() const + { + return jac_c_eval_time_; + } + const TimedTask& d_eval_time() const + { + return d_eval_time_; + } + const TimedTask& jac_d_eval_time() const + { + return jac_d_eval_time_; + } + const TimedTask& h_eval_time() const + { + return h_eval_time_; + } + + Number TotalFunctionEvaluationCpuTime() const; + Number TotalFunctionEvaluationSysTime() const; + Number TotalFunctionEvaluationWallclockTime() const; + //@} + + private: + /** journalist */ + SmartPtr<const Journalist> jnlst_; + + /** Pointer to the NLP */ + SmartPtr<NLP> nlp_; + + /** Necessary Vector/Matrix spaces */ + //@{ + SmartPtr<const VectorSpace> x_space_; + SmartPtr<const VectorSpace> c_space_; + SmartPtr<const VectorSpace> d_space_; + SmartPtr<const VectorSpace> x_l_space_; + SmartPtr<const MatrixSpace> px_l_space_; + SmartPtr<const VectorSpace> x_u_space_; + SmartPtr<const MatrixSpace> px_u_space_; + SmartPtr<const VectorSpace> d_l_space_; + SmartPtr<const MatrixSpace> pd_l_space_; + SmartPtr<const VectorSpace> d_u_space_; + SmartPtr<const MatrixSpace> pd_u_space_; + SmartPtr<const MatrixSpace> jac_c_space_; + SmartPtr<const MatrixSpace> jac_d_space_; + SmartPtr<const SymMatrixSpace> h_space_; + + SmartPtr<const MatrixSpace> scaled_jac_c_space_; + SmartPtr<const MatrixSpace> scaled_jac_d_space_; + SmartPtr<const SymMatrixSpace> scaled_h_space_; + //@} + /**@name Storage for Model Quantities */ + //@{ + /** Objective function */ + CachedResults<Number> f_cache_; + + /** Gradient of the objective function */ + CachedResults<SmartPtr<const Vector> > grad_f_cache_; + + /** Equality constraint residuals */ + CachedResults<SmartPtr<const Vector> > c_cache_; + + /** Jacobian Matrix for equality constraints + * (current iteration) */ + CachedResults<SmartPtr<const Matrix> > jac_c_cache_; + + /** Inequality constraint residual (reformulated + * as equalities with slacks */ + CachedResults<SmartPtr<const Vector> > d_cache_; + + /** Jacobian Matrix for inequality constraints + * (current iteration) */ + CachedResults<SmartPtr<const Matrix> > jac_d_cache_; + + /** Hessian of the lagrangian + * (current iteration) */ + CachedResults<SmartPtr<const SymMatrix> > h_cache_; + + /** Unscaled version of x vector */ + CachedResults<SmartPtr<const Vector> > unscaled_x_cache_; + + /** Lower bounds on x */ + SmartPtr<const Vector> x_L_; + + /** Permutation matrix (x_L_ -> x) */ + SmartPtr<const Matrix> Px_L_; + + /** Upper bounds on x */ + SmartPtr<const Vector> x_U_; + + /** Permutation matrix (x_U_ -> x */ + SmartPtr<const Matrix> Px_U_; + + /** Lower bounds on d */ + SmartPtr<const Vector> d_L_; + + /** Permutation matrix (d_L_ -> d) */ + SmartPtr<const Matrix> Pd_L_; + + /** Upper bounds on d */ + SmartPtr<const Vector> d_U_; + + /** Permutation matrix (d_U_ -> d */ + SmartPtr<const Matrix> Pd_U_; + + /** Original unmodified lower bounds on x */ + SmartPtr<const Vector> orig_x_L_; + + /** Original unmodified upper bounds on x */ + SmartPtr<const Vector> orig_x_U_; + //@} + + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + OrigIpoptNLP(); + + /** Copy Constructor */ + OrigIpoptNLP(const OrigIpoptNLP&); + + /** Overloaded Equals Operator */ + void operator=(const OrigIpoptNLP&); + //@} + + /** @name auxilliary functions */ + //@{ + /** relax the bounds by a relative move of relax_bound_factor. + * Here, relax_bound_factor should be negative (or zero) for + * lower bounds, and positive (or zero) for upper bounds. + */ + void relax_bounds(Number bound_relax_factor, Vector& bounds); + /** Method for getting the unscaled version of the x vector */ + SmartPtr<const Vector> get_unscaled_x(const Vector& x); + //@} + + /** @name Algorithmic parameters */ + //@{ + /** relaxation factor for the bounds */ + Number bound_relax_factor_; + /** Flag indicating whether the primal variables should be + * projected back into original bounds are optimization. */ + bool honor_original_bounds_; + /** Flag indicating whether the TNLP with identical structure has + * already been solved before. */ + bool warm_start_same_structure_; + /** Flag indicating what Hessian information is to be used. */ + HessianApproximationType hessian_approximation_; + /** Flag indicating in which space Hessian is to be approximated. */ + HessianApproximationSpace hessian_approximation_space_; + /** Flag indicating whether it is desired to check if there are + * Nan or Inf entries in first and second derivative matrices. */ + bool check_derivatives_for_naninf_; + /** Flag indicating if we need to ask for equality constraint + * Jacobians only once */ + bool jac_c_constant_; + /** Flag indicating if we need to ask for inequality constraint + * Jacobians only once */ + bool jac_d_constant_; + /** Flag indicating if we need to ask for Hessian only once */ + bool hessian_constant_; + //@} + + /** @name Counters for the function evaluations */ + //@{ + Index f_evals_; + Index grad_f_evals_; + Index c_evals_; + Index jac_c_evals_; + Index d_evals_; + Index jac_d_evals_; + Index h_evals_; + //@} + + /** Flag indicating if initialization method has been called */ + bool initialized_; + + /**@name Timing statistics for the function evaluations. */ + //@{ + TimedTask f_eval_time_; + TimedTask grad_f_eval_time_; + TimedTask c_eval_time_; + TimedTask jac_c_eval_time_; + TimedTask d_eval_time_; + TimedTask jac_d_eval_time_; + TimedTask h_eval_time_; + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpReferenced.hpp b/thirdparty/linux/include/coin/IpReferenced.hpp new file mode 100644 index 0000000..996beda --- /dev/null +++ b/thirdparty/linux/include/coin/IpReferenced.hpp @@ -0,0 +1,258 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpReferenced.hpp 2182 2013-03-30 20:02:18Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPREFERENCED_HPP__ +#define __IPREFERENCED_HPP__ + +#include "IpTypes.hpp" +#include "IpDebug.hpp" + +#include <list> + +#if COIN_IPOPT_CHECKLEVEL > 3 + #define IP_DEBUG_REFERENCED +#endif + +namespace Ipopt +{ + + /** Psydo-class, from which everything has to inherit that wants to + * use be registered as a Referencer for a ReferencedObject. + */ + class Referencer + {} + ; + + /** ReferencedObject class. + * This is part of the implementation of an intrusive smart pointer + * design. This class stores the reference count of all the smart + * pointers that currently reference it. See the documentation for + * the SmartPtr class for more details. + * + * A SmartPtr behaves much like a raw pointer, but manages the lifetime + * of an object, deleting the object automatically. This class implements + * a reference-counting, intrusive smart pointer design, where all + * objects pointed to must inherit off of ReferencedObject, which + * stores the reference count. Although this is intrusive (native types + * and externally authored classes require wrappers to be referenced + * by smart pointers), it is a safer design. A more detailed discussion of + * these issues follows after the usage information. + * + * Usage Example: + * Note: to use the SmartPtr, all objects to which you point MUST + * inherit off of ReferencedObject. + * + * \verbatim + * + * In MyClass.hpp... + * + * #include "IpReferenced.hpp" + + * namespace Ipopt { + * + * class MyClass : public ReferencedObject // must derive from ReferencedObject + * { + * ... + * } + * } // namespace Ipopt + * + * + * In my_usage.cpp... + * + * #include "IpSmartPtr.hpp" + * #include "MyClass.hpp" + * + * void func(AnyObject& obj) + * { + * SmartPtr<MyClass> ptr_to_myclass = new MyClass(...); + * // ptr_to_myclass now points to a new MyClass, + * // and the reference count is 1 + * + * ... + * + * obj.SetMyClass(ptr_to_myclass); + * // Here, let's assume that AnyObject uses a + * // SmartPtr<MyClass> internally here. + * // Now, both ptr_to_myclass and the internal + * // SmartPtr in obj point to the same MyClass object + * // and its reference count is 2. + * + * ... + * + * // No need to delete ptr_to_myclass, this + * // will be done automatically when the + * // reference count drops to zero. + * + * } + * + * \endverbatim + * + * Other Notes: + * The SmartPtr implements both dereference operators -> & *. + * The SmartPtr does NOT implement a conversion operator to + * the raw pointer. Use the GetRawPtr() method when this + * is necessary. Make sure that the raw pointer is NOT + * deleted. + * The SmartPtr implements the comparison operators == & != + * for a variety of types. Use these instead of + * \verbatim + * if (GetRawPtr(smrt_ptr) == ptr) // Don't use this + * \endverbatim + * SmartPtr's, as currently implemented, do NOT handle circular references. + * For example: consider a higher level object using SmartPtrs to point to + * A and B, but A and B also point to each other (i.e. A has a SmartPtr + * to B and B has a SmartPtr to A). In this scenario, when the higher + * level object is finished with A and B, their reference counts will + * never drop to zero (since they reference each other) and they + * will not be deleted. This can be detected by memory leak tools like + * valgrind. If the circular reference is necessary, the problem can be + * overcome by a number of techniques: + * + * 1) A and B can have a method that "releases" each other, that is + * they set their internal SmartPtrs to NULL. + * \verbatim + * void AClass::ReleaseCircularReferences() + * { + * smart_ptr_to_B = NULL; + * } + * \endverbatim + * Then, the higher level class can call these methods before + * it is done using A & B. + * + * 2) Raw pointers can be used in A and B to reference each other. + * Here, an implicit assumption is made that the lifetime is + * controlled by the higher level object and that A and B will + * both exist in a controlled manner. Although this seems + * dangerous, in many situations, this type of referencing + * is very controlled and this is reasonably safe. + * + * 3) This SmartPtr class could be redesigned with the Weak/Strong + * design concept. Here, the SmartPtr is identified as being + * Strong (controls lifetime of the object) or Weak (merely + * referencing the object). The Strong SmartPtr increments + * (and decrements) the reference count in ReferencedObject + * but the Weak SmartPtr does not. In the example above, + * the higher level object would have Strong SmartPtrs to + * A and B, but A and B would have Weak SmartPtrs to each + * other. Then, when the higher level object was done with + * A and B, they would be deleted. The Weak SmartPtrs in A + * and B would not decrement the reference count and would, + * of course, not delete the object. This idea is very similar + * to item (2), where it is implied that the sequence of events + * is controlled such that A and B will not call anything using + * their pointers following the higher level delete (i.e. in + * their destructors!). This is somehow safer, however, because + * code can be written (however expensive) to perform run-time + * detection of this situation. For example, the ReferencedObject + * could store pointers to all Weak SmartPtrs that are referencing + * it and, in its destructor, tell these pointers that it is + * dying. They could then set themselves to NULL, or set an + * internal flag to detect usage past this point. + * + * For every most derived object only one ReferencedObject may exist, + * that is multiple inheritance requires virtual inheritance, see also + * the 2nd point in ticket #162. + * + * Comments on Non-Intrusive Design: + * In a non-intrusive design, the reference count is stored somewhere other + * than the object being referenced. This means, unless the reference + * counting pointer is the first referencer, it must get a pointer to the + * referenced object from another smart pointer (so it has access to the + * reference count location). In this non-intrusive design, if we are + * pointing to an object with a smart pointer (or a number of smart + * pointers), and we then give another smart pointer the address through + * a RAW pointer, we will have two independent, AND INCORRECT, reference + * counts. To avoid this pitfall, we use an intrusive reference counting + * technique where the reference count is stored in the object being + * referenced. + */ + class ReferencedObject + { + public: + ReferencedObject() + : + reference_count_(0) + {} + + virtual ~ReferencedObject() + { + DBG_ASSERT(reference_count_ == 0); + } + + inline + Index ReferenceCount() const; + + inline + void AddRef(const Referencer* referencer) const; + + inline + void ReleaseRef(const Referencer* referencer) const; + + private: + mutable Index reference_count_; + +# ifdef IP_DEBUG_REFERENCED + mutable std::list<const Referencer*> referencers_; +# endif + + }; + + /* inline methods */ + inline + Index ReferencedObject::ReferenceCount() const + { + // DBG_START_METH("ReferencedObject::ReferenceCount()", 0); + // DBG_PRINT((1,"Returning reference_count_ = %d\n", reference_count_)); + return reference_count_; + } + + inline + void ReferencedObject::AddRef(const Referencer* referencer) const + { + // DBG_START_METH("ReferencedObject::AddRef(const Referencer* referencer)", 0); + reference_count_++; + // DBG_PRINT((1, "New reference_count_ = %d\n", reference_count_)); +# ifdef IP_DEBUG_REFERENCED + referencers_.push_back(referencer); +# endif + + } + + inline + void ReferencedObject::ReleaseRef(const Referencer* referencer) const + { + // DBG_START_METH("ReferencedObject::ReleaseRef(const Referencer* referencer)", + // 0); + reference_count_--; + // DBG_PRINT((1, "New reference_count_ = %d\n", reference_count_)); + +# ifdef IP_DEBUG_REFERENCED + + bool found = false; + std::list<const Referencer*>::iterator iter; + for (iter = referencers_.begin(); iter != referencers_.end(); iter++) { + if ((*iter) == referencer) { + found = true; + break; + } + } + + // cannot call release on a reference that was never added... + DBG_ASSERT(found); + + if (found) { + referencers_.erase(iter); + } +# endif + + } + + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpRegOptions.hpp b/thirdparty/linux/include/coin/IpRegOptions.hpp new file mode 100644 index 0000000..5859493 --- /dev/null +++ b/thirdparty/linux/include/coin/IpRegOptions.hpp @@ -0,0 +1,658 @@ +// Copyright (C) 2004, 2007 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpRegOptions.hpp 2189 2013-03-31 15:06:11Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2005-06-18 + +#ifndef __IPREGOPTIONS_HPP__ +#define __IPREGOPTIONS_HPP__ + +#include "IpUtils.hpp" +#include "IpReferenced.hpp" +#include "IpException.hpp" +#include "IpSmartPtr.hpp" + +#include <map> + +namespace Ipopt +{ + + enum RegisteredOptionType + { + OT_Number, + OT_Integer, + OT_String, + OT_Unknown + }; + + /** Base class for registered options. The derived types are more + * specific to a string option or a Number (real) option, etc. + */ + class RegisteredOption : public ReferencedObject + { + public: + /** class to hold the valid string settings for a string option */ + class string_entry + { + public: + string_entry(const std::string& value, const std::string& description) + : value_(value), description_(description) + {} + std::string value_; + std::string description_; + }; + + /** Constructors / Destructors */ + //@{ + RegisteredOption(Index counter) + : + type_(OT_Unknown), + has_lower_(false), + has_upper_(false), + counter_(counter) + {} + + RegisteredOption(const std::string& name, + const std::string& short_description, + const std::string& long_description, + const std::string& registering_category, + Index counter) + : + name_(name), + short_description_(short_description), + long_description_(long_description), + registering_category_(registering_category), + type_(OT_Unknown), + has_lower_(false), + has_upper_(false), + counter_(counter) + {} + + RegisteredOption(const RegisteredOption& copy) + : + name_(copy.name_), + short_description_(copy.short_description_), + long_description_(copy.long_description_), + registering_category_(copy.registering_category_), + type_(copy.type_), + has_lower_(copy.has_lower_), + lower_(copy.lower_), + has_upper_(copy.has_upper_), + upper_(copy.upper_), + valid_strings_(copy.valid_strings_), + counter_(copy.counter_) + {} + + virtual ~RegisteredOption() + {} + //@} + + DECLARE_STD_EXCEPTION(ERROR_CONVERTING_STRING_TO_ENUM); + + /** Standard Get / Set Methods */ + //@{ + /** Get the option's name (tag in the input file) */ + virtual const std::string& Name() const + { + return name_; + } + /** Set the option's name (tag in the input file) */ + virtual void SetName(const std::string& name) + { + name_ = name; + } + /** Get the short description */ + virtual const std::string& ShortDescription() const + { + return short_description_; + } + /** Get the long description */ + virtual const std::string& LongDescription() const + { + return long_description_; + } + /** Set the short description */ + virtual void SetShortDescription(const std::string& short_description) + { + short_description_ = short_description; + } + /** Set the long description */ + virtual void SetLongDescription(const std::string& long_description) + { + long_description_ = long_description; + } + /** Get the registering class */ + virtual const std::string& RegisteringCategory() const + { + return registering_category_; + } + /** Set the registering class */ + virtual void SetRegisteringCategory(const std::string& registering_category) + { + registering_category_ = registering_category; + } + /** Get the Option's type */ + virtual const RegisteredOptionType& Type() const + { + return type_; + } + /** Get the Option's type */ + virtual void SetType(const RegisteredOptionType& type) + { + type_ = type; + } + /** Counter */ + virtual Index Counter() const + { + return counter_; + } + //@} + + /** @name Get / Set methods valid for specific types - NOTE: the Type + * must be set before calling these methods. + */ + //@{ + /** check if the option has a lower bound - can be called for + * OT_Number & OT_Integer*/ + virtual const bool& HasLower() const + { + DBG_ASSERT(type_ == OT_Number || type_ == OT_Integer); + return has_lower_; + } + /** check if the lower bound is strict - can be called for + OT_Number */ + virtual const bool& LowerStrict() const + { + DBG_ASSERT(type_ == OT_Number && has_lower_ == true); + return lower_strict_; + } + /** get the Number version of the lower bound - can be called for + * OT_Number */ + virtual Number LowerNumber() const + { + DBG_ASSERT(has_lower_ == true && type_ == OT_Number); + return lower_; + } + /** set the Number version of the lower bound - can be called for + * OT_Number */ + virtual void SetLowerNumber(const Number& lower, const bool& strict) + { + DBG_ASSERT(type_ == OT_Number); + lower_ = lower; + lower_strict_ = strict, has_lower_ = true; + } + /** get the Integer version of the lower bound can be called for + * OT_Integer*/ + virtual Index LowerInteger() const + { + DBG_ASSERT(has_lower_ == true && type_ == OT_Integer); + return (Index)lower_; + } + /** set the Integer version of the lower bound - can be called for + * OT_Integer */ + virtual void SetLowerInteger(const Index& lower) + { + DBG_ASSERT(type_ == OT_Integer); + lower_ = (Number)lower; + has_lower_ = true; + } + /** check if the option has an upper bound - can be called for + * OT_Number & OT_Integer*/ + virtual const bool& HasUpper() const + { + DBG_ASSERT(type_ == OT_Number || type_ == OT_Integer); + return has_upper_; + } + /** check if the upper bound is strict - can be called for + * OT_Number */ + virtual const bool& UpperStrict() const + { + DBG_ASSERT(type_ == OT_Number && has_upper_ == true); + return upper_strict_; + } + /** get the Number version of the upper bound - can be called for + * OT_Number */ + virtual Number UpperNumber() const + { + DBG_ASSERT(has_upper_ == true && type_ == OT_Number); + return upper_; + } + /** set the Number version of the upper bound - can be called for + * OT_Number */ + virtual void SetUpperNumber(const Number& upper, const bool& strict) + { + DBG_ASSERT(type_ == OT_Number); + upper_ = upper; + upper_strict_ = strict; + has_upper_ = true; + } + /** get the Integer version of the upper bound - can be called for + * OT_Integer*/ + virtual Index UpperInteger() const + { + DBG_ASSERT(has_upper_ == true && type_ == OT_Integer); + return (Index)upper_; + } + /** set the Integer version of the upper bound - can be called for + * OT_Integer */ + virtual void SetUpperInteger(const Index& upper) + { + DBG_ASSERT(type_ == OT_Integer); + upper_ = (Number)upper; + has_upper_ = true; + } + /** method to add valid string entries - can be called for + * OT_String */ + virtual void AddValidStringSetting(const std::string value, + const std::string description) + { + DBG_ASSERT(type_ == OT_String); + valid_strings_.push_back(string_entry(value, description)); + } + /** get the default as a Number - can be called for OT_Number */ + virtual Number DefaultNumber() const + { + DBG_ASSERT(type_ == OT_Number); + return default_number_; + } + /** Set the default as a Number - can be called for OT_Number */ + virtual void SetDefaultNumber(const Number& default_value) + { + DBG_ASSERT(type_ == OT_Number); + default_number_ = default_value; + } + /** get the default as an Integer - can be called for OT_Integer*/ + virtual Index DefaultInteger() const + { + DBG_ASSERT(type_ == OT_Integer); + return (Index)default_number_; + } + /** Set the default as an Integer - can be called for + OT_Integer */ + virtual void SetDefaultInteger(const Index& default_value) + { + DBG_ASSERT(type_ == OT_Integer); + default_number_ = (Number)default_value; + } + /** get the default as a string - can be called for OT_String */ + virtual std::string DefaultString() const + { + DBG_ASSERT(type_ == OT_String); + return default_string_; + } + /** get the default as a string, but as the index of the string in + * the list - helps map from a string to an enum- can be called + * for OT_String */ + virtual Index DefaultStringAsEnum() const + { + DBG_ASSERT(type_ == OT_String); + return MapStringSettingToEnum(default_string_); + } + /** Set the default as a string - can be called for OT_String */ + virtual void SetDefaultString(const std::string& default_value) + { + DBG_ASSERT(type_ == OT_String); + default_string_ = default_value; + } + /** get the valid string settings - can be called for OT_String */ + virtual std::vector<string_entry> GetValidStrings() const + { + DBG_ASSERT(type_ == OT_String); + return valid_strings_; + } + /** Check if the Number value is a valid setting - can be called + * for OT_Number */ + virtual bool IsValidNumberSetting(const Number& value) const + { + DBG_ASSERT(type_ == OT_Number); + if (has_lower_ && ((lower_strict_ == true && value <= lower_) || + (lower_strict_ == false && value < lower_))) { + return false; + } + if (has_upper_ && ((upper_strict_ == true && value >= upper_) || + (upper_strict_ == false && value > upper_))) { + return false; + } + return true; + } + /** Check if the Integer value is a valid setting - can be called + * for OT_Integer */ + virtual bool IsValidIntegerSetting(const Index& value) const + { + DBG_ASSERT(type_ == OT_Integer); + if (has_lower_ && value < lower_) { + return false; + } + if (has_upper_ && value > upper_) { + return false; + } + return true; + } + /** Check if the String value is a valid setting - can be called + * for OT_String */ + virtual bool IsValidStringSetting(const std::string& value) const; + + /** Map a user setting (allowing any case) to the case used when + * the setting was registered. + */ + virtual std::string MapStringSetting(const std::string& value) const; + + /** Map a user setting (allowing any case) to the index of the + * matched setting in the list of string settings. Helps map a + * string setting to an enumeration. + */ + virtual Index MapStringSettingToEnum(const std::string& value) const; + //@} + + /** output a description of the option */ + virtual void OutputDescription(const Journalist& jnlst) const; + /** output a more concise version */ + virtual void OutputShortDescription(const Journalist& jnlst) const; + /** output a latex version */ + virtual void OutputLatexDescription(const Journalist& jnlst) const; + + private: + std::string name_; + std::string short_description_; + std::string long_description_; + std::string registering_category_; + RegisteredOptionType type_; + + bool has_lower_; + bool lower_strict_; + Number lower_; + bool has_upper_; + bool upper_strict_; + Number upper_; + Number default_number_; + + void MakeValidLatexString(std::string source, std::string& dest) const; + std::string MakeValidLatexNumber(Number value) const; + + /** Compare two strings and return true if they are equal (case + insensitive comparison) */ + bool string_equal_insensitive(const std::string& s1, + const std::string& s2) const; + + std::vector<string_entry> valid_strings_; + std::string default_string_; + + /** Has the information as how many-th option this one was + * registered. */ + const Index counter_; + }; + + /** Class for storing registered options. Used for validation and + * documentation. + */ + class RegisteredOptions : public ReferencedObject + { + public: + /** Constructors / Destructors */ + //@{ + /** Standard Constructor */ + RegisteredOptions() + : + next_counter_(0), + current_registering_category_("Uncategorized") + {} + + /** Standard Destructor */ + virtual ~RegisteredOptions() + {} + //@} + + DECLARE_STD_EXCEPTION(OPTION_ALREADY_REGISTERED); + + /** Methods to interact with registered options */ + //@{ + /** set the registering class. All subsequent options will be + * added with the registered class */ + virtual void SetRegisteringCategory(const std::string& registering_category) + { + current_registering_category_ = registering_category; + } + + /** retrieve the value of the current registering category */ + virtual std::string RegisteringCategory() + { + return current_registering_category_; + } + + /** Add a Number option (with no restrictions) */ + virtual void AddNumberOption(const std::string& name, + const std::string& short_description, + Number default_value, + const std::string& long_description=""); + /** Add a Number option (with a lower bound) */ + virtual void AddLowerBoundedNumberOption(const std::string& name, + const std::string& short_description, + Number lower, bool strict, + Number default_value, + const std::string& long_description=""); + /** Add a Number option (with a upper bound) */ + virtual void AddUpperBoundedNumberOption(const std::string& name, + const std::string& short_description, + Number upper, bool strict, + Number default_value, + const std::string& long_description=""); + /** Add a Number option (with a both bounds) */ + virtual void AddBoundedNumberOption(const std::string& name, + const std::string& short_description, + Number lower, bool lower_strict, + Number upper, bool upper_strict, + Number default_value, + const std::string& long_description=""); + /** Add a Integer option (with no restrictions) */ + virtual void AddIntegerOption(const std::string& name, + const std::string& short_description, + Index default_value, + const std::string& long_description=""); + /** Add a Integer option (with a lower bound) */ + virtual void AddLowerBoundedIntegerOption(const std::string& name, + const std::string& short_description, + Index lower, Index default_value, + const std::string& long_description=""); + /** Add a Integer option (with a upper bound) */ + virtual void AddUpperBoundedIntegerOption(const std::string& name, + const std::string& short_description, + Index upper, Index default_value, + const std::string& long_description=""); + /** Add a Integer option (with a both bounds) */ + virtual void AddBoundedIntegerOption(const std::string& name, + const std::string& short_description, + Index lower, Index upper, + Index default_value, + const std::string& long_description=""); + + /** Add a String option (with no restrictions) */ + virtual void AddStringOption(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::vector<std::string>& settings, + const std::vector<std::string>& descriptions, + const std::string& long_description=""); + /** Methods that make adding string options with only a few + * entries easier */ + virtual void AddStringOption1(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& long_description=""); + virtual void AddStringOption2(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& long_description=""); + virtual void AddStringOption3(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& long_description=""); + virtual void AddStringOption4(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& long_description=""); + virtual void AddStringOption5(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& setting5, + const std::string& description5, + const std::string& long_description=""); + virtual void AddStringOption6(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& setting5, + const std::string& description5, + const std::string& setting6, + const std::string& description6, + const std::string& long_description=""); + virtual void AddStringOption7(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& setting5, + const std::string& description5, + const std::string& setting6, + const std::string& description6, + const std::string& setting7, + const std::string& description7, + const std::string& long_description=""); + virtual void AddStringOption8(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& setting5, + const std::string& description5, + const std::string& setting6, + const std::string& description6, + const std::string& setting7, + const std::string& description7, + const std::string& setting8, + const std::string& description8, + const std::string& long_description=""); + virtual void AddStringOption9(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& setting5, + const std::string& description5, + const std::string& setting6, + const std::string& description6, + const std::string& setting7, + const std::string& description7, + const std::string& setting8, + const std::string& description8, + const std::string& setting9, + const std::string& description9, + const std::string& long_description=""); + virtual void AddStringOption10(const std::string& name, + const std::string& short_description, + const std::string& default_value, + const std::string& setting1, + const std::string& description1, + const std::string& setting2, + const std::string& description2, + const std::string& setting3, + const std::string& description3, + const std::string& setting4, + const std::string& description4, + const std::string& setting5, + const std::string& description5, + const std::string& setting6, + const std::string& description6, + const std::string& setting7, + const std::string& description7, + const std::string& setting8, + const std::string& description8, + const std::string& setting9, + const std::string& description9, + const std::string& setting10, + const std::string& description10, + const std::string& long_description=""); + + /** Get a registered option - this will return NULL if the option + * does not exist */ + virtual SmartPtr<const RegisteredOption> GetOption(const std::string& name); + + /** Output documentation for the options - gives a description, + * etc. */ + virtual void OutputOptionDocumentation(const Journalist& jnlst, std::list<std::string>& categories); + + /** Output documentation in Latex format to include in a latex file */ + virtual void OutputLatexOptionDocumentation(const Journalist& jnlst, std::list<std::string>& categories); + //@} + + typedef std::map<std::string, SmartPtr<RegisteredOption> > RegOptionsList; + + /** Giving access to iteratable representation of the registered + * options */ + virtual const RegOptionsList& RegisteredOptionsList () const + { + return registered_options_; + } + + private: + Index next_counter_; + std::string current_registering_category_; + std::map<std::string, SmartPtr<RegisteredOption> > registered_options_; + }; +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpReturnCodes.h b/thirdparty/linux/include/coin/IpReturnCodes.h new file mode 100644 index 0000000..b16d2c6 --- /dev/null +++ b/thirdparty/linux/include/coin/IpReturnCodes.h @@ -0,0 +1,18 @@ +/*********************************************************************** +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpReturnCodes.h 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 +************************************************************************/ + +#ifndef __IPRETURNCODES_H__ +#define __IPRETURNCODES_H__ + +/* include from a common include file */ + +#include "IpReturnCodes_inc.h" + +#endif diff --git a/thirdparty/linux/include/coin/IpReturnCodes.hpp b/thirdparty/linux/include/coin/IpReturnCodes.hpp new file mode 100644 index 0000000..36dd7d7 --- /dev/null +++ b/thirdparty/linux/include/coin/IpReturnCodes.hpp @@ -0,0 +1,21 @@ +/*********************************************************************** +// Copyright (C) 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpReturnCodes.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Andreas Waechter IBM 2006-03-01 +************************************************************************/ + +#ifndef __IPRETURNCODES_HPP__ +#define __IPRETURNCODES_HPP__ + +/* include from a common include file */ + +namespace Ipopt +{ +#include "IpReturnCodes_inc.h" +} + +#endif diff --git a/thirdparty/linux/include/coin/IpReturnCodes.inc b/thirdparty/linux/include/coin/IpReturnCodes.inc new file mode 100644 index 0000000..c6bf70a --- /dev/null +++ b/thirdparty/linux/include/coin/IpReturnCodes.inc @@ -0,0 +1,70 @@ +C Copyright (C) 2005, 2009 International Business Machines and others. +C All Rights Reserved. +C This code is published under the Eclipse Public License. +C +C $Id: IpReturnCodes.inc 1861 2010-12-21 21:34:47Z andreasw $ +C +C Author: Andreas Waechter IBM 2005-08-11 +C + INTEGER IP_SOLVE_SUCCEEDED + PARAMETER( IP_SOLVE_SUCCEEDED = 0 ) + + INTEGER IP_ACCEPTABLE_LEVEL + PARAMETER( IP_ACCEPTABLE_LEVEL = 1 ) + + INTEGER IP_INFEASIBLE_PROBLEM + PARAMETER( IP_INFEASIBLE_PROBLEM = 2 ) + + INTEGER IP_SEARCH_DIRECTION_TOO_SMALL + PARAMETER( IP_SEARCH_DIRECTION_TOO_SMALL = 3 ) + + INTEGER IP_DIVERGING_ITERATES + PARAMETER( IP_DIVERGING_ITERATES = 4 ) + + INTEGER IP_USER_REQUESTED_STOP + PARAMETER( IP_USER_REQUESTED_STOP = 5 ) + + INTEGER IP_FEASIBLE_POINT_FOUND + PARAMETER( IP_FEASIBLE_POINT_FOUND = 6 ) + + INTEGER IP_ITERATION_EXCEEDED + PARAMETER( IP_ITERATION_EXCEEDED = -1 ) + + INTEGER IP_RESTORATION_FAILED + PARAMETER( IP_RESTORATION_FAILED = -2 ) + + INTEGER IP_ERROR_IN_STEP_COMPUTATION + PARAMETER( IP_ERROR_IN_STEP_COMPUTATION = -3 ) + + INTEGER IP_CPUTIME_EXCEEDED + PARAMETER( IP_CPUTIME_EXCEEDED = -4 ) + + INTEGER IP_NOT_ENOUGH_DEGREES_OF_FRE + PARAMETER( IP_NOT_ENOUGH_DEGREES_OF_FRE = -10 ) + + INTEGER IP_INVALID_PROBLEM_DEFINITION + PARAMETER( IP_INVALID_PROBLEM_DEFINITION = -11) + + INTEGER IP_INVALID_OPTION + PARAMETER( IP_INVALID_OPTION = -12 ) + + INTEGER IP_INVALID_NUMBER_DETECTED + PARAMETER( IP_INVALID_NUMBER_DETECTED = -13 ) + + INTEGER IP_UNRECOVERABLE_EXCEPTION + PARAMETER( IP_UNRECOVERABLE_EXCEPTION = -100 ) + + INTEGER IP_NON_IPOPT_EXCEPTION + PARAMETER( IP_NON_IPOPT_EXCEPTION = -101 ) + + INTEGER IP_INSUFFICIENT_MEMORY + PARAMETER( IP_INSUFFICIENT_MEMORY = -102 ) + + INTEGER IP_INTERNAL_ERROR + PARAMETER( IP_INTERNAL_ERROR = -199 ) + + INTEGER IP_REGULAR_MODE + PARAMETER( IP_REGULAR_MODE = 0 ) + + INTEGER IP_RESTORATION_PHASE_MODE + PARAMETER( IP_RESTORATION_PHASE_MODE = 1 ) diff --git a/thirdparty/linux/include/coin/IpReturnCodes_inc.h b/thirdparty/linux/include/coin/IpReturnCodes_inc.h new file mode 100644 index 0000000..80190ed --- /dev/null +++ b/thirdparty/linux/include/coin/IpReturnCodes_inc.h @@ -0,0 +1,46 @@ +/*********************************************************************** +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpReturnCodes_inc.h 2216 2013-04-14 17:06:00Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 +************************************************************************/ + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* !!!!!!!!! REMEMBER TO UPDATE IpReturnCodes.inc and Ipopt.java !!!!!!!! */ +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +/** Return codes for the Optimize call for an application */ +enum ApplicationReturnStatus + { + Solve_Succeeded=0, + Solved_To_Acceptable_Level=1, + Infeasible_Problem_Detected=2, + Search_Direction_Becomes_Too_Small=3, + Diverging_Iterates=4, + User_Requested_Stop=5, + Feasible_Point_Found=6, + + Maximum_Iterations_Exceeded=-1, + Restoration_Failed=-2, + Error_In_Step_Computation=-3, + Maximum_CpuTime_Exceeded=-4, + Not_Enough_Degrees_Of_Freedom=-10, + Invalid_Problem_Definition=-11, + Invalid_Option=-12, + Invalid_Number_Detected=-13, + + Unrecoverable_Exception=-100, + NonIpopt_Exception_Thrown=-101, + Insufficient_Memory=-102, + Internal_Error=-199 + }; + +/** enum to indicate the mode in which the algorithm is */ +enum AlgorithmMode + { + RegularMode=0, + RestorationPhaseMode=1 + }; diff --git a/thirdparty/linux/include/coin/IpSmartPtr.hpp b/thirdparty/linux/include/coin/IpSmartPtr.hpp new file mode 100644 index 0000000..dec0ab5 --- /dev/null +++ b/thirdparty/linux/include/coin/IpSmartPtr.hpp @@ -0,0 +1,734 @@ +// Copyright (C) 2004, 2011 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSmartPtr.hpp 2182 2013-03-30 20:02:18Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSMARTPTR_HPP__ +#define __IPSMARTPTR_HPP__ + +#include "IpReferenced.hpp" + +#include "IpDebug.hpp" +#if COIN_IPOPT_CHECKLEVEL > 2 +# define IP_DEBUG_SMARTPTR +#endif +#ifndef IPOPT_UNUSED +# if defined(__GNUC__) +# define IPOPT_UNUSED __attribute__((unused)) +# else +# define IPOPT_UNUSED +# endif +#endif + +namespace Ipopt +{ + + /** Template class for Smart Pointers. + * A SmartPtr behaves much like a raw pointer, but manages the lifetime + * of an object, deleting the object automatically. This class implements + * a reference-counting, intrusive smart pointer design, where all + * objects pointed to must inherit off of ReferencedObject, which + * stores the reference count. Although this is intrusive (native types + * and externally authored classes require wrappers to be referenced + * by smart pointers), it is a safer design. A more detailed discussion of + * these issues follows after the usage information. + * + * Usage Example: + * Note: to use the SmartPtr, all objects to which you point MUST + * inherit off of ReferencedObject. + * + * \verbatim + * + * In MyClass.hpp... + * + * #include "IpReferenced.hpp" + + * namespace Ipopt { + * + * class MyClass : public ReferencedObject // must derive from ReferencedObject + * { + * ... + * } + * } // namespace Ipopt + * + * + * In my_usage.cpp... + * + * #include "IpSmartPtr.hpp" + * #include "MyClass.hpp" + * + * void func(AnyObject& obj) + * { + * SmartPtr<MyClass> ptr_to_myclass = new MyClass(...); + * // ptr_to_myclass now points to a new MyClass, + * // and the reference count is 1 + * + * ... + * + * obj.SetMyClass(ptr_to_myclass); + * // Here, let's assume that AnyObject uses a + * // SmartPtr<MyClass> internally here. + * // Now, both ptr_to_myclass and the internal + * // SmartPtr in obj point to the same MyClass object + * // and its reference count is 2. + * + * ... + * + * // No need to delete ptr_to_myclass, this + * // will be done automatically when the + * // reference count drops to zero. + * + * } + * + * \endverbatim + * + * It is not necessary to use SmartPtr's in all cases where an + * object is used that has been allocated "into" a SmartPtr. It is + * possible to just pass objects by reference or regular pointers, + * even if lower down in the stack a SmartPtr is to be held on to. + * Everything should work fine as long as a pointer created by "new" + * is immediately passed into a SmartPtr, and if SmartPtr's are used + * to hold on to objects. + * + * Other Notes: + * The SmartPtr implements both dereference operators -> & *. + * The SmartPtr does NOT implement a conversion operator to + * the raw pointer. Use the GetRawPtr() method when this + * is necessary. Make sure that the raw pointer is NOT + * deleted. + * The SmartPtr implements the comparison operators == & != + * for a variety of types. Use these instead of + * \verbatim + * if (GetRawPtr(smrt_ptr) == ptr) // Don't use this + * \endverbatim + * SmartPtr's, as currently implemented, do NOT handle circular references. + * For example: consider a higher level object using SmartPtrs to point to + * A and B, but A and B also point to each other (i.e. A has a SmartPtr + * to B and B has a SmartPtr to A). In this scenario, when the higher + * level object is finished with A and B, their reference counts will + * never drop to zero (since they reference each other) and they + * will not be deleted. This can be detected by memory leak tools like + * valgrind. If the circular reference is necessary, the problem can be + * overcome by a number of techniques: + * + * 1) A and B can have a method that "releases" each other, that is + * they set their internal SmartPtrs to NULL. + * \verbatim + * void AClass::ReleaseCircularReferences() + * { + * smart_ptr_to_B = NULL; + * } + * \endverbatim + * Then, the higher level class can call these methods before + * it is done using A & B. + * + * 2) Raw pointers can be used in A and B to reference each other. + * Here, an implicit assumption is made that the lifetime is + * controlled by the higher level object and that A and B will + * both exist in a controlled manner. Although this seems + * dangerous, in many situations, this type of referencing + * is very controlled and this is reasonably safe. + * + * 3) This SmartPtr class could be redesigned with the Weak/Strong + * design concept. Here, the SmartPtr is identified as being + * Strong (controls lifetime of the object) or Weak (merely + * referencing the object). The Strong SmartPtr increments + * (and decrements) the reference count in ReferencedObject + * but the Weak SmartPtr does not. In the example above, + * the higher level object would have Strong SmartPtrs to + * A and B, but A and B would have Weak SmartPtrs to each + * other. Then, when the higher level object was done with + * A and B, they would be deleted. The Weak SmartPtrs in A + * and B would not decrement the reference count and would, + * of course, not delete the object. This idea is very similar + * to item (2), where it is implied that the sequence of events + * is controlled such that A and B will not call anything using + * their pointers following the higher level delete (i.e. in + * their destructors!). This is somehow safer, however, because + * code can be written (however expensive) to perform run-time + * detection of this situation. For example, the ReferencedObject + * could store pointers to all Weak SmartPtrs that are referencing + * it and, in its destructor, tell these pointers that it is + * dying. They could then set themselves to NULL, or set an + * internal flag to detect usage past this point. + * + * Comments on Non-Intrusive Design: + * In a non-intrusive design, the reference count is stored somewhere other + * than the object being referenced. This means, unless the reference + * counting pointer is the first referencer, it must get a pointer to the + * referenced object from another smart pointer (so it has access to the + * reference count location). In this non-intrusive design, if we are + * pointing to an object with a smart pointer (or a number of smart + * pointers), and we then give another smart pointer the address through + * a RAW pointer, we will have two independent, AND INCORRECT, reference + * counts. To avoid this pitfall, we use an intrusive reference counting + * technique where the reference count is stored in the object being + * referenced. + */ + template<class T> + class SmartPtr : public Referencer + { + public: +#define ipopt_dbg_smartptr_verbosity 0 + + /**@name Constructors/Destructors */ + //@{ + /** Default constructor, initialized to NULL */ + SmartPtr(); + + /** Copy constructor, initialized from copy of type T */ + SmartPtr(const SmartPtr<T>& copy); + + /** Copy constructor, initialized from copy of type U */ + template <class U> + SmartPtr(const SmartPtr<U>& copy); + + /** Constructor, initialized from T* ptr */ + SmartPtr(T* ptr); + + /** Destructor, automatically decrements the + * reference count, deletes the object if + * necessary.*/ + ~SmartPtr(); + //@} + + /**@name Overloaded operators. */ + //@{ + /** Overloaded arrow operator, allows the user to call + * methods using the contained pointer. */ + T* operator->() const; + + /** Overloaded dereference operator, allows the user + * to dereference the contained pointer. */ + T& operator*() const; + + /** Overloaded equals operator, allows the user to + * set the value of the SmartPtr from a raw pointer */ + SmartPtr<T>& operator=(T* rhs); + + /** Overloaded equals operator, allows the user to + * set the value of the SmartPtr from another + * SmartPtr */ + SmartPtr<T>& operator=(const SmartPtr<T>& rhs); + + /** Overloaded equals operator, allows the user to + * set the value of the SmartPtr from another + * SmartPtr of a different type */ + template <class U> + SmartPtr<T>& operator=(const SmartPtr<U>& rhs); + + /** Overloaded equality comparison operator, allows the + * user to compare the value of two SmartPtrs */ + template <class U1, class U2> + friend + bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); + + /** Overloaded equality comparison operator, allows the + * user to compare the value of a SmartPtr with a raw pointer. */ + template <class U1, class U2> + friend + bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs); + + /** Overloaded equality comparison operator, allows the + * user to compare the value of a raw pointer with a SmartPtr. */ + template <class U1, class U2> + friend + bool operator==(U1* lhs, const SmartPtr<U2>& raw_rhs); + + /** Overloaded in-equality comparison operator, allows the + * user to compare the value of two SmartPtrs */ + template <class U1, class U2> + friend + bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); + + /** Overloaded in-equality comparison operator, allows the + * user to compare the value of a SmartPtr with a raw pointer. */ + template <class U1, class U2> + friend + bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs); + + /** Overloaded in-equality comparison operator, allows the + * user to compare the value of a SmartPtr with a raw pointer. */ + template <class U1, class U2> + friend + bool operator!=(U1* lhs, const SmartPtr<U2>& raw_rhs); + + /** Overloaded less-than comparison operator, allows the + * user to compare the value of two SmartPtrs */ + template <class U> + friend + bool operator<(const SmartPtr<U>& lhs, const SmartPtr<U>& rhs); + //@} + + /**@name friend method declarations. */ + //@{ + /** Returns the raw pointer contained. + * Use to get the value of + * the raw ptr (i.e. to pass to other + * methods/functions, etc.) + * Note: This method does NOT copy, + * therefore, modifications using this + * value modify the underlying object + * contained by the SmartPtr, + * NEVER delete this returned value. + */ + template <class U> + friend + U* GetRawPtr(const SmartPtr<U>& smart_ptr); + + /** Returns a const pointer */ + template <class U> + friend + SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr); + + /** Returns true if the SmartPtr is NOT NULL. + * Use this to check if the SmartPtr is not null + * This is preferred to if(GetRawPtr(sp) != NULL) + */ + template <class U> + friend + bool IsValid(const SmartPtr<U>& smart_ptr); + + /** Returns true if the SmartPtr is NULL. + * Use this to check if the SmartPtr IsNull. + * This is preferred to if(GetRawPtr(sp) == NULL) + */ + template <class U> + friend + bool IsNull(const SmartPtr<U>& smart_ptr); + //@} + + private: + /**@name Private Data/Methods */ + //@{ + /** Actual raw pointer to the object. */ + T* ptr_; + + /** Set the value of the internal raw pointer + * from another raw pointer, releasing the + * previously referenced object if necessary. */ + SmartPtr<T>& SetFromRawPtr_(T* rhs); + + /** Set the value of the internal raw pointer + * from a SmartPtr, releasing the previously referenced + * object if necessary. */ + SmartPtr<T>& SetFromSmartPtr_(const SmartPtr<T>& rhs); + + /** Release the currently referenced object. */ + void ReleasePointer_(); + //@} + }; + + /**@name SmartPtr friend function declarations.*/ + //@{ + template <class U> + U* GetRawPtr(const SmartPtr<U>& smart_ptr); + + template <class U> + SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr); + + template <class U> + bool IsNull(const SmartPtr<U>& smart_ptr); + + template <class U> + bool IsValid(const SmartPtr<U>& smart_ptr); + + template <class U1, class U2> + bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); + + template <class U1, class U2> + bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs); + + template <class U1, class U2> + bool operator==(U1* lhs, const SmartPtr<U2>& raw_rhs); + + template <class U1, class U2> + bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); + + template <class U1, class U2> + bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs); + + template <class U1, class U2> + bool operator!=(U1* lhs, const SmartPtr<U2>& raw_rhs); + + //@} + + + template <class T> + SmartPtr<T>::SmartPtr() + : + ptr_(0) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("SmartPtr<T>::SmartPtr()", ipopt_dbg_smartptr_verbosity); +#endif + +#ifndef NDEBUG + const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_; +#endif + + } + + + template <class T> + SmartPtr<T>::SmartPtr(const SmartPtr<T>& copy) + : + ptr_(0) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("SmartPtr<T>::SmartPtr(const SmartPtr<T>& copy)", ipopt_dbg_smartptr_verbosity); +#endif + +#ifndef NDEBUG + const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_; +#endif + + (void) SetFromSmartPtr_(copy); + } + + + template <class T> + template <class U> + SmartPtr<T>::SmartPtr(const SmartPtr<U>& copy) + : + ptr_(0) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("SmartPtr<T>::SmartPtr(const SmartPtr<U>& copy)", ipopt_dbg_smartptr_verbosity); +#endif + +#ifndef NDEBUG + const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_; +#endif + + (void) SetFromSmartPtr_(GetRawPtr(copy)); + } + + + template <class T> + SmartPtr<T>::SmartPtr(T* ptr) + : + ptr_(0) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("SmartPtr<T>::SmartPtr(T* ptr)", ipopt_dbg_smartptr_verbosity); +#endif + +#ifndef NDEBUG + const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_; +#endif + + (void) SetFromRawPtr_(ptr); + } + + template <class T> + SmartPtr<T>::~SmartPtr() + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("SmartPtr<T>::~SmartPtr(T* ptr)", ipopt_dbg_smartptr_verbosity); +#endif + + ReleasePointer_(); + } + + + template <class T> + T* SmartPtr<T>::operator->() const + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("T* SmartPtr<T>::operator->()", ipopt_dbg_smartptr_verbosity); +#endif + + // cannot deref a null pointer +#if COIN_IPOPT_CHECKLEVEL > 0 + assert(ptr_); +#endif + + return ptr_; + } + + + template <class T> + T& SmartPtr<T>::operator*() const + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("T& SmartPtr<T>::operator*()", ipopt_dbg_smartptr_verbosity); +#endif + + // cannot dereference a null pointer +#if COIN_IPOPT_CHECKLEVEL > 0 + assert(ptr_); +#endif + + return *ptr_; + } + + + template <class T> + SmartPtr<T>& SmartPtr<T>::operator=(T* rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH("SmartPtr<T>& SmartPtr<T>::operator=(T* rhs)", ipopt_dbg_smartptr_verbosity); +#endif + + return SetFromRawPtr_(rhs); + } + + + template <class T> + SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH( + "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + return SetFromSmartPtr_(rhs); + } + + + template <class T> + template <class U> + SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH( + "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + return SetFromSmartPtr_(GetRawPtr(rhs)); + } + + + template <class T> + SmartPtr<T>& SmartPtr<T>::SetFromRawPtr_(T* rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH( + "SmartPtr<T>& SmartPtr<T>::SetFromRawPtr_(T* rhs)", ipopt_dbg_smartptr_verbosity); +#endif + + if (rhs != 0) + rhs->AddRef(this); + + // Release any old pointer + ReleasePointer_(); + + ptr_ = rhs; + + return *this; + } + + template <class T> + SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH( + "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + SetFromRawPtr_(GetRawPtr(rhs)); + + return (*this); + } + + + template <class T> + void SmartPtr<T>::ReleasePointer_() + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_METH( + "void SmartPtr<T>::ReleasePointer()", + ipopt_dbg_smartptr_verbosity); +#endif + + if (ptr_) { + ptr_->ReleaseRef(this); + if (ptr_->ReferenceCount() == 0) + delete ptr_; + } + } + + + template <class U> + U* GetRawPtr(const SmartPtr<U>& smart_ptr) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "T* GetRawPtr(const SmartPtr<T>& smart_ptr)", + 0); +#endif + + return smart_ptr.ptr_; + } + + template <class U> + SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr) + { + // compiler should implicitly cast + return GetRawPtr(smart_ptr); + } + + template <class U> + bool IsValid(const SmartPtr<U>& smart_ptr) + { + return !IsNull(smart_ptr); + } + + template <class U> + bool IsNull(const SmartPtr<U>& smart_ptr) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool IsNull(const SmartPtr<T>& smart_ptr)", + 0); +#endif + + return (smart_ptr.ptr_ == 0); + } + + + template <class U1, class U2> + bool ComparePointers(const U1* lhs, const U2* rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool ComparePtrs(const U1* lhs, const U2* rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + // Even if lhs and rhs point to the same object + // with different interfaces U1 and U2, we cannot guarantee that + // the value of the pointers will be equivalent. We can + // guarantee this if we convert to ReferencedObject* (see also #162) + const ReferencedObject* v_lhs = lhs; + const ReferencedObject* v_rhs = rhs; + + return v_lhs == v_rhs; + } + + template <class U1, class U2> + bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + U1* raw_lhs = GetRawPtr(lhs); + U2* raw_rhs = GetRawPtr(rhs); + return ComparePointers(raw_lhs, raw_rhs); + } + + template <class U1, class U2> + bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool operator==(SmartPtr<U1>& lhs, U2* rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + U1* raw_lhs = GetRawPtr(lhs); + return ComparePointers(raw_lhs, raw_rhs); + } + + template <class U1, class U2> + bool operator==(U1* raw_lhs, const SmartPtr<U2>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + const U2* raw_rhs = GetRawPtr(rhs); + return ComparePointers(raw_lhs, raw_rhs); + } + + template <class U1, class U2> + bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + bool retValue = operator==(lhs, rhs); + return !retValue; + } + + template <class U1, class U2> + bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + bool retValue = operator==(lhs, raw_rhs); + return !retValue; + } + + template <class U1, class U2> + bool operator!=(U1* raw_lhs, const SmartPtr<U2>& rhs) + { +#ifdef IP_DEBUG_SMARTPTR + DBG_START_FUN( + "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)", + ipopt_dbg_smartptr_verbosity); +#endif + + bool retValue = operator==(raw_lhs, rhs); + return !retValue; + } + + template <class T> + void swap(SmartPtr<T>& a, SmartPtr<T>& b) + { +#ifdef IP_DEBUG_REFERENCED + SmartPtr<T> tmp(a); + a = b; + b = tmp; +#else + std::swap(a.prt_, b.ptr_); +#endif + } + + template <class T> + bool operator<(const SmartPtr<T>& lhs, const SmartPtr<T>& rhs) + { + return lhs.ptr_ < rhs.ptr_; + } + + template <class T> + bool operator> (const SmartPtr<T>& lhs, const SmartPtr<T>& rhs) + { + return rhs < lhs; + } + + template <class T> bool + operator<=(const SmartPtr<T>& lhs, const SmartPtr<T>& rhs) + { + return !( rhs < lhs ); + } + + template <class T> bool + operator>=(const SmartPtr<T>& lhs, const SmartPtr<T>& rhs) + { + return !( lhs < rhs ); + } +} // namespace Ipopt + +#undef ipopt_dbg_smartptr_verbosity + +#endif diff --git a/thirdparty/linux/include/coin/IpSolveStatistics.hpp b/thirdparty/linux/include/coin/IpSolveStatistics.hpp new file mode 100644 index 0000000..625ddfb --- /dev/null +++ b/thirdparty/linux/include/coin/IpSolveStatistics.hpp @@ -0,0 +1,150 @@ +// Copyright (C) 2005, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSolveStatistics.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2005-08-15 + +#ifndef __IPSOLVESTATISTICS_HPP__ +#define __IPSOLVESTATISTICS_HPP__ + +#include "IpReferenced.hpp" +#include "IpSmartPtr.hpp" + +namespace Ipopt +{ + // forward declaration (to avoid inclusion of too many header files) + class IpoptNLP; + class IpoptData; + class IpoptCalculatedQuantities; + + /** This class collects statistics about an optimziation run, such + * as iteration count, final infeasibilities etc. It is meant to + * provide such information to a user of Ipopt during the + * finalize_solution call. + */ + class SolveStatistics : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor. It takes in those collecting Ipopt + * objects that can provide the statistics information. Those + * statistics are retrieved at the time of the constructor + * call. */ + SolveStatistics(const SmartPtr<IpoptNLP>& ip_nlp, + const SmartPtr<IpoptData>& ip_data, + const SmartPtr<IpoptCalculatedQuantities>& ip_cq); + + /** Default destructor */ + virtual ~SolveStatistics() + {} + //@} + + /** @name Accessor methods for retrieving different kind of solver + * statistics information */ + //@{ + /** Iteration counts. */ + virtual Index IterationCount() const; + /** Total CPU time, including function evaluations. */ + virtual Number TotalCpuTime() const; + /** Total CPU time, including function evaluations. Included for + * backward compatibility. */ + Number TotalCPUTime() const + { + return TotalCpuTime(); + } + /** Total System time, including function evaluations. */ + virtual Number TotalSysTime() const; + /** Total wall clock time, including function evaluations. */ + virtual Number TotalWallclockTime() const; + /** Number of NLP function evaluations. */ + virtual void NumberOfEvaluations(Index& num_obj_evals, + Index& num_constr_evals, + Index& num_obj_grad_evals, + Index& num_constr_jac_evals, + Index& num_hess_evals) const; + /** Unscaled solution infeasibilities */ + virtual void Infeasibilities(Number& dual_inf, + Number& constr_viol, + Number& complementarity, + Number& kkt_error) const; + /** Scaled solution infeasibilities */ + virtual void ScaledInfeasibilities(Number& scaled_dual_inf, + Number& scaled_constr_viol, + Number& scaled_complementarity, + Number& scaled_kkt_error) const; + /** Final value of objective function */ + virtual Number FinalObjective() const; + /** Final scaled value of objective function */ + virtual Number FinalScaledObjective() const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + SolveStatistics(); + + /** Copy Constructor */ + SolveStatistics(const SolveStatistics&); + + /** Overloaded Equals Operator */ + void operator=(const SolveStatistics&); + //@} + + /** @name Fields for storing the statistics data */ + //@{ + /** Number of iterations. */ + Index num_iters_; + /* Total CPU time */ + Number total_cpu_time_; + /* Total system time */ + Number total_sys_time_; + /* Total wall clock time */ + Number total_wallclock_time_; + /** Number of objective function evaluations. */ + Index num_obj_evals_; + /** Number of constraints evaluations (max of equality and + * inequality) */ + Index num_constr_evals_; + /** Number of objective gradient evaluations. */ + Index num_obj_grad_evals_; + /** Number of constraint Jacobian evaluations. */ + Index num_constr_jac_evals_; + /** Number of Lagrangian Hessian evaluations. */ + Index num_hess_evals_; + + /** Final scaled value of objective function */ + Number scaled_obj_val_; + /** Final unscaled value of objective function */ + Number obj_val_; + /** Final scaled dual infeasibility (max-norm) */ + Number scaled_dual_inf_; + /** Final unscaled dual infeasibility (max-norm) */ + Number dual_inf_; + /** Final scaled constraint violation (max-norm) */ + Number scaled_constr_viol_; + /** Final unscaled constraint violation (max-norm) */ + Number constr_viol_; + /** Final scaled complementarity error (max-norm) */ + Number scaled_compl_; + /** Final unscaled complementarity error (max-norm) */ + Number compl_; + /** Final overall scaled KKT error (max-norm) */ + Number scaled_kkt_error_; + /** Final overall unscaled KKT error (max-norm) */ + Number kkt_error_; + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpStdCInterface.h b/thirdparty/linux/include/coin/IpStdCInterface.h new file mode 100644 index 0000000..4f11336 --- /dev/null +++ b/thirdparty/linux/include/coin/IpStdCInterface.h @@ -0,0 +1,271 @@ +/************************************************************************* + Copyright (C) 2004, 2010 International Business Machines and others. + All Rights Reserved. + This code is published under the Eclipse Public License. + + $Id: IpStdCInterface.h 2082 2012-02-16 03:00:34Z andreasw $ + + Authors: Carl Laird, Andreas Waechter IBM 2004-09-02 + *************************************************************************/ + +#ifndef __IPSTDCINTERFACE_H__ +#define __IPSTDCINTERFACE_H__ + +#ifndef IPOPT_EXPORT +#ifdef _MSC_VER +#ifdef IPOPT_DLL +#define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl +#else +#define IPOPT_EXPORT(type) type __cdecl +#endif +#else +#define IPOPT_EXPORT(type) type +#endif +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** Type for all number. We need to make sure that this is + identical with what is defined in Common/IpTypes.hpp */ + typedef double Number; + + /** Type for all incides. We need to make sure that this is + identical with what is defined in Common/IpTypes.hpp */ + typedef int Index; + + /** Type for all integers. We need to make sure that this is + identical with what is defined in Common/IpTypes.hpp */ + typedef int Int; + + /* This includes the SolverReturn enum type */ +#include "IpReturnCodes.h" + + /** Structure collecting all information about the problem + * definition and solve statistics etc. This is defined in the + * source file. */ + struct IpoptProblemInfo; + + /** Pointer to a Ipopt Problem. */ + typedef struct IpoptProblemInfo* IpoptProblem; + + /** define a boolean type for C */ + typedef int Bool; +#ifndef TRUE +# define TRUE (1) +#endif +#ifndef FALSE +# define FALSE (0) +#endif + + /** A pointer for anything that is to be passed between the called + * and individual callback function */ + typedef void * UserDataPtr; + + /** Type defining the callback function for evaluating the value of + * the objective function. Return value should be set to false if + * there was a problem doing the evaluation. */ + typedef Bool (*Eval_F_CB)(Index n, Number* x, Bool new_x, + Number* obj_value, UserDataPtr user_data); + + /** Type defining the callback function for evaluating the gradient of + * the objective function. Return value should be set to false if + * there was a problem doing the evaluation. */ + typedef Bool (*Eval_Grad_F_CB)(Index n, Number* x, Bool new_x, + Number* grad_f, UserDataPtr user_data); + + /** Type defining the callback function for evaluating the value of + * the constraint functions. Return value should be set to false if + * there was a problem doing the evaluation. */ + typedef Bool (*Eval_G_CB)(Index n, Number* x, Bool new_x, + Index m, Number* g, UserDataPtr user_data); + + /** Type defining the callback function for evaluating the Jacobian of + * the constrant functions. Return value should be set to false if + * there was a problem doing the evaluation. */ + typedef Bool (*Eval_Jac_G_CB)(Index n, Number *x, Bool new_x, + Index m, Index nele_jac, + Index *iRow, Index *jCol, Number *values, + UserDataPtr user_data); + + /** Type defining the callback function for evaluating the Hessian of + * the Lagrangian function. Return value should be set to false if + * there was a problem doing the evaluation. */ + typedef Bool (*Eval_H_CB)(Index n, Number *x, Bool new_x, Number obj_factor, + Index m, Number *lambda, Bool new_lambda, + Index nele_hess, Index *iRow, Index *jCol, + Number *values, UserDataPtr user_data); + + /** Type defining the callback function for giving intermediate + * execution control to the user. If set, it is called once per + * iteration, providing the user with some information on the state + * of the optimization. This can be used to print some + * user-defined output. It also gives the user a way to terminate + * the optimization prematurely. If this method returns false, + * Ipopt will terminate the optimization. */ + typedef Bool (*Intermediate_CB)(Index alg_mod, /* 0 is regular, 1 is resto */ + Index iter_count, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, UserDataPtr user_data); + + /** Function for creating a new Ipopt Problem object. This function + * returns an object that can be passed to the IpoptSolve call. It + * contains the basic definition of the optimization problem, such + * as number of variables and constraints, bounds on variables and + * constraints, information about the derivatives, and the callback + * function for the computation of the optimization problem + * functions and derivatives. During this call, the options file + * PARAMS.DAT is read as well. + * + * If NULL is returned, there was a problem with one of the inputs + * or reading the options file. */ + IPOPT_EXPORT(IpoptProblem) CreateIpoptProblem( + Index n /** Number of optimization variables */ + , Number* x_L /** Lower bounds on variables. This array of + size n is copied internally, so that the + caller can change the incoming data after + return without that IpoptProblem is + modified. Any value less or equal than + the number specified by option + 'nlp_lower_bound_inf' is interpreted to + be minus infinity. */ + , Number* x_U /** Upper bounds on variables. This array of + size n is copied internally, so that the + caller can change the incoming data after + return without that IpoptProblem is + modified. Any value greater or equal + than the number specified by option + 'nlp_upper_bound_inf' is interpreted to + be plus infinity. */ + , Index m /** Number of constraints. */ + , Number* g_L /** Lower bounds on constraints. This array of + size m is copied internally, so that the + caller can change the incoming data after + return without that IpoptProblem is + modified. Any value less or equal than + the number specified by option + 'nlp_lower_bound_inf' is interpreted to + be minus infinity. */ + , Number* g_U /** Upper bounds on constraints. This array of + size m is copied internally, so that the + caller can change the incoming data after + return without that IpoptProblem is + modified. Any value greater or equal + than the number specified by option + 'nlp_upper_bound_inf' is interpreted to + be plus infinity. */ + , Index nele_jac /** Number of non-zero elements in constraint + Jacobian. */ + , Index nele_hess /** Number of non-zero elements in Hessian of + Lagrangian. */ + , Index index_style /** indexing style for iRow & jCol, + 0 for C style, 1 for Fortran style */ + , Eval_F_CB eval_f /** Callback function for evaluating + objective function */ + , Eval_G_CB eval_g /** Callback function for evaluating + constraint functions */ + , Eval_Grad_F_CB eval_grad_f + /** Callback function for evaluating gradient + of objective function */ + , Eval_Jac_G_CB eval_jac_g + /** Callback function for evaluating Jacobian + of constraint functions */ + , Eval_H_CB eval_h /** Callback function for evaluating Hessian + of Lagrangian function */ + ); + + /** Method for freeing a previously created IpoptProblem. After + freeing an IpoptProblem, it cannot be used anymore. */ + IPOPT_EXPORT(void) FreeIpoptProblem(IpoptProblem ipopt_problem); + + + /** Function for adding a string option. Returns FALSE the option + * could not be set (e.g., if keyword is unknown) */ + IPOPT_EXPORT(Bool) AddIpoptStrOption(IpoptProblem ipopt_problem, char* keyword, char* val); + + /** Function for adding a Number option. Returns FALSE the option + * could not be set (e.g., if keyword is unknown) */ + IPOPT_EXPORT(Bool) AddIpoptNumOption(IpoptProblem ipopt_problem, char* keyword, Number val); + + /** Function for adding an Int option. Returns FALSE the option + * could not be set (e.g., if keyword is unknown) */ + IPOPT_EXPORT(Bool) AddIpoptIntOption(IpoptProblem ipopt_problem, char* keyword, Int val); + + /** Function for opening an output file for a given name with given + * printlevel. Returns false, if there was a problem opening the + * file. */ + IPOPT_EXPORT(Bool) OpenIpoptOutputFile(IpoptProblem ipopt_problem, char* file_name, + Int print_level); + + /** Optional function for setting scaling parameter for the NLP. + * This corresponds to the get_scaling_parameters method in TNLP. + * If the pointers x_scaling or g_scaling are NULL, then no scaling + * for x resp. g is done. */ + IPOPT_EXPORT(Bool) SetIpoptProblemScaling(IpoptProblem ipopt_problem, + Number obj_scaling, + Number* x_scaling, + Number* g_scaling); + + /** Setting a callback function for the "intermediate callback" + * method in the TNLP. This gives control back to the user once + * per iteration. If set, it provides the user with some + * information on the state of the optimization. This can be used + * to print some user-defined output. It also gives the user a way + * to terminate the optimization prematurely. If the callback + * method returns false, Ipopt will terminate the optimization. + * Calling this set method to set the CB pointer to NULL disables + * the intermediate callback functionality. */ + IPOPT_EXPORT(Bool) SetIntermediateCallback(IpoptProblem ipopt_problem, + Intermediate_CB intermediate_cb); + + /** Function calling the Ipopt optimization algorithm for a problem + previously defined with CreateIpoptProblem. The return + specified outcome of the optimization procedure (e.g., success, + failure etc). + */ + IPOPT_EXPORT(enum ApplicationReturnStatus) IpoptSolve( + IpoptProblem ipopt_problem + /** Problem that is to be optimized. Ipopt + will use the options previously specified with + AddIpoptOption (etc) for this problem. */ + , Number* x /** Input: Starting point + Output: Optimal solution */ + , Number* g /** Values of constraint at final point + (output only - ignored if set to NULL) */ + , Number* obj_val /** Final value of objective function + (output only - ignored if set to NULL) */ + , Number* mult_g /** Input: Initial values for the constraint + multipliers (only if warm start option + is chosen) + Output: Final multipliers for constraints + (ignored if set to NULL) */ + , Number* mult_x_L /** Input: Initial values for the multipliers for + lower variable bounds (only if warm start + option is chosen) + Output: Final multipliers for lower variable + bounds (ignored if set to NULL) */ + , Number* mult_x_U /** Input: Initial values for the multipliers for + upper variable bounds (only if warm start + option is chosen) + Output: Final multipliers for upper variable + bounds (ignored if set to NULL) */ + , UserDataPtr user_data + /** Pointer to user data. This will be + passed unmodified to the callback + functions. */ + ); + + /** + void IpoptStatisticsCounts; + + void IpoptStatisticsInfeasibilities; */ +#ifdef __cplusplus +} /* extern "C" { */ +#endif + +#endif diff --git a/thirdparty/linux/include/coin/IpSymMatrix.hpp b/thirdparty/linux/include/coin/IpSymMatrix.hpp new file mode 100644 index 0000000..4a0137b --- /dev/null +++ b/thirdparty/linux/include/coin/IpSymMatrix.hpp @@ -0,0 +1,162 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSymMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSYMMATRIX_HPP__ +#define __IPSYMMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class SymMatrixSpace; + + /** This is the base class for all derived symmetric matrix types. + */ + class SymMatrix : public Matrix + { + public: + /** @name Constructor/Destructor */ + //@{ + /** Constructor, taking the owner_space. + */ + inline + SymMatrix(const SymMatrixSpace* owner_space); + + /** Destructor */ + virtual ~SymMatrix() + {} + //@} + + /** @name Information about the size of the matrix */ + //@{ + /** Dimension of the matrix (number of rows and columns) */ + inline + Index Dim() const; + //@} + + inline + SmartPtr<const SymMatrixSpace> OwnerSymMatrixSpace() const; + + protected: + /** @name Overloaded methods from Matrix. */ + //@{ + /** Since the matrix is + * symmetric, it is only necessary to implement the + * MultVectorImpl method in a class that inherits from this base + * class. If the TransMultVectorImpl is called, this base class + * automatically calls MultVectorImpl instead. */ + virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, + Vector& y) const + { + // Since this matrix is symetric, this is the same operation as + // MultVector + MultVector(alpha, x, beta, y); + } + /** Since the matrix is symmetric, the row and column max norms + * are identical */ + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const + { + ComputeRowAMaxImpl(cols_norms, init); + } + //@} + + private: + /** Copy of the owner space ptr as a SymMatrixSpace instead + * of a MatrixSpace + */ + const SymMatrixSpace* owner_space_; + }; + + + /** SymMatrixSpace base class, corresponding to the SymMatrix base + * class. */ + class SymMatrixSpace : public MatrixSpace + { + public: + /** @name Constructors/Destructors */ + //@{ + /** Constructor, given the dimension (identical to the number of + * rows and columns). + */ + SymMatrixSpace(Index dim) + : + MatrixSpace(dim,dim) + {} + + /** Destructor */ + virtual ~SymMatrixSpace() + {} + //@} + + /** Pure virtual method for creating a new matrix of this specific + * type. */ + virtual SymMatrix* MakeNewSymMatrix() const=0; + + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewSymMatrix(); + } + + /** Accessor method for the dimension of the matrices in this + * matrix space. + */ + Index Dim() const + { + DBG_ASSERT(NRows() == NCols()); + return NRows(); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** default constructor */ + SymMatrixSpace(); + + /* Copy constructor */ + SymMatrixSpace(const SymMatrixSpace&); + + /** Overloaded Equals Operator */ + SymMatrixSpace& operator=(const SymMatrixSpace&); + //@} + + }; + + /* inline methods */ + inline + SymMatrix::SymMatrix(const SymMatrixSpace* owner_space) + : + Matrix(owner_space), + owner_space_(owner_space) + {} + + inline + Index SymMatrix::Dim() const + { + return owner_space_->Dim(); + } + + inline + SmartPtr<const SymMatrixSpace> SymMatrix::OwnerSymMatrixSpace() const + { + return owner_space_; + } + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpTNLP.hpp b/thirdparty/linux/include/coin/IpTNLP.hpp new file mode 100644 index 0000000..998d38e --- /dev/null +++ b/thirdparty/linux/include/coin/IpTNLP.hpp @@ -0,0 +1,301 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTNLP.hpp 2212 2013-04-14 14:51:52Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPTNLP_HPP__ +#define __IPTNLP_HPP__ + +#include "IpUtils.hpp" +#include "IpReferenced.hpp" +#include "IpException.hpp" +#include "IpAlgTypes.hpp" +#include "IpReturnCodes.hpp" + +#include <map> + +namespace Ipopt +{ + // forward declarations + class IpoptData; + class IpoptCalculatedQuantities; + class IteratesVector; + + /** Base class for all NLP's that use standard triplet matrix form + * and dense vectors. This is the standard base class for all + * NLP's that use the standard triplet matrix form (as for Harwell + * routines) and dense vectors. The class TNLPAdapter then converts + * this interface to an interface that can be used directly by + * ipopt. + * + * This interface presents the problem form: + * + * min f(x) + * + * s.t. gL <= g(x) <= gU + * + * xL <= x <= xU + * + * In order to specify an equality constraint, set gL_i = gU_i = + * rhs. The value that indicates "infinity" for the bounds + * (i.e. the variable or constraint has no lower bound (-infinity) + * or upper bound (+infinity)) is set through the option + * nlp_lower_bound_inf and nlp_upper_bound_inf. To indicate that a + * variable has no upper or lower bound, set the bound to + * -ipopt_inf or +ipopt_inf respectively + */ + class TNLP : public ReferencedObject + { + public: + /** Type of the constraints*/ + enum LinearityType + { + LINEAR/** Constraint/Variable is linear.*/, + NON_LINEAR/**Constraint/Varaible is non-linear.*/ + }; + + /**@name Constructors/Destructors */ + //@{ + TNLP() + {} + + /** Default destructor */ + virtual ~TNLP() + {} + //@} + + DECLARE_STD_EXCEPTION(INVALID_TNLP); + + /**@name methods to gather information about the NLP */ + //@{ + /** overload this method to return the number of variables + * and constraints, and the number of non-zeros in the jacobian and + * the hessian. The index_style parameter lets you specify C or Fortran + * style indexing for the sparse matrix iRow and jCol parameters. + * C_STYLE is 0-based, and FORTRAN_STYLE is 1-based. + */ + enum IndexStyleEnum { C_STYLE=0, FORTRAN_STYLE=1 }; + virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, + Index& nnz_h_lag, IndexStyleEnum& index_style)=0; + + typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType; + typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType; + typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType; + + /** overload this method to return any meta data for + * the variables and the constraints */ + virtual bool get_var_con_metadata(Index n, + StringMetaDataMapType& var_string_md, + IntegerMetaDataMapType& var_integer_md, + NumericMetaDataMapType& var_numeric_md, + Index m, + StringMetaDataMapType& con_string_md, + IntegerMetaDataMapType& con_integer_md, + NumericMetaDataMapType& con_numeric_md) + + { + return false; + } + + /** overload this method to return the information about the bound + * on the variables and constraints. The value that indicates + * that a bound does not exist is specified in the parameters + * nlp_lower_bound_inf and nlp_upper_bound_inf. By default, + * nlp_lower_bound_inf is -1e19 and nlp_upper_bound_inf is + * 1e19. (see TNLPAdapter) */ + virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, + Index m, Number* g_l, Number* g_u)=0; + + /** overload this method to return scaling parameters. This is + * only called if the options are set to retrieve user scaling. + * There, use_x_scaling (or use_g_scaling) should get set to true + * only if the variables (or constraints) are to be scaled. This + * method should return true only if the scaling parameters could + * be provided. + */ + virtual bool get_scaling_parameters(Number& obj_scaling, + bool& use_x_scaling, Index n, + Number* x_scaling, + bool& use_g_scaling, Index m, + Number* g_scaling) + { + return false; + } + + /** overload this method to return the variables linearity + * (TNLP::LINEAR or TNLP::NON_LINEAR). The var_types + * array has been allocated with length at least n. (default implementation + * just return false and does not fill the array).*/ + virtual bool get_variables_linearity(Index n, LinearityType* var_types) + { + return false; + } + + /** overload this method to return the constraint linearity. + * array has been allocated with length at least n. (default implementation + * just return false and does not fill the array).*/ + virtual bool get_constraints_linearity(Index m, LinearityType* const_types) + { + return false; + } + + /** overload this method to return the starting point. The bool + * variables indicate whether the algorithm wants you to + * initialize x, z_L/z_u, and lambda, respectively. If, for some + * reason, the algorithm wants you to initialize these and you + * cannot, return false, which will cause Ipopt to stop. You + * will have to run Ipopt with different options then. + */ + virtual bool get_starting_point(Index n, bool init_x, Number* x, + bool init_z, Number* z_L, Number* z_U, + Index m, bool init_lambda, + Number* lambda)=0; + + /** overload this method to provide an Ipopt iterate (already in + * the form Ipopt requires it internally) for a warm start. + * Since this is only for expert users, a default dummy + * implementation is provided and returns false. */ + virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate) + { + return false; + } + + /** overload this method to return the value of the objective function */ + virtual bool eval_f(Index n, const Number* x, bool new_x, + Number& obj_value)=0; + + /** overload this method to return the vector of the gradient of + * the objective w.r.t. x */ + virtual bool eval_grad_f(Index n, const Number* x, bool new_x, + Number* grad_f)=0; + + /** overload this method to return the vector of constraint values */ + virtual bool eval_g(Index n, const Number* x, bool new_x, + Index m, Number* g)=0; + /** overload this method to return the jacobian of the + * constraints. The vectors iRow and jCol only need to be set + * once. The first call is used to set the structure only (iRow + * and jCol will be non-NULL, and values will be NULL) For + * subsequent calls, iRow and jCol will be NULL. */ + virtual bool eval_jac_g(Index n, const Number* x, bool new_x, + Index m, Index nele_jac, Index* iRow, + Index *jCol, Number* values)=0; + + /** overload this method to return the hessian of the + * lagrangian. The vectors iRow and jCol only need to be set once + * (during the first call). The first call is used to set the + * structure only (iRow and jCol will be non-NULL, and values + * will be NULL) For subsequent calls, iRow and jCol will be + * NULL. This matrix is symmetric - specify the lower diagonal + * only. A default implementation is provided, in case the user + * wants to se quasi-Newton approximations to estimate the second + * derivatives and doesn't not neet to implement this method. */ + virtual bool eval_h(Index n, const Number* x, bool new_x, + Number obj_factor, Index m, const Number* lambda, + bool new_lambda, Index nele_hess, + Index* iRow, Index* jCol, Number* values) + { + return false; + } + //@} + + /** @name Solution Methods */ + //@{ + /** This method is called when the algorithm is complete so the TNLP can store/write the solution */ + virtual void finalize_solution(SolverReturn status, + Index n, const Number* x, const Number* z_L, const Number* z_U, + Index m, const Number* g, const Number* lambda, + Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq)=0; + /** This method is called just before finalize_solution. With + * this method, the algorithm returns any metadata collected + * during its run, including the metadata provided by the user + * with the above get_var_con_metadata. Each metadata can be of + * type string, integer, and numeric. It can be associated to + * either the variables or the constraints. The metadata that + * was associated with the primal variable vector is stored in + * var_..._md. The metadata associated with the constraint + * multipliers is stored in con_..._md. The metadata associated + * with the bound multipliers is stored in var_..._md, with the + * suffixes "_z_L", and "_z_U", denoting lower and upper + * bounds. */ + virtual void finalize_metadata(Index n, + const StringMetaDataMapType& var_string_md, + const IntegerMetaDataMapType& var_integer_md, + const NumericMetaDataMapType& var_numeric_md, + Index m, + const StringMetaDataMapType& con_string_md, + const IntegerMetaDataMapType& con_integer_md, + const NumericMetaDataMapType& con_numeric_md) + {} + + + /** Intermediate Callback method for the user. Providing dummy + * default implementation. For details see IntermediateCallBack + * in IpNLP.hpp. */ + virtual bool intermediate_callback(AlgorithmMode mode, + Index iter, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq) + { + return true; + } + //@} + + /** @name Methods for quasi-Newton approximation. If the second + * derivatives are approximated by Ipopt, it is better to do this + * only in the space of nonlinear variables. The following + * methods are call by Ipopt if the quasi-Newton approximation is + * selected. If -1 is returned as number of nonlinear variables, + * Ipopt assumes that all variables are nonlinear. Otherwise, it + * calls get_list_of_nonlinear_variables with an array into which + * the indices of the nonlinear variables should be written - the + * array has the lengths num_nonlin_vars, which is identical with + * the return value of get_number_of_nonlinear_variables(). It + * is assumed that the indices are counted starting with 1 in the + * FORTRAN_STYLE, and 0 for the C_STYLE. */ + //@{ + virtual Index get_number_of_nonlinear_variables() + { + return -1; + } + + virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, + Index* pos_nonlin_vars) + { + return false; + } + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + //TNLP(); + + /** Copy Constructor */ + TNLP(const TNLP&); + + /** Overloaded Equals Operator */ + void operator=(const TNLP&); + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpTNLPAdapter.hpp b/thirdparty/linux/include/coin/IpTNLPAdapter.hpp new file mode 100644 index 0000000..6eea8e3 --- /dev/null +++ b/thirdparty/linux/include/coin/IpTNLPAdapter.hpp @@ -0,0 +1,427 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTNLPAdapter.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPTNLPADAPTER_HPP__ +#define __IPTNLPADAPTER_HPP__ + +#include "IpNLP.hpp" +#include "IpTNLP.hpp" +#include "IpOrigIpoptNLP.hpp" +#include <list> + +namespace Ipopt +{ + + // forward declarations + class ExpansionMatrix; + class ExpansionMatrixSpace; + class IteratesVector; + class TDependencyDetector; + + /** This class Adapts the TNLP interface so it looks like an NLP interface. + * This is an Adapter class (Design Patterns) that converts a TNLP to an + * NLP. This allows users to write to the "more convenient" TNLP interface. + */ + class TNLPAdapter : public NLP + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor */ + TNLPAdapter(const SmartPtr<TNLP> tnlp, + const SmartPtr<const Journalist> jnlst = NULL); + + /** Default destructor */ + virtual ~TNLPAdapter(); + //@} + + /**@name Exceptions */ + //@{ + DECLARE_STD_EXCEPTION(INVALID_TNLP); + DECLARE_STD_EXCEPTION(ERROR_IN_TNLP_DERIVATIVE_TEST); + //@} + + /** @name TNLPAdapter Initialization. */ + //@{ + virtual bool ProcessOptions(const OptionsList& options, + const std::string& prefix); + + /** Method for creating the derived vector / matrix types + * (Do not delete these, the ). */ + virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space, + SmartPtr<const VectorSpace>& c_space, + SmartPtr<const VectorSpace>& d_space, + SmartPtr<const VectorSpace>& x_l_space, + SmartPtr<const MatrixSpace>& px_l_space, + SmartPtr<const VectorSpace>& x_u_space, + SmartPtr<const MatrixSpace>& px_u_space, + SmartPtr<const VectorSpace>& d_l_space, + SmartPtr<const MatrixSpace>& pd_l_space, + SmartPtr<const VectorSpace>& d_u_space, + SmartPtr<const MatrixSpace>& pd_u_space, + SmartPtr<const MatrixSpace>& Jac_c_space, + SmartPtr<const MatrixSpace>& Jac_d_space, + SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space); + + /** Method for obtaining the bounds information */ + virtual bool GetBoundsInformation(const Matrix& Px_L, + Vector& x_L, + const Matrix& Px_U, + Vector& x_U, + const Matrix& Pd_L, + Vector& d_L, + const Matrix& Pd_U, + Vector& d_U); + + /** Method for obtaining the starting point + * for all the iterates. */ + virtual bool GetStartingPoint( + SmartPtr<Vector> x, + bool need_x, + SmartPtr<Vector> y_c, + bool need_y_c, + SmartPtr<Vector> y_d, + bool need_y_d, + SmartPtr<Vector> z_L, + bool need_z_L, + SmartPtr<Vector> z_U, + bool need_z_U + ); + + /** Method for obtaining an entire iterate as a warmstart point. + * The incoming IteratesVector has to be filled. */ + virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate); + //@} + + /** @name TNLPAdapter evaluation routines. */ + //@{ + virtual bool Eval_f(const Vector& x, Number& f); + + virtual bool Eval_grad_f(const Vector& x, Vector& g_f); + + virtual bool Eval_c(const Vector& x, Vector& c); + + virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c); + + virtual bool Eval_d(const Vector& x, Vector& d); + + virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d); + + virtual bool Eval_h(const Vector& x, + Number obj_factor, + const Vector& yc, + const Vector& yd, + SymMatrix& h); + + virtual void GetScalingParameters( + const SmartPtr<const VectorSpace> x_space, + const SmartPtr<const VectorSpace> c_space, + const SmartPtr<const VectorSpace> d_space, + Number& obj_scaling, + SmartPtr<Vector>& x_scaling, + SmartPtr<Vector>& c_scaling, + SmartPtr<Vector>& d_scaling) const; + //@} + + /** @name Solution Reporting Methods */ + //@{ + virtual void FinalizeSolution(SolverReturn status, + const Vector& x, + const Vector& z_L, const Vector& z_U, + const Vector& c, const Vector& d, + const Vector& y_c, const Vector& y_d, + Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq); + + virtual bool IntermediateCallBack(AlgorithmMode mode, + Index iter, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq); + //@} + + /** Method returning information on quasi-Newton approximation. */ + virtual void + GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space, + SmartPtr<Matrix>& P_approx); + + /** Enum for treatment of fixed variables option */ + enum FixedVariableTreatmentEnum + { + MAKE_PARAMETER=0, + MAKE_CONSTRAINT, + RELAX_BOUNDS + }; + + /** Enum for specifying which derivative test is to be performed. */ + enum DerivativeTestEnum + { + NO_TEST=0, + FIRST_ORDER_TEST, + SECOND_ORDER_TEST, + ONLY_SECOND_ORDER_TEST + }; + + /** Enum for specifying technique for computing Jacobian */ + enum JacobianApproxEnum + { + JAC_EXACT=0, + JAC_FINDIFF_VALUES + }; + + /** Method for performing the derivative test */ + bool CheckDerivatives(DerivativeTestEnum deriv_test, + Index deriv_test_start_index); + + /** @name Methods for IpoptType */ + //@{ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + /** Accessor method for the underlying TNLP. */ + SmartPtr<TNLP> tnlp() const + { + return tnlp_; + } + + /** @name Methods for translating data for IpoptNLP into the TNLP + * data. These methods are used to obtain the current (or + * final) data for the TNLP formulation from the IpoptNLP + * structure. */ + //@{ + /** Sort the primal variables, and add the fixed values in x */ + void ResortX(const Vector& x, Number* x_orig); + void ResortG(const Vector& c, const Vector& d, Number *g_orig); + void ResortBnds(const Vector& x_L, Number* x_L_orig, + const Vector& x_U, Number* x_U_orig); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + TNLPAdapter(const TNLPAdapter&); + + /** Overloaded Equals Operator */ + void operator=(const TNLPAdapter&); + //@} + + /** @name Method implementing the detection of linearly dependent + equality constraints */ + bool DetermineDependentConstraints(Index n_x_var, + const Index* x_not_fixed_map, + const Number* x_l, const Number* x_u, + const Number* g_l, const Number* g_u, + Index n_c, const Index* c_map, + std::list<Index>& c_deps); + + /** Pointer to the TNLP class (class specific to Number* vectors and + * harwell triplet matrices) */ + SmartPtr<TNLP> tnlp_; + + /** Journalist */ + SmartPtr<const Journalist> jnlst_; + + /** Object that can be used to detect linearly dependent rows in + * the equality constraint Jacobian */ + SmartPtr<TDependencyDetector> dependency_detector_; + + /**@name Algorithmic parameters */ + //@{ + /** Value for a lower bound that denotes -infinity */ + Number nlp_lower_bound_inf_; + /** Value for a upper bound that denotes infinity */ + Number nlp_upper_bound_inf_; + /** Flag indicating how fixed variables should be handled */ + FixedVariableTreatmentEnum fixed_variable_treatment_; + /* Determines relaxation of fixing bound for RELAX_BOUNDS. */ + Number bound_relax_factor_; + /* Maximal slack for one-sidedly bounded variables. If a + * variable has only one bound, say a lower bound xL, then an + * upper bound xL + max_onesided_bound_slack_. If this value is + * zero, no upper bound is added. */ + /* Took this out: Number max_onesided_bound_slack_; */ + /** Enum indicating whether and which derivative test should be + * performed at starting point. */ + DerivativeTestEnum derivative_test_; + /** Size of the perturbation for the derivative test */ + Number derivative_test_perturbation_; + /** Relative threshold for marking deviation from finite + * difference test */ + Number derivative_test_tol_; + /** Flag indicating if all test values should be printed, or only + * those violating the threshold. */ + bool derivative_test_print_all_; + /** Index of first quantity to be checked. */ + Index derivative_test_first_index_; + /** Flag indicating whether the TNLP with identical structure has + * already been solved before. */ + bool warm_start_same_structure_; + /** Flag indicating what Hessian information is to be used. */ + HessianApproximationType hessian_approximation_; + /** Number of linear variables. */ + Index num_linear_variables_; + /** Flag indicating how Jacobian is computed. */ + JacobianApproxEnum jacobian_approximation_; + /** Size of the perturbation for the derivative approximation */ + Number findiff_perturbation_; + /** Maximal perturbation of the initial point */ + Number point_perturbation_radius_; + /** Flag indicating if rhs should be considered during dependency + * detection */ + bool dependency_detection_with_rhs_; + + /** Overall convergence tolerance */ + Number tol_; + //@} + + /**@name Problem Size Data */ + //@{ + /** full dimension of x (fixed + non-fixed) */ + Index n_full_x_; + /** full dimension of g (c + d) */ + Index n_full_g_; + /** non-zeros of the jacobian of c */ + Index nz_jac_c_; + /** non-zeros of the jacobian of c without added constraints for + * fixed variables. */ + Index nz_jac_c_no_extra_; + /** non-zeros of the jacobian of d */ + Index nz_jac_d_; + /** number of non-zeros in full-size Jacobian of g */ + Index nz_full_jac_g_; + /** number of non-zeros in full-size Hessian */ + Index nz_full_h_; + /** number of non-zeros in the non-fixed-size Hessian */ + Index nz_h_; + /** Number of fixed variables */ + Index n_x_fixed_; + //@} + + /** Numbering style of variables and constraints */ + TNLP::IndexStyleEnum index_style_; + + /** @name Local copy of spaces (for warm start) */ + //@{ + SmartPtr<const VectorSpace> x_space_; + SmartPtr<const VectorSpace> c_space_; + SmartPtr<const VectorSpace> d_space_; + SmartPtr<const VectorSpace> x_l_space_; + SmartPtr<const MatrixSpace> px_l_space_; + SmartPtr<const VectorSpace> x_u_space_; + SmartPtr<const MatrixSpace> px_u_space_; + SmartPtr<const VectorSpace> d_l_space_; + SmartPtr<const MatrixSpace> pd_l_space_; + SmartPtr<const VectorSpace> d_u_space_; + SmartPtr<const MatrixSpace> pd_u_space_; + SmartPtr<const MatrixSpace> Jac_c_space_; + SmartPtr<const MatrixSpace> Jac_d_space_; + SmartPtr<const SymMatrixSpace> Hess_lagrangian_space_; + //@} + + /**@name Local Copy of the Data */ + //@{ + Number* full_x_; /** copy of the full x vector (fixed & non-fixed) */ + Number* full_lambda_; /** copy of lambda (yc & yd) */ + Number* full_g_; /** copy of g (c & d) */ + Number* jac_g_; /** the values for the full jacobian of g */ + Number* c_rhs_; /** the rhs values of c */ + //@} + + /**@name Tags for deciding when to update internal copies of vectors */ + //@{ + TaggedObject::Tag x_tag_for_iterates_; + TaggedObject::Tag y_c_tag_for_iterates_; + TaggedObject::Tag y_d_tag_for_iterates_; + TaggedObject::Tag x_tag_for_g_; + TaggedObject::Tag x_tag_for_jac_g_; + //@} + + /**@name Methods to update the values in the local copies of vectors */ + //@{ + bool update_local_x(const Vector& x); + bool update_local_lambda(const Vector& y_c, const Vector& y_d); + //@} + + /**@name Internal routines for evaluating g and jac_g (values stored since + * they are used in both c and d routines */ + //@{ + bool internal_eval_g(bool new_x); + bool internal_eval_jac_g(bool new_x); + //@} + + /** @name Internal methods for dealing with finite difference + approxation */ + //@{ + /** Initialize sparsity structure for finite difference Jacobian */ + void initialize_findiff_jac(const Index* iRow, const Index* jCol); + //@} + + /**@name Internal Permutation Spaces and matrices + */ + //@{ + /** Expansion from fixed x (ipopt) to full x */ + SmartPtr<ExpansionMatrix> P_x_full_x_; + SmartPtr<ExpansionMatrixSpace> P_x_full_x_space_; + + /** Expansion from fixed x_L (ipopt) to full x */ + SmartPtr<ExpansionMatrix> P_x_x_L_; + SmartPtr<ExpansionMatrixSpace> P_x_x_L_space_; + + /** Expansion from fixed x_U (ipopt) to full x */ + SmartPtr<ExpansionMatrix> P_x_x_U_; + SmartPtr<ExpansionMatrixSpace> P_x_x_U_space_; + + /** Expansion from c only (ipopt) to full ampl c */ + SmartPtr<ExpansionMatrixSpace> P_c_g_space_; + SmartPtr<ExpansionMatrix> P_c_g_; + + /** Expansion from d only (ipopt) to full ampl d */ + SmartPtr<ExpansionMatrixSpace> P_d_g_space_; + SmartPtr<ExpansionMatrix> P_d_g_; + + Index* jac_idx_map_; + Index* h_idx_map_; + + /** Position of fixed variables. This is required for a warm start */ + Index* x_fixed_map_; + //@} + + /** @name Data for finite difference approximations of derivatives */ + //@{ + /** Number of unique nonzeros in constraint Jacobian */ + Index findiff_jac_nnz_; + /** Start position for nonzero indices in ja for each column of + Jacobian */ + Index* findiff_jac_ia_; + /** Ordered by columns, for each column the row indices in + Jacobian */ + Index* findiff_jac_ja_; + /** Position of entry in original triplet matrix */ + Index* findiff_jac_postriplet_; + /** Copy of the lower bounds */ + Number* findiff_x_l_; + /** Copy of the upper bounds */ + Number* findiff_x_u_; + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpTNLPReducer.hpp b/thirdparty/linux/include/coin/IpTNLPReducer.hpp new file mode 100644 index 0000000..bce1478 --- /dev/null +++ b/thirdparty/linux/include/coin/IpTNLPReducer.hpp @@ -0,0 +1,180 @@ +// Copyright (C) 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTNLPReducer.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Andreas Waechter IBM 2008-08-10 + +#ifndef __IPTNLPREDUCER_HPP__ +#define __IPTNLPREDUCER_HPP__ + +#include "IpTNLP.hpp" + +namespace Ipopt +{ + /** This is a wrapper around a given TNLP class that takes out a + * list of constraints that are given to the constructor. It is + * provided for convenience, if one wants to experiment with + * problems that consist of only a subset of the constraints. But + * keep in mind that this is not efficient, since behind the scenes + * we are still evaluation all functions and derivatives, and are + * making copies of the original data. */ + class TNLPReducer : public TNLP + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor is given the indices of the constraints that + * should be taken out of the problem statement, as well as the + * original TNLP. */ + TNLPReducer(TNLP& tnlp, Index n_g_skip, const Index* index_g_skip, + Index n_xL_skip, const Index* index_xL_skip, + Index n_xU_skip, const Index* index_xU_skip, + Index n_x_fix, const Index* index_f_fix); + + /** Default destructor */ + virtual ~TNLPReducer(); + //@} + + /** @name Overloaded methods from TNLP */ + virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, + Index& nnz_h_lag, IndexStyleEnum& index_style); + + virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, + Index m, Number* g_l, Number* g_u); + + virtual bool get_scaling_parameters(Number& obj_scaling, + bool& use_x_scaling, Index n, + Number* x_scaling, + bool& use_g_scaling, Index m, + Number* g_scaling); + + virtual bool get_variables_linearity(Index n, LinearityType* var_types); + + virtual bool get_constraints_linearity(Index m, LinearityType* const_types); + + virtual bool get_starting_point(Index n, bool init_x, Number* x, + bool init_z, Number* z_L, Number* z_U, + Index m, bool init_lambda, + Number* lambda); + + virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate); + + virtual bool eval_f(Index n, const Number* x, bool new_x, + Number& obj_value); + + virtual bool eval_grad_f(Index n, const Number* x, bool new_x, + Number* grad_f); + + virtual bool eval_g(Index n, const Number* x, bool new_x, + Index m, Number* g); + + virtual bool eval_jac_g(Index n, const Number* x, bool new_x, + Index m, Index nele_jac, Index* iRow, + Index *jCol, Number* values); + + virtual bool eval_h(Index n, const Number* x, bool new_x, + Number obj_factor, Index m, const Number* lambda, + bool new_lambda, Index nele_hess, + Index* iRow, Index* jCol, Number* values); + + virtual void finalize_solution(SolverReturn status, + Index n, const Number* x, const Number* z_L, const Number* z_U, + Index m, const Number* g, const Number* lambda, + Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq); + + virtual bool intermediate_callback(AlgorithmMode mode, + Index iter, Number obj_value, + Number inf_pr, Number inf_du, + Number mu, Number d_norm, + Number regularization_size, + Number alpha_du, Number alpha_pr, + Index ls_trials, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq); + + virtual Index get_number_of_nonlinear_variables(); + + virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, + Index* pos_nonlin_vars); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + TNLPReducer(); + + /** Copy Constructor */ + TNLPReducer(const TNLPReducer&); + + /** Overloaded Equals Operator */ + void operator=(const TNLPReducer&); + //@} + + /** @name original TNLP */ + //@{ + SmartPtr<TNLP> tnlp_; + Index m_orig_; + Index nnz_jac_g_orig_; + //@} + + /** Number of constraints to be skipped */ + Index n_g_skip_; + + /** Array of indices of the constraints that are to be skipped. + * This is provided at the beginning in the constructor. */ + Index* index_g_skip_; + + /** Index style for original problem. Internally, we use C-Style + * now. */ + IndexStyleEnum index_style_orig_; + + /** Map from original constraints to new constraints. A -1 means + * that a constraint is skipped. */ + Index* g_keep_map_; + + /** Number of constraints in reduced NLP */ + Index m_reduced_; + + /** Number of Jacobian nonzeros in the reduced NLP */ + Index nnz_jac_g_reduced_; + + /** Number of Jacobian nonzeros that are skipped */ + Index nnz_jac_g_skipped_; + + /** Array of Jacobian elements that are to be skipped. This is in + * increasing order. */ + Index* jac_g_skipped_; + + /** Number of lower variable bounds to be skipped. */ + Index n_xL_skip_; + + /** Array of indices of the lower variable bounds to be skipped. */ + Index* index_xL_skip_; + + /** Number of upper variable bounds to be skipped. */ + Index n_xU_skip_; + + /** Array of indices of the upper variable bounds to be skipped. */ + Index* index_xU_skip_; + + /** Number of variables that are to be fixed to initial value. */ + Index n_x_fix_; + + /** Array of indices of the variables that are to be fixed. */ + Index* index_x_fix_; + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpTaggedObject.hpp b/thirdparty/linux/include/coin/IpTaggedObject.hpp new file mode 100644 index 0000000..e81b065 --- /dev/null +++ b/thirdparty/linux/include/coin/IpTaggedObject.hpp @@ -0,0 +1,161 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTaggedObject.hpp 2491 2014-05-31 11:17:49Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPTAGGEDOBJECT_HPP__ +#define __IPTAGGEDOBJECT_HPP__ + +#include "IpUtils.hpp" +#include "IpDebug.hpp" +#include "IpReferenced.hpp" +#include "IpObserver.hpp" +#include <limits> + +/* keyword to declare a thread-local variable according to http://en.wikipedia.org/wiki/Thread-local_storage + * GCC < 4.5 on MacOS X does not support TLS + */ +#ifndef IPOPT_THREAD_LOCAL + +#if defined(_MSC_VER) +#define IPOPT_THREAD_LOCAL __declspec(thread) +#elif defined(__APPLE__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 405) +#define IPOPT_THREAD_LOCAL +#else +#define IPOPT_THREAD_LOCAL __thread +#endif + +#endif + +namespace Ipopt +{ + + /** TaggedObject class. + * Often, certain calculations or operations are expensive, + * and it can be very inefficient to perform these calculations + * again if the input to the calculation has not changed + * since the result was last stored. + * This base class provides an efficient mechanism to update + * a tag, indicating that the object has changed. + * Users of a TaggedObject class, need their own Tag data + * member to keep track of the state of the TaggedObject, the + * last time they performed a calculation. A basic use case for + * users of a class inheriting from TaggedObject follows like + * this: + * + * 1. Initialize your own Tag to zero in constructor. + * + * 2. Before an expensive calculation, + * check if the TaggedObject has changed, passing in + * your own Tag, indicating the last time you used + * the object for the calculation. If it has changed, + * perform the calculation again, and store the result. + * If it has not changed, simply return the stored result. + * + * Here is a simple example: + \verbatim + if (vector.HasChanged(my_vector_tag_)) { + my_vector_tag_ = vector.GetTag(); + result = PerformExpensiveCalculation(vector); + return result; + } + else { + return result; + } + \endverbatim + * + * Objects derived from TaggedObject must indicate that they have changed to + * the base class using the protected member function ObjectChanged(). For + * example, a Vector class, inside its own set method, MUST call + * ObjectChanged() to update the internally stored tag for comparison. + */ + class TaggedObject : public ReferencedObject, public Subject + { + public: + /** Type for the Tag values */ + typedef unsigned int Tag; + + /** Constructor. */ + TaggedObject() + : + Subject() + { + ObjectChanged(); + } + + /** Destructor. */ + virtual ~TaggedObject() + {} + + /** Users of TaggedObjects call this to + * update their own internal tags every time + * they perform the expensive operation. + */ + Tag GetTag() const + { + return tag_; + } + + /** Users of TaggedObjects call this to + * check if the object HasChanged since + * they last updated their own internal + * tag. + */ + bool HasChanged(const Tag comparison_tag) const + { + return (comparison_tag == tag_) ? false : true; + } + protected: + /** Objects derived from TaggedObject MUST call this + * method every time their internal state changes to + * update the internal tag for comparison + */ + void ObjectChanged() + { + DBG_START_METH("TaggedObject::ObjectChanged()", 0); + tag_ = unique_tag_; + unique_tag_++; + DBG_ASSERT(unique_tag_ < std::numeric_limits<Tag>::max()); + // The Notify method from the Subject base class notifies all + // registered Observers that this subject has changed. + Notify(Observer::NT_Changed); + } + private: + /**@name Default Compiler Generated Methods (Hidden to avoid + * implicit creation/calling). These methods are not implemented + * and we do not want the compiler to implement them for us, so we + * declare them private and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + TaggedObject(const TaggedObject&); + + /** Overloaded Equals Operator */ + void operator=(const TaggedObject&); + //@} + + /** static data member that is incremented every + * time ANY TaggedObject changes. This allows us + * to obtain a unique Tag when the object changes + */ + static IPOPT_THREAD_LOCAL Tag unique_tag_; + + /** The tag indicating the current state of the object. + * We use this to compare against the comparison_tag + * in the HasChanged method. This member is updated + * from the unique_tag_ every time the object changes. + */ + Tag tag_; + + /** The index indicating the cache priority for this + * TaggedObject. If a result that depended on this + * TaggedObject is cached, it will be cached with this + * priority + */ + Index cache_priority_; + }; +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpTimedTask.hpp b/thirdparty/linux/include/coin/IpTimedTask.hpp new file mode 100644 index 0000000..a1c5bac --- /dev/null +++ b/thirdparty/linux/include/coin/IpTimedTask.hpp @@ -0,0 +1,146 @@ +// Copyright (C) 2006, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTimedTask.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Andreas Waechter IBM 2005-09-19 + +#ifndef __IPTIMEDTASK_HPP__ +#define __IPTIMEDTASK_HPP__ + +#include "IpUtils.hpp" + +namespace Ipopt +{ + /** This class is used to collect timing information for a + * particular task. */ + class TimedTask + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor. */ + TimedTask() + : + total_cputime_(0.), + total_systime_(0.), + total_walltime_(0.), + start_called_(false), + end_called_(true) + {} + + /** Default destructor */ + ~TimedTask() + {} + //@} + + /** Method for resetting time to zero. */ + void Reset() + { + total_cputime_ = 0.; + total_systime_ = 0.; + total_walltime_ = 0.; + start_called_ = false; + end_called_ = true; + } + + /** Method that is called before execution of the task. */ + void Start() + { + DBG_ASSERT(end_called_); + DBG_ASSERT(!start_called_); + end_called_ = false; + start_called_ = true; + start_cputime_ = CpuTime(); + start_systime_ = SysTime(); + start_walltime_ = WallclockTime(); + } + + /** Method that is called after execution of the task. */ + void End() + { + DBG_ASSERT(!end_called_); + DBG_ASSERT(start_called_); + end_called_ = true; + start_called_ = false; + total_cputime_ += CpuTime() - start_cputime_; + total_systime_ += SysTime() - start_systime_; + total_walltime_ += WallclockTime() - start_walltime_; + } + + /** Method that is called after execution of the task for which + * timing might have been started. This only updates the timing + * if the timing has indeed been conducted. This is useful to + * stop timing after catching exceptions. */ + void EndIfStarted() + { + if (start_called_) { + end_called_ = true; + start_called_ = false; + total_cputime_ += CpuTime() - start_cputime_; + total_systime_ += SysTime() - start_systime_; + total_walltime_ += WallclockTime() - start_walltime_; + } + DBG_ASSERT(end_called_); + } + + /** Method returning total CPU time spend for task so far. */ + Number TotalCpuTime() const + { + DBG_ASSERT(end_called_); + return total_cputime_; + } + + /** Method returning total system time spend for task so far. */ + Number TotalSysTime() const + { + DBG_ASSERT(end_called_); + return total_systime_; + } + + /** Method returning total wall clock time spend for task so far. */ + Number TotalWallclockTime() const + { + DBG_ASSERT(end_called_); + return total_walltime_; + } + + private: + /**@name Default Compiler Generated Methods (Hidden to avoid + * implicit creation/calling). These methods are not + * implemented and we do not want the compiler to implement them + * for us, so we declare them private and do not define + * them. This ensures that they will not be implicitly + * created/called. */ + //@{ + /** Copy Constructor */ + TimedTask(const TimedTask&); + + /** Overloaded Equals Operator */ + void operator=(const TimedTask&); + //@} + + /** CPU time at beginning of task. */ + Number start_cputime_; + /** Total CPU time for task measured so far. */ + Number total_cputime_; + /** System time at beginning of task. */ + Number start_systime_; + /** Total system time for task measured so far. */ + Number total_systime_; + /** Wall clock time at beginning of task. */ + Number start_walltime_; + /** Total wall clock time for task measured so far. */ + Number total_walltime_; + + /** @name fields for debugging */ + //@{ + bool start_called_; + bool end_called_; + //@} + + }; +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpTimingStatistics.hpp b/thirdparty/linux/include/coin/IpTimingStatistics.hpp new file mode 100644 index 0000000..850ed1b --- /dev/null +++ b/thirdparty/linux/include/coin/IpTimingStatistics.hpp @@ -0,0 +1,213 @@ +// Copyright (C) 2005, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTimingStatistics.hpp 2005 2011-06-06 12:55:16Z stefan $ +// +// Authors: Andreas Waechter IBM 2005-09-19 + +#ifndef __IPTIMINGSTATISTICS_HPP__ +#define __IPTIMINGSTATISTICS_HPP__ + +#include "IpReferenced.hpp" +#include "IpJournalist.hpp" +#include "IpTimedTask.hpp" + +namespace Ipopt +{ + /** This class collects all timing statistics for Ipopt. + */ + class TimingStatistics : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor. */ + TimingStatistics() + {} + + /** Default destructor */ + virtual ~TimingStatistics() + {} + //@} + + /** Method for resetting all times. */ + void ResetTimes(); + + /** Method for printing all timing information */ + void PrintAllTimingStatistics(Journalist& jnlst, + EJournalLevel level, + EJournalCategory category) const; + + /**@name Accessor methods to all timed tasks. */ + //@{ + TimedTask& OverallAlgorithm() + { + return OverallAlgorithm_; + } + TimedTask& PrintProblemStatistics() + { + return PrintProblemStatistics_; + } + TimedTask& InitializeIterates() + { + return InitializeIterates_; + } + TimedTask& UpdateHessian() + { + return UpdateHessian_; + } + TimedTask& OutputIteration() + { + return OutputIteration_; + } + TimedTask& UpdateBarrierParameter() + { + return UpdateBarrierParameter_; + } + TimedTask& ComputeSearchDirection() + { + return ComputeSearchDirection_; + } + TimedTask& ComputeAcceptableTrialPoint() + { + return ComputeAcceptableTrialPoint_; + } + TimedTask& AcceptTrialPoint() + { + return AcceptTrialPoint_; + } + TimedTask& CheckConvergence() + { + return CheckConvergence_; + } + + TimedTask& PDSystemSolverTotal() + { + return PDSystemSolverTotal_; + } + TimedTask& PDSystemSolverSolveOnce() + { + return PDSystemSolverSolveOnce_; + } + TimedTask& ComputeResiduals() + { + return ComputeResiduals_; + } + TimedTask& StdAugSystemSolverMultiSolve() + { + return StdAugSystemSolverMultiSolve_; + } + TimedTask& LinearSystemScaling() + { + return LinearSystemScaling_; + } + TimedTask& LinearSystemSymbolicFactorization() + { + return LinearSystemSymbolicFactorization_; + } + TimedTask& LinearSystemFactorization() + { + return LinearSystemFactorization_; + } + TimedTask& LinearSystemBackSolve() + { + return LinearSystemBackSolve_; + } + TimedTask& LinearSystemStructureConverter() + { + return LinearSystemStructureConverter_; + } + TimedTask& LinearSystemStructureConverterInit() + { + return LinearSystemStructureConverterInit_; + } + TimedTask& QualityFunctionSearch() + { + return QualityFunctionSearch_; + } + TimedTask& TryCorrector() + { + return TryCorrector_; + } + + TimedTask& Task1() + { + return Task1_; + } + TimedTask& Task2() + { + return Task2_; + } + TimedTask& Task3() + { + return Task3_; + } + TimedTask& Task4() + { + return Task4_; + } + TimedTask& Task5() + { + return Task5_; + } + TimedTask& Task6() + { + return Task6_; + } + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + TimingStatistics(const TimingStatistics&); + + /** Overloaded Equals Operator */ + void operator=(const TimingStatistics&); + //@} + + /**@name All timed tasks. */ + //@{ + TimedTask OverallAlgorithm_; + TimedTask PrintProblemStatistics_; + TimedTask InitializeIterates_; + TimedTask UpdateHessian_; + TimedTask OutputIteration_; + TimedTask UpdateBarrierParameter_; + TimedTask ComputeSearchDirection_; + TimedTask ComputeAcceptableTrialPoint_; + TimedTask AcceptTrialPoint_; + TimedTask CheckConvergence_; + + TimedTask PDSystemSolverTotal_; + TimedTask PDSystemSolverSolveOnce_; + TimedTask ComputeResiduals_; + TimedTask StdAugSystemSolverMultiSolve_; + TimedTask LinearSystemScaling_; + TimedTask LinearSystemSymbolicFactorization_; + TimedTask LinearSystemFactorization_; + TimedTask LinearSystemBackSolve_; + TimedTask LinearSystemStructureConverter_; + TimedTask LinearSystemStructureConverterInit_; + TimedTask QualityFunctionSearch_; + TimedTask TryCorrector_; + + TimedTask Task1_; + TimedTask Task2_; + TimedTask Task3_; + TimedTask Task4_; + TimedTask Task5_; + TimedTask Task6_; + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpTypes.hpp b/thirdparty/linux/include/coin/IpTypes.hpp new file mode 100644 index 0000000..9c41b8f --- /dev/null +++ b/thirdparty/linux/include/coin/IpTypes.hpp @@ -0,0 +1,28 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTypes.hpp 2005 2011-06-06 12:55:16Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPTYPES_HPP__ +#define __IPTYPES_HPP__ + +#include "IpoptConfig.h" + +namespace Ipopt +{ + /** Type of all numbers */ + typedef double Number; + /** Type of all indices of vectors, matrices etc */ + typedef int Index; + /** Type of default integer */ + typedef int Int; + +} // namespace Ipopt + +/* Type of Fortran integer translated into C */ +typedef FORTRAN_INTEGER_TYPE ipfint; + +#endif diff --git a/thirdparty/linux/include/coin/IpUtils.hpp b/thirdparty/linux/include/coin/IpUtils.hpp new file mode 100644 index 0000000..4e5f045 --- /dev/null +++ b/thirdparty/linux/include/coin/IpUtils.hpp @@ -0,0 +1,128 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpUtils.hpp 2167 2013-03-08 11:15:38Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPUTILS_HPP__ +#define __IPUTILS_HPP__ + +// Standard Ip Include Files +#include "IpTypes.hpp" +#include "IpDebug.hpp" + +namespace Ipopt +{ + + inline Index Max(Index a, Index b) + { + return ((a) > (b) ? (a) : (b)); + } + + inline Index Max(Index a, Index b, Index c) + { + Index max = Max(a,b); + max = Max(max, c); + return max; + } + + inline Index Max(Index a, Index b, Index c, Index d) + { + Index max = Max(a, b, c); + max = Max(max, d); + return max; + } + + inline Index Min(Index a, Index b) + { + return ((a) < (b) ? (a) : (b)); + } + + inline Index Min(Index a, Index b, Index c) + { + Index min = Min(a,b); + min = Min(min, c); + return min; + } + + inline Index Min(Index a, Index b, Index c, Index d) + { + Index min = Min(a, b, c); + min = Min(min, d); + return min; + } + + /////////////////////////////////////////// + + inline Number Max(Number a, Number b) + { + return ((a) > (b) ? (a) : (b)); + } + + inline Number Max(Number a, Number b, Number c) + { + Number max = Max(a,b); + max = Max(max, c); + return max; + } + + inline Number Max(Number a, Number b, Number c, Number d) + { + Number max = Max(a, b, c); + max = Max(max, d); + return max; + } + + inline Number Min(Number a, Number b) + { + return ((a) < (b) ? (a) : (b)); + } + + inline Number Min(Number a, Number b, Number c) + { + Number min = Min(a,b); + min = Min(min, c); + return min; + } + + inline Number Min(Number a, Number b, Number c, Number d) + { + Number min = Min(a, b, c); + min = Min(min, d); + return min; + } + + /** Function returning true iff the argument is a valid double number + * (not NaN or Inf). */ + bool IsFiniteNumber(Number val); + + /** Function returning a random number between 0 and 1 */ + Number IpRandom01(); + + /** Function resetting the random number generator */ + void IpResetRandom01(); + + /** method determining CPU time */ + Number CpuTime(); + + /** method determining system time */ + Number SysTime(); + + /** method determining wallclock time since first call */ + Number WallclockTime(); + + /** Method for comparing two numbers within machine precision. The + * return value is true if lhs is less or equal the rhs, relaxing + * this inequality by something a little larger than machine + * precision relative to the absolute value of BasVal. */ + bool Compare_le(Number lhs, Number rhs, Number BasVal); + + /** Method for printing a formatted output to a string with given size. + */ + int Snprintf(char* str, long size, const char* format, ...); + +} //namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpVector.hpp b/thirdparty/linux/include/coin/IpVector.hpp new file mode 100644 index 0000000..a903558 --- /dev/null +++ b/thirdparty/linux/include/coin/IpVector.hpp @@ -0,0 +1,774 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpVector.hpp 2472 2014-04-05 17:47:20Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPVECTOR_HPP__ +#define __IPVECTOR_HPP__ + +#include "IpTypes.hpp" +#include "IpTaggedObject.hpp" +#include "IpCachedResults.hpp" +#include "IpSmartPtr.hpp" +#include "IpJournalist.hpp" +#include "IpException.hpp" + +#include <vector> + +namespace Ipopt +{ + /** Exception that can be used to flag unimplemented linear algebra + * methods */ + DECLARE_STD_EXCEPTION(UNIMPLEMENTED_LINALG_METHOD_CALLED); + + /* forward declarations */ + class VectorSpace; + + /** Vector Base Class. + * This is the base class for all derived vector types. Those vectors + * are meant to store entities like iterates, Lagrangian multipliers, + * constraint values etc. The implementation of a vector type depends + * on the computational environment (e.g. just a double array on a shared + * memory machine, or distributed double arrays for a distributed + * memory machine.) + * + * Deriving from Vector: This class inherits from tagged object to + * implement an advanced caching scheme. Because of this, the + * TaggedObject method ObjectChanged() must be called each time the + * Vector changes. If you overload the XXXX_Impl protected methods, + * this taken care of (along with caching if possible) for you. If + * you have additional methods in your derived class that change the + * underlying data (vector values), you MUST remember to call + * ObjectChanged() AFTER making the change! + */ + class Vector : public TaggedObject + { + public: + /** @name Constructor/Destructor */ + //@{ + /** Constructor. It has to be given a pointer to the + * corresponding VectorSpace. + */ + inline + Vector(const VectorSpace* owner_space); + + /** Destructor */ + inline + virtual ~Vector(); + //@} + + /** Create new Vector of the same type with uninitialized data */ + inline + Vector* MakeNew() const; + + /** Create new Vector of the same type and copy the data over */ + inline + Vector* MakeNewCopy() const; + + /**@name Standard BLAS-1 Operations + * (derived classes do NOT overload these + * methods, instead, overload the + * protected versions of these methods). */ + //@{ + /** Copy the data of the vector x into this vector (DCOPY). */ + inline + void Copy(const Vector& x); + + /** Scales the vector by scalar alpha (DSCAL) */ + void Scal(Number alpha); + + /** Add the multiple alpha of vector x to this vector (DAXPY) */ + inline + void Axpy(Number alpha, const Vector &x); + + /** Computes inner product of vector x with this (DDOT) */ + inline + Number Dot(const Vector &x) const; + + /** Computes the 2-norm of this vector (DNRM2) */ + inline + Number Nrm2() const; + + /** Computes the 1-norm of this vector (DASUM) */ + inline + Number Asum() const; + + /** Computes the max-norm of this vector (based on IDAMAX) */ + inline + Number Amax() const; + //@} + + /** @name Additional (Non-BLAS) Vector Methods + * (derived classes do NOT overload these + * methods, instead, overload the + * protected versions of these methods). */ + //@{ + /** Set each element in the vector to the scalar alpha. */ + inline + void Set(Number alpha); + + /** Element-wise division \f$y_i \gets y_i/x_i\f$*/ + inline + void ElementWiseDivide(const Vector& x); + + /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$ */ + inline + void ElementWiseMultiply(const Vector& x); + + /** Element-wise max against entries in x */ + inline + void ElementWiseMax(const Vector& x); + + /** Element-wise min against entries in x */ + inline + void ElementWiseMin(const Vector& x); + + /** Reciprocates the entries in the vector */ + inline + void ElementWiseReciprocal(); + + /** Absolute values of the entries in the vector */ + inline + void ElementWiseAbs(); + + /** Element-wise square root of the entries in the vector */ + inline + void ElementWiseSqrt(); + + /** Replaces the vector values with their sgn values + ( -1 if x_i < 0, 0 if x_i == 0, and 1 if x_i > 0) + */ + inline + void ElementWiseSgn(); + + /** Add scalar to every vector component */ + inline + void AddScalar(Number scalar); + + /** Returns the maximum value in the vector */ + inline + Number Max() const; + + /** Returns the minimum value in the vector */ + inline + Number Min() const; + + /** Returns the sum of the vector entries */ + inline + Number Sum() const; + + /** Returns the sum of the logs of each vector entry */ + inline + Number SumLogs() const; + //@} + + /** @name Methods for specialized operations. A prototype + * implementation is provided, but for efficient implementation + * those should be specially implemented. + */ + //@{ + /** Add one vector, y = a * v1 + c * y. This is automatically + * reduced to call AddTwoVectors. */ + inline + void AddOneVector(Number a, const Vector& v1, Number c); + + /** Add two vectors, y = a * v1 + b * v2 + c * y. Here, this + * vector is y */ + inline void AddTwoVectors(Number a, const Vector& v1, + Number b, const Vector& v2, Number c); + /** Fraction to the boundary parameter. Computes \f$\alpha = + * \max\{\bar\alpha\in(0,1] : x + \bar\alpha \Delta \geq (1-\tau)x\}\f$ + */ + inline + Number FracToBound(const Vector& delta, Number tau) const; + /** Add the quotient of two vectors, y = a * z/s + c * y. */ + inline + void AddVectorQuotient(Number a, const Vector& z, const Vector& s, + Number c); + //@} + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + inline + bool HasValidNumbers() const; + + /** @name Accessor methods */ + //@{ + /** Dimension of the Vector */ + inline + Index Dim() const; + + /** Return the owner VectorSpace*/ + inline + SmartPtr<const VectorSpace> OwnerSpace() const; + //@} + + /** @name Output methods + * (derived classes do NOT overload these + * methods, instead, overload the + * protected versions of these methods). */ + //@{ + /** Print the entire vector */ + void Print(SmartPtr<const Journalist> jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent=0, + const std::string& prefix="") const; + void Print(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent=0, + const std::string& prefix="") const; + //@} + + protected: + /** @name implementation methods (derived classes MUST + * overload these pure virtual protected methods.) + */ + //@{ + /** Copy the data of the vector x into this vector (DCOPY). */ + virtual void CopyImpl(const Vector& x)=0; + + /** Scales the vector by scalar alpha (DSCAL) */ + virtual void ScalImpl(Number alpha)=0; + + /** Add the multiple alpha of vector x to this vector (DAXPY) */ + virtual void AxpyImpl(Number alpha, const Vector &x)=0; + + /** Computes inner product of vector x with this (DDOT) */ + virtual Number DotImpl(const Vector &x) const =0; + + /** Computes the 2-norm of this vector (DNRM2) */ + virtual Number Nrm2Impl() const =0; + + /** Computes the 1-norm of this vector (DASUM) */ + virtual Number AsumImpl() const =0; + + /** Computes the max-norm of this vector (based on IDAMAX) */ + virtual Number AmaxImpl() const =0; + + /** Set each element in the vector to the scalar alpha. */ + virtual void SetImpl(Number alpha)=0; + + /** Element-wise division \f$y_i \gets y_i/x_i\f$*/ + virtual void ElementWiseDivideImpl(const Vector& x)=0; + + /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$ */ + virtual void ElementWiseMultiplyImpl(const Vector& x)=0; + + /** Element-wise max against entries in x */ + virtual void ElementWiseMaxImpl(const Vector& x)=0; + + /** Element-wise min against entries in x */ + virtual void ElementWiseMinImpl(const Vector& x)=0; + + /** Reciprocates the elements of the vector */ + virtual void ElementWiseReciprocalImpl()=0; + + /** Take elementwise absolute values of the elements of the vector */ + virtual void ElementWiseAbsImpl()=0; + + /** Take elementwise square-root of the elements of the vector */ + virtual void ElementWiseSqrtImpl()=0; + + /** Replaces entries with sgn of the entry */ + virtual void ElementWiseSgnImpl()=0; + + /** Add scalar to every component of vector */ + virtual void AddScalarImpl(Number scalar)=0; + + /** Max value in the vector */ + virtual Number MaxImpl() const=0; + + /** Min number in the vector */ + virtual Number MinImpl() const=0; + + /** Sum of entries in the vector */ + virtual Number SumImpl() const=0; + + /** Sum of logs of entries in the vector */ + virtual Number SumLogsImpl() const=0; + + /** Add two vectors (a * v1 + b * v2). Result is stored in this + vector. */ + virtual void AddTwoVectorsImpl(Number a, const Vector& v1, + Number b, const Vector& v2, Number c); + + /** Fraction to boundary parameter. */ + virtual Number FracToBoundImpl(const Vector& delta, Number tau) const; + + /** Add the quotient of two vectors */ + virtual void AddVectorQuotientImpl(Number a, const Vector& z, + const Vector& s, Number c); + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). A default implementation using Asum is + * provided. */ + virtual bool HasValidNumbersImpl() const; + + /** Print the entire vector */ + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const =0; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + Vector(); + + /** Copy constructor */ + Vector(const Vector&); + + /** Overloaded Equals Operator */ + Vector& operator=(const Vector&); + //@} + + /** Vector Space */ + const SmartPtr<const VectorSpace> owner_space_; + + /**@name CachedResults data members */ + //@{ + /** Cache for dot products */ + mutable CachedResults<Number> dot_cache_; + + mutable TaggedObject::Tag nrm2_cache_tag_; + mutable Number cached_nrm2_; + + mutable TaggedObject::Tag asum_cache_tag_; + mutable Number cached_asum_; + + mutable TaggedObject::Tag amax_cache_tag_; + mutable Number cached_amax_; + + mutable TaggedObject::Tag max_cache_tag_; + mutable Number cached_max_; + + mutable TaggedObject::Tag min_cache_tag_; + mutable Number cached_min_; + + mutable TaggedObject::Tag sum_cache_tag_; + mutable Number cached_sum_; + + mutable TaggedObject::Tag sumlogs_cache_tag_; + mutable Number cached_sumlogs_; + + mutable TaggedObject::Tag valid_cache_tag_; + mutable bool cached_valid_; + + // AW: I removed this cache since it gets in the way for the + // quality function search + // /** Cache for FracToBound */ + // mutable CachedResults<Number> frac_to_bound_cache_; + //@} + + }; + + /** VectorSpace base class, corresponding to the Vector base class. + * For each Vector implementation, a corresponding VectorSpace has + * to be implemented. A VectorSpace is able to create new Vectors + * of a specific type. The VectorSpace should also store + * information that is common to all Vectors of that type. For + * example, the dimension of a Vector is stored in the VectorSpace + * base class. + */ + class VectorSpace : public ReferencedObject + { + public: + /** @name Constructors/Destructors */ + //@{ + /** Constructor, given the dimension of all vectors generated by + * this VectorSpace. + */ + VectorSpace(Index dim); + + /** Destructor */ + virtual ~VectorSpace() + {} + //@} + + /** Pure virtual method for creating a new Vector of the + * corresponding type. + */ + virtual Vector* MakeNew() const=0; + + /** Accessor function for the dimension of the vectors of this type.*/ + Index Dim() const + { + return dim_; + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** default constructor */ + VectorSpace(); + + /** Copy constructor */ + VectorSpace(const VectorSpace&); + + /** Overloaded Equals Operator */ + VectorSpace& operator=(const VectorSpace&); + //@} + + /** Dimension of the vectors in this vector space. */ + const Index dim_; + }; + + /* inline methods */ + inline + Vector::~Vector() + {} + + inline + Vector::Vector(const VectorSpace* owner_space) + : + TaggedObject(), + owner_space_(owner_space), + dot_cache_(10), + nrm2_cache_tag_(0), + asum_cache_tag_(0), + amax_cache_tag_(0), + max_cache_tag_(0), + min_cache_tag_(0), + sum_cache_tag_(0), + sumlogs_cache_tag_(0), + cached_valid_(0) + { + DBG_ASSERT(IsValid(owner_space_)); + } + + inline + Vector* Vector::MakeNew() const + { + return owner_space_->MakeNew(); + } + + inline + Vector* Vector::MakeNewCopy() const + { + // ToDo: We can probably copy also the cached values for Norms etc here + Vector* copy = MakeNew(); + copy->Copy(*this); + return copy; + } + + inline + void Vector::Copy(const Vector& x) + { + CopyImpl(x); + ObjectChanged(); + // Also copy any cached scalar values from the original vector + // ToDo: Check if that is too much overhead + TaggedObject::Tag x_tag = x.GetTag(); + if (x_tag == x.nrm2_cache_tag_) { + nrm2_cache_tag_ = GetTag(); + cached_nrm2_ = x.cached_nrm2_; + } + if (x_tag == x.asum_cache_tag_) { + asum_cache_tag_ = GetTag(); + cached_asum_ = x.cached_asum_; + } + if (x_tag == x.amax_cache_tag_) { + amax_cache_tag_ = GetTag(); + cached_amax_ = x.cached_amax_; + } + if (x_tag == x.max_cache_tag_) { + max_cache_tag_ = GetTag(); + cached_max_ = x.cached_max_; + } + if (x_tag == x.min_cache_tag_) { + min_cache_tag_ = GetTag(); + cached_min_ = x.cached_min_; + } + if (x_tag == x.sum_cache_tag_) { + sum_cache_tag_ = GetTag(); + cached_sum_ = x.cached_sum_; + } + if (x_tag == x.sumlogs_cache_tag_) { + sumlogs_cache_tag_ = GetTag(); + cached_sumlogs_ = x.cached_sumlogs_; + } + } + + inline + void Vector::Axpy(Number alpha, const Vector &x) + { + AxpyImpl(alpha, x); + ObjectChanged(); + } + + inline + Number Vector::Dot(const Vector &x) const + { + // The current implementation of the caching doesn't allow to have + // a dependency of something with itself. Therefore, we use the + // Nrm2 method if the dot product is to be taken with the vector + // itself. Might be more efficient anyway. + if (this==&x) { + Number nrm2 = Nrm2(); + return nrm2*nrm2; + } + Number retValue; + if (!dot_cache_.GetCachedResult2Dep(retValue, this, &x)) { + retValue = DotImpl(x); + dot_cache_.AddCachedResult2Dep(retValue, this, &x); + } + return retValue; + } + + inline + Number Vector::Nrm2() const + { + if (nrm2_cache_tag_ != GetTag()) { + cached_nrm2_ = Nrm2Impl(); + nrm2_cache_tag_ = GetTag(); + } + return cached_nrm2_; + } + + inline + Number Vector::Asum() const + { + if (asum_cache_tag_ != GetTag()) { + cached_asum_ = AsumImpl(); + asum_cache_tag_ = GetTag(); + } + return cached_asum_; + } + + inline + Number Vector::Amax() const + { + if (amax_cache_tag_ != GetTag()) { + cached_amax_ = AmaxImpl(); + amax_cache_tag_ = GetTag(); + } + return cached_amax_; + } + + inline + Number Vector::Sum() const + { + if (sum_cache_tag_ != GetTag()) { + cached_sum_ = SumImpl(); + sum_cache_tag_ = GetTag(); + } + return cached_sum_; + } + + inline + Number Vector::SumLogs() const + { + if (sumlogs_cache_tag_ != GetTag()) { + cached_sumlogs_ = SumLogsImpl(); + sumlogs_cache_tag_ = GetTag(); + } + return cached_sumlogs_; + } + + inline + void Vector::ElementWiseSgn() + { + ElementWiseSgnImpl(); + ObjectChanged(); + } + + inline + void Vector::Set(Number alpha) + { + // Could initialize caches here + SetImpl(alpha); + ObjectChanged(); + } + + inline + void Vector::ElementWiseDivide(const Vector& x) + { + ElementWiseDivideImpl(x); + ObjectChanged(); + } + + inline + void Vector::ElementWiseMultiply(const Vector& x) + { + ElementWiseMultiplyImpl(x); + ObjectChanged(); + } + + inline + void Vector::ElementWiseReciprocal() + { + ElementWiseReciprocalImpl(); + ObjectChanged(); + } + + inline + void Vector::ElementWiseMax(const Vector& x) + { + // Could initialize some caches here + ElementWiseMaxImpl(x); + ObjectChanged(); + } + + inline + void Vector::ElementWiseMin(const Vector& x) + { + // Could initialize some caches here + ElementWiseMinImpl(x); + ObjectChanged(); + } + + inline + void Vector::ElementWiseAbs() + { + // Could initialize some caches here + ElementWiseAbsImpl(); + ObjectChanged(); + } + + inline + void Vector::ElementWiseSqrt() + { + ElementWiseSqrtImpl(); + ObjectChanged(); + } + + inline + void Vector::AddScalar(Number scalar) + { + // Could initialize some caches here + AddScalarImpl(scalar); + ObjectChanged(); + } + + inline + Number Vector::Max() const + { + if (max_cache_tag_ != GetTag()) { + cached_max_ = MaxImpl(); + max_cache_tag_ = GetTag(); + } + return cached_max_; + } + + inline + Number Vector::Min() const + { + if (min_cache_tag_ != GetTag()) { + cached_min_ = MinImpl(); + min_cache_tag_ = GetTag(); + } + return cached_min_; + } + + inline + void Vector::AddOneVector(Number a, const Vector& v1, Number c) + { + AddTwoVectors(a, v1, 0., v1, c); + } + + inline + void Vector::AddTwoVectors(Number a, const Vector& v1, + Number b, const Vector& v2, Number c) + { + AddTwoVectorsImpl(a, v1, b, v2, c); + ObjectChanged(); + } + + inline + Number Vector::FracToBound(const Vector& delta, Number tau) const + { + /* AW: I avoid the caching here, since it leads to overhead in the + quality function search. Caches for this are in + CalculatedQuantities. + Number retValue; + std::vector<const TaggedObject*> tdeps(1); + tdeps[0] = δ + std::vector<Number> sdeps(1); + sdeps[0] = tau; + if (!frac_to_bound_cache_.GetCachedResult(retValue, tdeps, sdeps)) { + retValue = FracToBoundImpl(delta, tau); + frac_to_bound_cache_.AddCachedResult(retValue, tdeps, sdeps); + } + return retValue; + */ + return FracToBoundImpl(delta, tau); + } + + inline + void Vector::AddVectorQuotient(Number a, const Vector& z, + const Vector& s, Number c) + { + AddVectorQuotientImpl(a, z, s, c); + ObjectChanged(); + } + + inline + bool Vector::HasValidNumbers() const + { + if (valid_cache_tag_ != GetTag()) { + cached_valid_ = HasValidNumbersImpl(); + valid_cache_tag_ = GetTag(); + } + return cached_valid_; + } + + inline + Index Vector::Dim() const + { + return owner_space_->Dim(); + } + + inline + SmartPtr<const VectorSpace> Vector::OwnerSpace() const + { + return owner_space_; + } + + inline + VectorSpace::VectorSpace(Index dim) + : + dim_(dim) + {} + +} // namespace Ipopt + +// Macro definitions for debugging vectors +#if COIN_IPOPT_VERBOSITY == 0 +# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) +#else +# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) \ + if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \ + if (dbg_jrnl.Jnlst()!=NULL) { \ + (__vec).Print(dbg_jrnl.Jnlst(), \ + J_ERROR, J_DBG, \ + __vec_name, \ + dbg_jrnl.IndentationLevel()*2, \ + "# "); \ + } \ + } +#endif //if COIN_IPOPT_VERBOSITY == 0 + +#endif diff --git a/thirdparty/linux/include/coin/IpoptConfig.h b/thirdparty/linux/include/coin/IpoptConfig.h new file mode 100644 index 0000000..e7de361 --- /dev/null +++ b/thirdparty/linux/include/coin/IpoptConfig.h @@ -0,0 +1,22 @@ +/* src/Common/config_ipopt.h. Generated by configure. */ +/* src/Common/config_ipopt.h.in. */ + +#ifndef __CONFIG_IPOPT_H__ +#define __CONFIG_IPOPT_H__ + +/* Version number of project */ +#define IPOPT_VERSION "3.12.4" + +/* Major Version number of project */ +#define IPOPT_VERSION_MAJOR 3 + +/* Minor Version number of project */ +#define IPOPT_VERSION_MINOR 12 + +/* Release Version number of project */ +#define IPOPT_VERSION_RELEASE 4 + +/* Define to the C type corresponding to Fortran INTEGER */ +#define FORTRAN_INTEGER_TYPE int + +#endif diff --git a/thirdparty/linux/include/coin/PardisoLoader.h b/thirdparty/linux/include/coin/PardisoLoader.h new file mode 100644 index 0000000..0942521 --- /dev/null +++ b/thirdparty/linux/include/coin/PardisoLoader.h @@ -0,0 +1,41 @@ +/* Copyright (C) 2008 GAMS Development and others + All Rights Reserved. + This code is published under the Eclipse Public License. + + $Id: PardisoLoader.h 2204 2013-04-13 13:49:26Z stefan $ + + Author: Stefan Vigerske +*/ + +#ifndef PARDISOLOADER_H_ +#define PARDISOLOADER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + /** Tries to load a dynamically linked library with Pardiso. + * Return a failure if the library cannot be loaded or not all Pardiso symbols are found. + * @param libname The name under which the Pardiso lib can be found, or NULL to use a default name (libpardiso.SHAREDLIBEXT). + * @param msgbuf A buffer where we can store a failure message. Assumed to be NOT NULL! + * @param msglen Length of the message buffer. + * @return Zero on success, nonzero on failure. + */ + int LSL_loadPardisoLib(const char* libname, char* msgbuf, int msglen); + + /** Unloads a loaded Pardiso library. + * @return Zero on success, nonzero on failure. + */ + int LSL_unloadPardisoLib(); + + /** Indicates whether a Pardiso library has been successfully loaded. + * @return Zero if not loaded, nonzero if handle is loaded + */ + int LSL_isPardisoLoaded(); + + /** Returns name of the shared library that should contain Pardiso */ + char* LSL_PardisoLibraryName(); +#ifdef __cplusplus +} +#endif + +#endif /*PARADISOLOADER_H_*/ diff --git a/thirdparty/linux/include/coin/ThirdParty/defs.h b/thirdparty/linux/include/coin/ThirdParty/defs.h new file mode 100644 index 0000000..2209540 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/defs.h @@ -0,0 +1,161 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * defs.h + * + * This file contains constant definitions + * + * Started 8/27/94 + * George + * + * $Id: defs.h,v 1.1 1998/11/27 17:59:13 karypis Exp $ + * + */ + +#define METISTITLE " METIS 4.0.3 Copyright 1998, Regents of the University of Minnesota\n\n" +#define MAXLINE 1280000 + +#define LTERM (void **) 0 /* List terminator for GKfree() */ + +#define MAXNCON 16 /* The maximum number of constrains */ +#define MAXNOBJ 16 /* The maximum number of objectives */ + +#define PLUS_GAINSPAN 500 /* Parameters for FM buckets */ +#define NEG_GAINSPAN 500 + +#define HTLENGTH ((1<<11)-1) + +/* Meaning of various options[] parameters */ +#define OPTION_PTYPE 0 +#define OPTION_CTYPE 1 +#define OPTION_ITYPE 2 +#define OPTION_RTYPE 3 +#define OPTION_DBGLVL 4 +#define OPTION_OFLAGS 5 +#define OPTION_PFACTOR 6 +#define OPTION_NSEPS 7 + +#define OFLAG_COMPRESS 1 /* Try to compress the graph */ +#define OFLAG_CCMP 2 /* Find and order connected components */ + + +/* Default options for PMETIS */ +#define PMETIS_CTYPE MATCH_SHEM +#define PMETIS_ITYPE IPART_GGPKL +#define PMETIS_RTYPE RTYPE_FM +#define PMETIS_DBGLVL 0 + +/* Default options for KMETIS */ +#define KMETIS_CTYPE MATCH_SHEM +#define KMETIS_ITYPE IPART_PMETIS +#define KMETIS_RTYPE RTYPE_KWAYRANDOM_MCONN +#define KMETIS_DBGLVL 0 + +/* Default options for OEMETIS */ +#define OEMETIS_CTYPE MATCH_SHEM +#define OEMETIS_ITYPE IPART_GGPKL +#define OEMETIS_RTYPE RTYPE_FM +#define OEMETIS_DBGLVL 0 + +/* Default options for ONMETIS */ +#define ONMETIS_CTYPE MATCH_SHEM +#define ONMETIS_ITYPE IPART_GGPKL +#define ONMETIS_RTYPE RTYPE_SEP1SIDED +#define ONMETIS_DBGLVL 0 +#define ONMETIS_OFLAGS OFLAG_COMPRESS +#define ONMETIS_PFACTOR -1 +#define ONMETIS_NSEPS 1 + +/* Default options for McPMETIS */ +#define McPMETIS_CTYPE MATCH_SHEBM_ONENORM +#define McPMETIS_ITYPE IPART_RANDOM +#define McPMETIS_RTYPE RTYPE_FM +#define McPMETIS_DBGLVL 0 + +/* Default options for McKMETIS */ +#define McKMETIS_CTYPE MATCH_SHEBM_ONENORM +#define McKMETIS_ITYPE IPART_McHPMETIS +#define McKMETIS_RTYPE RTYPE_KWAYRANDOM +#define McKMETIS_DBGLVL 0 + +/* Default options for KVMETIS */ +#define KVMETIS_CTYPE MATCH_SHEM +#define KVMETIS_ITYPE IPART_PMETIS +#define KVMETIS_RTYPE RTYPE_KWAYRANDOM +#define KVMETIS_DBGLVL 0 + + +/* Operations supported by stand-alone code */ +#define OP_PMETIS 1 +#define OP_KMETIS 2 +#define OP_OEMETIS 3 +#define OP_ONMETIS 4 +#define OP_ONWMETIS 5 +#define OP_KVMETIS 6 + + +/* Matching Schemes */ +#define MATCH_RM 1 +#define MATCH_HEM 2 +#define MATCH_SHEM 3 +#define MATCH_SHEMKWAY 4 +#define MATCH_SHEBM_ONENORM 5 +#define MATCH_SHEBM_INFNORM 6 +#define MATCH_SBHEM_ONENORM 7 +#define MATCH_SBHEM_INFNORM 8 + +/* Initial partitioning schemes for PMETIS and ONMETIS */ +#define IPART_GGPKL 1 +#define IPART_GGPKLNODE 2 +#define IPART_RANDOM 2 + +/* Refinement schemes for PMETIS */ +#define RTYPE_FM 1 + +/* Initial partitioning schemes for KMETIS */ +#define IPART_PMETIS 1 + +/* Refinement schemes for KMETIS */ +#define RTYPE_KWAYRANDOM 1 +#define RTYPE_KWAYGREEDY 2 +#define RTYPE_KWAYRANDOM_MCONN 3 + +/* Refinement schemes for ONMETIS */ +#define RTYPE_SEP2SIDED 1 +#define RTYPE_SEP1SIDED 2 + +/* Initial Partitioning Schemes for McKMETIS */ +#define IPART_McPMETIS 1 /* Simple McPMETIS */ +#define IPART_McHPMETIS 2 /* horizontally relaxed McPMETIS */ + +#define UNMATCHED -1 + +#define HTABLE_EMPTY -1 + +#define NGR_PASSES 4 /* Number of greedy refinement passes */ +#define NLGR_PASSES 5 /* Number of GR refinement during IPartition */ + +#define LARGENIPARTS 8 /* Number of random initial partitions */ +#define SMALLNIPARTS 3 /* Number of random initial partitions */ + +#define COARSEN_FRACTION 0.75 /* Node reduction between succesive coarsening levels */ +#define COARSEN_FRACTION2 0.90 /* Node reduction between succesive coarsening levels */ +#define UNBALANCE_FRACTION 1.05 + +#define COMPRESSION_FRACTION 0.85 + +#define ORDER_UNBALANCE_FRACTION 1.10 + +#define MMDSWITCH 200 + +#define HORIZONTAL_IMBALANCE 1.05 + +/* Debug Levels */ +#define DBG_TIME 1 /* Perform timing analysis */ +#define DBG_OUTPUT 2 +#define DBG_COARSEN 4 /* Show the coarsening progress */ +#define DBG_REFINE 8 /* Show info on communication during folding */ +#define DBG_IPART 16 /* Show info on initial partition */ +#define DBG_MOVEINFO 32 /* Show info on communication during folding */ +#define DBG_KWAYPINFO 64 /* Show info on communication during folding */ +#define DBG_SEPINFO 128 /* Show info on communication during folding */ diff --git a/thirdparty/linux/include/coin/ThirdParty/dmumps_c.h b/thirdparty/linux/include/coin/ThirdParty/dmumps_c.h new file mode 100644 index 0000000..1d5c2c9 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/dmumps_c.h @@ -0,0 +1,159 @@ +/* + * + * This file is part of MUMPS 4.10.0, built on Tue May 10 12:56:32 UTC 2011 + * + * + * This version of MUMPS is provided to you free of charge. It is public + * domain, based on public domain software developed during the Esprit IV + * European project PARASOL (1996-1999). Since this first public domain + * version in 1999, research and developments have been supported by the + * following institutions: CERFACS, CNRS, ENS Lyon, INPT(ENSEEIHT)-IRIT, + * INRIA, and University of Bordeaux. + * + * The MUMPS team at the moment of releasing this version includes + * Patrick Amestoy, Maurice Bremond, Alfredo Buttari, Abdou Guermouche, + * Guillaume Joslin, Jean-Yves L'Excellent, Francois-Henry Rouet, Bora + * Ucar and Clement Weisbecker. + * + * We are also grateful to Emmanuel Agullo, Caroline Bousquet, Indranil + * Chowdhury, Philippe Combes, Christophe Daniel, Iain Duff, Vincent Espirat, + * Aurelia Fevre, Jacko Koster, Stephane Pralet, Chiara Puglisi, Gregoire + * Richard, Tzvetomila Slavova, Miroslav Tuma and Christophe Voemel who + * have been contributing to this project. + * + * Up-to-date copies of the MUMPS package can be obtained + * from the Web pages: + * http://mumps.enseeiht.fr/ or http://graal.ens-lyon.fr/MUMPS + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY + * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * + * User documentation of any code that uses this software can + * include this complete notice. You can acknowledge (using + * references [1] and [2]) the contribution of this package + * in any scientific publication dependent upon the use of the + * package. You shall use reasonable endeavours to notify + * the authors of the package of this publication. + * + * [1] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent, + * A fully asynchronous multifrontal solver using distributed dynamic + * scheduling, SIAM Journal of Matrix Analysis and Applications, + * Vol 23, No 1, pp 15-41 (2001). + * + * [2] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and + * S. Pralet, Hybrid scheduling for the parallel solution of linear + * systems. Parallel Computing Vol 32 (2), pp 136-156 (2006). + * + */ + +/* Mostly written in march 2002 (JYL) */ + +#ifndef DMUMPS_C_H +#define DMUMPS_C_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mumps_compat.h" +/* Next line defines MUMPS_INT, DMUMPS_COMPLEX and DMUMPS_REAL */ +#include "mumps_c_types.h" + +#ifndef MUMPS_VERSION +/* Protected in case headers of other arithmetics are included */ +#define MUMPS_VERSION "4.10.0" +#endif +#ifndef MUMPS_VERSION_MAX_LEN +#define MUMPS_VERSION_MAX_LEN 14 +#endif + +/* + * Definition of the (simplified) MUMPS C structure. + * NB: DMUMPS_COMPLEX are REAL types in s and d arithmetics. + */ +typedef struct { + + MUMPS_INT sym, par, job; + MUMPS_INT comm_fortran; /* Fortran communicator */ + MUMPS_INT icntl[40]; + DMUMPS_REAL cntl[15]; + MUMPS_INT n; + + MUMPS_INT nz_alloc; /* used in matlab interface to decide if we + free + malloc when we have large variation */ + + /* Assembled entry */ + MUMPS_INT nz; + MUMPS_INT *irn; + MUMPS_INT *jcn; + DMUMPS_COMPLEX *a; + + /* Distributed entry */ + MUMPS_INT nz_loc; + MUMPS_INT *irn_loc; + MUMPS_INT *jcn_loc; + DMUMPS_COMPLEX *a_loc; + + /* Element entry */ + MUMPS_INT nelt; + MUMPS_INT *eltptr; + MUMPS_INT *eltvar; + DMUMPS_COMPLEX *a_elt; + + /* Ordering, if given by user */ + MUMPS_INT *perm_in; + + /* Orderings returned to user */ + MUMPS_INT *sym_perm; /* symmetric permutation */ + MUMPS_INT *uns_perm; /* column permutation */ + + /* Scaling (input only in this version) */ + DMUMPS_REAL *colsca; + DMUMPS_REAL *rowsca; + + /* RHS, solution, ouptput data and statistics */ + DMUMPS_COMPLEX *rhs, *redrhs, *rhs_sparse, *sol_loc; + MUMPS_INT *irhs_sparse, *irhs_ptr, *isol_loc; + MUMPS_INT nrhs, lrhs, lredrhs, nz_rhs, lsol_loc; + MUMPS_INT schur_mloc, schur_nloc, schur_lld; + MUMPS_INT mblock, nblock, nprow, npcol; + MUMPS_INT info[40],infog[40]; + DMUMPS_REAL rinfo[40], rinfog[40]; + + /* Null space */ + MUMPS_INT deficiency; + MUMPS_INT *pivnul_list; + MUMPS_INT *mapping; + + /* Schur */ + MUMPS_INT size_schur; + MUMPS_INT *listvar_schur; + DMUMPS_COMPLEX *schur; + + /* Internal parameters */ + MUMPS_INT instance_number; + DMUMPS_COMPLEX *wk_user; + + /* Version number: length=14 in FORTRAN + 1 for final \0 + 1 for alignment */ + char version_number[MUMPS_VERSION_MAX_LEN + 1 + 1]; + /* For out-of-core */ + char ooc_tmpdir[256]; + char ooc_prefix[64]; + /* To save the matrix in matrix market format */ + char write_problem[256]; + MUMPS_INT lwk_user; + +} DMUMPS_STRUC_C; + + +void MUMPS_CALL +dmumps_c( DMUMPS_STRUC_C * dmumps_par ); + +#ifdef __cplusplus +} +#endif + +#endif /* DMUMPS_C_H */ + diff --git a/thirdparty/linux/include/coin/ThirdParty/macros.h b/thirdparty/linux/include/coin/ThirdParty/macros.h new file mode 100644 index 0000000..fdf0ade --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/macros.h @@ -0,0 +1,143 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * macros.h + * + * This file contains macros used in multilevel + * + * Started 9/25/94 + * George + * + * $Id: macros.h,v 1.1 1998/11/27 17:59:18 karypis Exp $ + * + */ + + +/************************************************************************* +* The following macro returns a random number in the specified range +**************************************************************************/ +#ifdef __VC__ +#define RandomInRange(u) ((rand()>>3)%(u)) +#define RandomInRangeFast(u) ((rand()>>3)%(u)) +#else +#define RandomInRange(u) ((int)(drand48()*((double)(u)))) +#define RandomInRangeFast(u) ((rand()>>3)%(u)) +#endif + + + +#define amax(a, b) ((a) >= (b) ? (a) : (b)) +#define amin(a, b) ((a) >= (b) ? (b) : (a)) + +#define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b))) +#define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b))) +#define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b))) + +#define SWAP(a, b, tmp) \ + do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0) + +#define INC_DEC(a, b, val) \ + do {(a) += (val); (b) -= (val);} while(0) + + +#define scopy(n, a, b) (float *)memcpy((void *)(b), (void *)(a), sizeof(float)*(n)) +#define idxcopy(n, a, b) (idxtype *)memcpy((void *)(b), (void *)(a), sizeof(idxtype)*(n)) + +#define HASHFCT(key, size) ((key)%(size)) + + +/************************************************************************* +* Timer macros +**************************************************************************/ +#define cleartimer(tmr) (tmr = 0.0) +#define starttimer(tmr) (tmr -= seconds()) +#define stoptimer(tmr) (tmr += seconds()) +#define gettimer(tmr) (tmr) + + +/************************************************************************* +* This macro is used to handle dbglvl +**************************************************************************/ +#define IFSET(a, flag, cmd) if ((a)&(flag)) (cmd); + +/************************************************************************* +* These macros are used for debuging memory leaks +**************************************************************************/ +#ifdef DMALLOC +#define imalloc(n, msg) (malloc(sizeof(int)*(n))) +#define fmalloc(n, msg) (malloc(sizeof(float)*(n))) +#define idxmalloc(n, msg) (malloc(sizeof(idxtype)*(n))) +#define ismalloc(n, val, msg) (iset((n), (val), malloc(sizeof(int)*(n)))) +#define idxsmalloc(n, val, msg) (idxset((n), (val), malloc(sizeof(idxtype)*(n)))) +#define GKmalloc(a, b) (malloc((a))) +#endif + +#ifdef DMALLOC +# define MALLOC_CHECK(ptr) \ + if (malloc_verify((ptr)) == DMALLOC_VERIFY_ERROR) { \ + printf("***MALLOC_CHECK failed on line %d of file %s: " #ptr "\n", \ + __LINE__, __FILE__); \ + abort(); \ + } +#else +# define MALLOC_CHECK(ptr) ; +#endif + + + +/************************************************************************* +* This macro converts a length array in a CSR one +**************************************************************************/ +#define MAKECSR(i, n, a) \ + do { \ + for (i=1; i<n; i++) a[i] += a[i-1]; \ + for (i=n; i>0; i--) a[i] = a[i-1]; \ + a[0] = 0; \ + } while(0) + + +/************************************************************************* +* These macros insert and remove nodes from the boundary list +**************************************************************************/ +#define BNDInsert(nbnd, bndind, bndptr, vtx) \ + do { \ + ASSERT(bndptr[vtx] == -1); \ + bndind[nbnd] = vtx; \ + bndptr[vtx] = nbnd++;\ + } while(0) + +#define BNDDelete(nbnd, bndind, bndptr, vtx) \ + do { \ + ASSERT(bndptr[vtx] != -1); \ + bndind[bndptr[vtx]] = bndind[--nbnd]; \ + bndptr[bndind[nbnd]] = bndptr[vtx]; \ + bndptr[vtx] = -1; \ + } while(0) + + + +/************************************************************************* +* These are debugging macros +**************************************************************************/ +#ifdef DEBUG +# define ASSERT(expr) \ + if (!(expr)) { \ + printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \ + __LINE__, __FILE__); \ + abort(); \ + } +#else +# define ASSERT(expr) ; +#endif + +#ifdef DEBUG +# define ASSERTP(expr, msg) \ + if (!(expr)) { \ + printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \ + __LINE__, __FILE__); \ + printf msg ; \ + abort(); \ + } +#else +# define ASSERTP(expr, msg) ; +#endif diff --git a/thirdparty/linux/include/coin/ThirdParty/metis.h b/thirdparty/linux/include/coin/ThirdParty/metis.h new file mode 100644 index 0000000..9512477 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/metis.h @@ -0,0 +1,37 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * metis.h + * + * This file includes all necessary header files + * + * Started 8/27/94 + * George + * + * $Id: metis.h,v 1.1 1998/11/27 17:59:21 karypis Exp $ + */ + + +#include <stdio.h> +#ifdef __STDC__ +#include <stdlib.h> +#else +#include <malloc.h> +#endif +#include <strings.h> +#include <string.h> +#include <ctype.h> +#include <math.h> +#include <stdarg.h> +#include <time.h> + +#ifdef DMALLOC +#include <dmalloc.h> +#endif + +#include <defs.h> +#include <struct.h> +#include <macros.h> +#include <rename.h> +#include <proto.h> + diff --git a/thirdparty/linux/include/coin/ThirdParty/mpi.h b/thirdparty/linux/include/coin/ThirdParty/mpi.h new file mode 100644 index 0000000..7ab0c37 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/mpi.h @@ -0,0 +1,77 @@ +/* + * + * This file is part of MUMPS 4.10.0, built on Tue May 10 12:56:32 UTC 2011 + * + * + * This version of MUMPS is provided to you free of charge. It is public + * domain, based on public domain software developed during the Esprit IV + * European project PARASOL (1996-1999). Since this first public domain + * version in 1999, research and developments have been supported by the + * following institutions: CERFACS, CNRS, ENS Lyon, INPT(ENSEEIHT)-IRIT, + * INRIA, and University of Bordeaux. + * + * The MUMPS team at the moment of releasing this version includes + * Patrick Amestoy, Maurice Bremond, Alfredo Buttari, Abdou Guermouche, + * Guillaume Joslin, Jean-Yves L'Excellent, Francois-Henry Rouet, Bora + * Ucar and Clement Weisbecker. + * + * We are also grateful to Emmanuel Agullo, Caroline Bousquet, Indranil + * Chowdhury, Philippe Combes, Christophe Daniel, Iain Duff, Vincent Espirat, + * Aurelia Fevre, Jacko Koster, Stephane Pralet, Chiara Puglisi, Gregoire + * Richard, Tzvetomila Slavova, Miroslav Tuma and Christophe Voemel who + * have been contributing to this project. + * + * Up-to-date copies of the MUMPS package can be obtained + * from the Web pages: + * http://mumps.enseeiht.fr/ or http://graal.ens-lyon.fr/MUMPS + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY + * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * + * User documentation of any code that uses this software can + * include this complete notice. You can acknowledge (using + * references [1] and [2]) the contribution of this package + * in any scientific publication dependent upon the use of the + * package. You shall use reasonable endeavours to notify + * the authors of the package of this publication. + * + * [1] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent, + * A fully asynchronous multifrontal solver using distributed dynamic + * scheduling, SIAM Journal of Matrix Analysis and Applications, + * Vol 23, No 1, pp 15-41 (2001). + * + * [2] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and + * S. Pralet, Hybrid scheduling for the parallel solution of linear + * systems. Parallel Computing Vol 32 (2), pp 136-156 (2006). + * + */ + +#ifndef MUMPS_MPI_H +#define MUMPS_MPI_H + +/* We define all symbols as extern "C" for users who call MUMPS with its + libseq from a C++ driver. */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the minimum to have the C interface of MUMPS work. + * Most of the time, users who need this file have no call to MPI functions in + * their own code. Hence it is not worth declaring all MPI functions here. + * However if some users come to request some more stub functions of the MPI + * standards, we may add them. But it is not worth doing it until then. */ + +typedef int MPI_Comm; /* Simple type for MPI communicator */ +static MPI_Comm MPI_COMM_WORLD=(MPI_Comm)0; + +int MPI_Init(int *pargc, char ***pargv); +int MPI_Comm_rank(int comm, int *rank); +int MPI_Finalize(void); + +#ifdef __cplusplus +} +#endif + +#endif /* MUMPS_MPI_H */ diff --git a/thirdparty/linux/include/coin/ThirdParty/mumps_c_types.h b/thirdparty/linux/include/coin/ThirdParty/mumps_c_types.h new file mode 100644 index 0000000..aef6212 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/mumps_c_types.h @@ -0,0 +1,92 @@ +/* + * + * This file is part of MUMPS 4.10.0, built on Tue May 10 12:56:32 UTC 2011 + * + * + * This version of MUMPS is provided to you free of charge. It is public + * domain, based on public domain software developed during the Esprit IV + * European project PARASOL (1996-1999). Since this first public domain + * version in 1999, research and developments have been supported by the + * following institutions: CERFACS, CNRS, ENS Lyon, INPT(ENSEEIHT)-IRIT, + * INRIA, and University of Bordeaux. + * + * The MUMPS team at the moment of releasing this version includes + * Patrick Amestoy, Maurice Bremond, Alfredo Buttari, Abdou Guermouche, + * Guillaume Joslin, Jean-Yves L'Excellent, Francois-Henry Rouet, Bora + * Ucar and Clement Weisbecker. + * + * We are also grateful to Emmanuel Agullo, Caroline Bousquet, Indranil + * Chowdhury, Philippe Combes, Christophe Daniel, Iain Duff, Vincent Espirat, + * Aurelia Fevre, Jacko Koster, Stephane Pralet, Chiara Puglisi, Gregoire + * Richard, Tzvetomila Slavova, Miroslav Tuma and Christophe Voemel who + * have been contributing to this project. + * + * Up-to-date copies of the MUMPS package can be obtained + * from the Web pages: + * http://mumps.enseeiht.fr/ or http://graal.ens-lyon.fr/MUMPS + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY + * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * + * User documentation of any code that uses this software can + * include this complete notice. You can acknowledge (using + * references [1] and [2]) the contribution of this package + * in any scientific publication dependent upon the use of the + * package. You shall use reasonable endeavours to notify + * the authors of the package of this publication. + * + * [1] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent, + * A fully asynchronous multifrontal solver using distributed dynamic + * scheduling, SIAM Journal of Matrix Analysis and Applications, + * Vol 23, No 1, pp 15-41 (2001). + * + * [2] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and + * S. Pralet, Hybrid scheduling for the parallel solution of linear + * systems. Parallel Computing Vol 32 (2), pp 136-156 (2006). + * + */ + + +#ifndef MUMPS_C_TYPES_H +#define MUMPS_C_TYPES_H + +#define MUMPS_INT int + +#define SMUMPS_COMPLEX float +#define SMUMPS_REAL float + +#define DMUMPS_COMPLEX double +#define DMUMPS_REAL double + +/* Complex datatypes */ +typedef struct {float r,i;} mumps_complex; +typedef struct {double r,i;} mumps_double_complex; + +#define CMUMPS_COMPLEX mumps_complex +#define CMUMPS_REAL float + +#define ZMUMPS_COMPLEX mumps_double_complex +#define ZMUMPS_REAL double + + +#ifndef mumps_ftnlen +/* When passing a string, what is the type of the extra argument + * passed by value ? */ +# define mumps_ftnlen int +#endif + + +#define MUMPS_ARITH_s 1 +#define MUMPS_ARITH_d 2 +#define MUMPS_ARITH_c 4 +#define MUMPS_ARITH_z 8 + +#define MUMPS_ARITH_REAL ( MUMPS_ARITH_s | MUMPS_ARITH_d ) +#define MUMPS_ARITH_CMPLX ( MUMPS_ARITH_c | MUMPS_ARITH_z ) +#define MUMPS_ARITH_SINGLE ( MUMPS_ARITH_s | MUMPS_ARITH_c ) +#define MUMPS_ARITH_DBL ( MUMPS_ARITH_d | MUMPS_ARITH_z ) + + +#endif /* MUMPS_C_TYPES_H */ diff --git a/thirdparty/linux/include/coin/ThirdParty/mumps_compat.h b/thirdparty/linux/include/coin/ThirdParty/mumps_compat.h new file mode 100644 index 0000000..d63120e --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/mumps_compat.h @@ -0,0 +1,78 @@ +/* + * + * This file is part of MUMPS 4.10.0, built on Tue May 10 12:56:32 UTC 2011 + * + * + * This version of MUMPS is provided to you free of charge. It is public + * domain, based on public domain software developed during the Esprit IV + * European project PARASOL (1996-1999). Since this first public domain + * version in 1999, research and developments have been supported by the + * following institutions: CERFACS, CNRS, ENS Lyon, INPT(ENSEEIHT)-IRIT, + * INRIA, and University of Bordeaux. + * + * The MUMPS team at the moment of releasing this version includes + * Patrick Amestoy, Maurice Bremond, Alfredo Buttari, Abdou Guermouche, + * Guillaume Joslin, Jean-Yves L'Excellent, Francois-Henry Rouet, Bora + * Ucar and Clement Weisbecker. + * + * We are also grateful to Emmanuel Agullo, Caroline Bousquet, Indranil + * Chowdhury, Philippe Combes, Christophe Daniel, Iain Duff, Vincent Espirat, + * Aurelia Fevre, Jacko Koster, Stephane Pralet, Chiara Puglisi, Gregoire + * Richard, Tzvetomila Slavova, Miroslav Tuma and Christophe Voemel who + * have been contributing to this project. + * + * Up-to-date copies of the MUMPS package can be obtained + * from the Web pages: + * http://mumps.enseeiht.fr/ or http://graal.ens-lyon.fr/MUMPS + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY + * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * + * User documentation of any code that uses this software can + * include this complete notice. You can acknowledge (using + * references [1] and [2]) the contribution of this package + * in any scientific publication dependent upon the use of the + * package. You shall use reasonable endeavours to notify + * the authors of the package of this publication. + * + * [1] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent, + * A fully asynchronous multifrontal solver using distributed dynamic + * scheduling, SIAM Journal of Matrix Analysis and Applications, + * Vol 23, No 1, pp 15-41 (2001). + * + * [2] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and + * S. Pralet, Hybrid scheduling for the parallel solution of linear + * systems. Parallel Computing Vol 32 (2), pp 136-156 (2006). + * + */ + +/* Compatibility issues between various Windows versions */ +#ifndef MUMPS_COMPAT_H +#define MUMPS_COMPAT_H + + +#if defined(_WIN32) && ! defined(__MINGW32__) +# define MUMPS_WIN32 1 +#endif + +#ifndef MUMPS_CALL +# ifdef MUMPS_WIN32 +/* Modify/choose between next 2 lines depending + * on your Windows calling conventions */ +/* # define MUMPS_CALL __stdcall */ +# define MUMPS_CALL +# else +# define MUMPS_CALL +# endif +#endif + +#if (__STDC_VERSION__ >= 199901L) +# define MUMPS_INLINE static inline +#else +# define MUMPS_INLINE +#endif + + +#endif /* MUMPS_COMPAT_H */ diff --git a/thirdparty/linux/include/coin/ThirdParty/proto.h b/thirdparty/linux/include/coin/ThirdParty/proto.h new file mode 100644 index 0000000..9b65adf --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/proto.h @@ -0,0 +1,505 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * proto.h + * + * This file contains header files + * + * Started 10/19/95 + * George + * + * $Id: proto.h,v 1.1 1998/11/27 17:59:28 karypis Exp $ + * + */ + +/* balance.c */ +void Balance2Way(CtrlType *, GraphType *, int *, float); +void Bnd2WayBalance(CtrlType *, GraphType *, int *); +void General2WayBalance(CtrlType *, GraphType *, int *); + +/* bucketsort.c */ +void BucketSortKeysInc(int, int, idxtype *, idxtype *, idxtype *); + +/* ccgraph.c */ +void CreateCoarseGraph(CtrlType *, GraphType *, int, idxtype *, idxtype *); +void CreateCoarseGraphNoMask(CtrlType *, GraphType *, int, idxtype *, idxtype *); +void CreateCoarseGraph_NVW(CtrlType *, GraphType *, int, idxtype *, idxtype *); +GraphType *SetUpCoarseGraph(GraphType *, int, int); +void ReAdjustMemory(GraphType *, GraphType *, int); + +/* coarsen.c */ +GraphType *Coarsen2Way(CtrlType *, GraphType *); + +/* compress.c */ +void CompressGraph(CtrlType *, GraphType *, int, idxtype *, idxtype *, idxtype *, idxtype *); +void PruneGraph(CtrlType *, GraphType *, int, idxtype *, idxtype *, idxtype *, float); + +/* debug.c */ +int ComputeCut(GraphType *, idxtype *); +int CheckBnd(GraphType *); +int CheckBnd2(GraphType *); +int CheckNodeBnd(GraphType *, int); +int CheckRInfo(RInfoType *); +int CheckNodePartitionParams(GraphType *); +int IsSeparable(GraphType *); + +/* estmem.c */ +void METIS_EstimateMemory(int *, idxtype *, idxtype *, int *, int *, int *); +void EstimateCFraction(int, idxtype *, idxtype *, float *, float *); +int ComputeCoarseGraphSize(int, idxtype *, idxtype *, int, idxtype *, idxtype *, idxtype *); + +/* fm.c */ +void FM_2WayEdgeRefine(CtrlType *, GraphType *, int *, int); + +/* fortran.c */ +void Change2CNumbering(int, idxtype *, idxtype *); +void Change2FNumbering(int, idxtype *, idxtype *, idxtype *); +void Change2FNumbering2(int, idxtype *, idxtype *); +void Change2FNumberingOrder(int, idxtype *, idxtype *, idxtype *, idxtype *); +void ChangeMesh2CNumbering(int, idxtype *); +void ChangeMesh2FNumbering(int, idxtype *, int, idxtype *, idxtype *); +void ChangeMesh2FNumbering2(int, idxtype *, int, int, idxtype *, idxtype *); + +/* frename.c */ +void METIS_PARTGRAPHRECURSIVE(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphrecursive(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphrecursive_(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphrecursive__(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPARTGRAPHRECURSIVE(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphrecursive(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphrecursive_(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphrecursive__(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void METIS_PARTGRAPHKWAY(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphkway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphkway_(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphkway__(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPARTGRAPHKWAY(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphkway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphkway_(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphkway__(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void METIS_EDGEND(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_edgend(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_edgend_(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_edgend__(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_NODEND(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_nodend(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_nodend_(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_nodend__(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_NODEWND(int *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_nodewnd(int *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_nodewnd_(int *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_nodewnd__(int *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_PARTMESHNODAL(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void metis_partmeshnodal(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void metis_partmeshnodal_(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void metis_partmeshnodal__(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void METIS_PARTMESHDUAL(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void metis_partmeshdual(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void metis_partmeshdual_(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void metis_partmeshdual__(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void METIS_MESHTONODAL(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_meshtonodal(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_meshtonodal_(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_meshtonodal__(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_MESHTODUAL(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_meshtodual(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_meshtodual_(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void metis_meshtodual__(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_ESTIMATEMEMORY(int *, idxtype *, idxtype *, int *, int *, int *); +void metis_estimatememory(int *, idxtype *, idxtype *, int *, int *, int *); +void metis_estimatememory_(int *, idxtype *, idxtype *, int *, int *, int *); +void metis_estimatememory__(int *, idxtype *, idxtype *, int *, int *, int *); +void METIS_MCPARTGRAPHRECURSIVE(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_mcpartgraphrecursive(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_mcpartgraphrecursive_(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_mcpartgraphrecursive__(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_MCPARTGRAPHKWAY(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_mcpartgraphkway(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_mcpartgraphkway_(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_mcpartgraphkway__(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void METIS_PARTGRAPHVKWAY(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphvkway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphvkway_(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void metis_partgraphvkway__(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPARTGRAPHVKWAY(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphvkway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphvkway_(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void metis_wpartgraphvkway__(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); + +/* graph.c */ +void SetUpGraph(GraphType *, int, int, int, idxtype *, idxtype *, idxtype *, idxtype *, int); +void SetUpGraphKway(GraphType *, int, idxtype *, idxtype *); +void SetUpGraph2(GraphType *, int, int, idxtype *, idxtype *, float *, idxtype *); +void VolSetUpGraph(GraphType *, int, int, int, idxtype *, idxtype *, idxtype *, idxtype *, int); +void RandomizeGraph(GraphType *); +int IsConnectedSubdomain(CtrlType *, GraphType *, int, int); +int IsConnected(CtrlType *, GraphType *, int); +int IsConnected2(GraphType *, int); +int FindComponents(CtrlType *, GraphType *, idxtype *, idxtype *); + +/* initpart.c */ +void Init2WayPartition(CtrlType *, GraphType *, int *, float); +void InitSeparator(CtrlType *, GraphType *, float); +void GrowBisection(CtrlType *, GraphType *, int *, float); +void GrowBisectionNode(CtrlType *, GraphType *, float); +void RandomBisection(CtrlType *, GraphType *, int *, float); + +/* kmetis.c */ +void METIS_PartGraphKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPartGraphKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +int MlevelKWayPartitioning(CtrlType *, GraphType *, int, idxtype *, float *, float); + +/* kvmetis.c */ +void METIS_PartGraphVKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPartGraphVKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +int MlevelVolKWayPartitioning(CtrlType *, GraphType *, int, idxtype *, float *, float); + +/* kwayfm.c */ +void Random_KWayEdgeRefine(CtrlType *, GraphType *, int, float *, float, int, int); +void Greedy_KWayEdgeRefine(CtrlType *, GraphType *, int, float *, float, int); +void Greedy_KWayEdgeBalance(CtrlType *, GraphType *, int, float *, float, int); + +/* kwayrefine.c */ +void RefineKWay(CtrlType *, GraphType *, GraphType *, int, float *, float); +void AllocateKWayPartitionMemory(CtrlType *, GraphType *, int); +void ComputeKWayPartitionParams(CtrlType *, GraphType *, int); +void ProjectKWayPartition(CtrlType *, GraphType *, int); +int IsBalanced(idxtype *, int, float *, float); +void ComputeKWayBoundary(CtrlType *, GraphType *, int); +void ComputeKWayBalanceBoundary(CtrlType *, GraphType *, int); + +/* kwayvolfm.c */ +void Random_KWayVolRefine(CtrlType *, GraphType *, int, float *, float, int, int); +void Random_KWayVolRefineMConn(CtrlType *, GraphType *, int, float *, float, int, int); +void Greedy_KWayVolBalance(CtrlType *, GraphType *, int, float *, float, int); +void Greedy_KWayVolBalanceMConn(CtrlType *, GraphType *, int, float *, float, int); +void KWayVolUpdate(CtrlType *, GraphType *, int, int, int, idxtype *, idxtype *, idxtype *); +void ComputeKWayVolume(GraphType *, int, idxtype *, idxtype *, idxtype *); +int ComputeVolume(GraphType *, idxtype *); +void CheckVolKWayPartitionParams(CtrlType *, GraphType *, int); +void ComputeVolSubDomainGraph(GraphType *, int, idxtype *, idxtype *); +void EliminateVolSubDomainEdges(CtrlType *, GraphType *, int, float *); +void EliminateVolComponents(CtrlType *, GraphType *, int, float *, float); + +/* kwayvolrefine.c */ +void RefineVolKWay(CtrlType *, GraphType *, GraphType *, int, float *, float); +void AllocateVolKWayPartitionMemory(CtrlType *, GraphType *, int); +void ComputeVolKWayPartitionParams(CtrlType *, GraphType *, int); +void ComputeKWayVolGains(CtrlType *, GraphType *, int); +void ProjectVolKWayPartition(CtrlType *, GraphType *, int); +void ComputeVolKWayBoundary(CtrlType *, GraphType *, int); +void ComputeVolKWayBalanceBoundary(CtrlType *, GraphType *, int); + +/* match.c */ +void Match_RM(CtrlType *, GraphType *); +void Match_RM_NVW(CtrlType *, GraphType *); +void Match_HEM(CtrlType *, GraphType *); +void Match_SHEM(CtrlType *, GraphType *); + +/* mbalance.c */ +void MocBalance2Way(CtrlType *, GraphType *, float *, float); +void MocGeneral2WayBalance(CtrlType *, GraphType *, float *, float); + +/* mbalance2.c */ +void MocBalance2Way2(CtrlType *, GraphType *, float *, float *); +void MocGeneral2WayBalance2(CtrlType *, GraphType *, float *, float *); +void SelectQueue3(int, float *, float *, int *, int *, PQueueType [MAXNCON][2], float *); + +/* mcoarsen.c */ +GraphType *MCCoarsen2Way(CtrlType *, GraphType *); + +/* memory.c */ +void AllocateWorkSpace(CtrlType *, GraphType *, int); +void FreeWorkSpace(CtrlType *, GraphType *); +int WspaceAvail(CtrlType *); +idxtype *idxwspacemalloc(CtrlType *, int); +void idxwspacefree(CtrlType *, int); +float *fwspacemalloc(CtrlType *, int); +void fwspacefree(CtrlType *, int); +GraphType *CreateGraph(void); +void InitGraph(GraphType *); +void FreeGraph(GraphType *); + +/* mesh.c */ +void METIS_MeshToDual(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_MeshToNodal(int *, int *, idxtype *, int *, int *, idxtype *, idxtype *); +void GENDUALMETIS(int, int, int, idxtype *, idxtype *, idxtype *adjncy); +void TRINODALMETIS(int, int, idxtype *, idxtype *, idxtype *adjncy); +void TETNODALMETIS(int, int, idxtype *, idxtype *, idxtype *adjncy); +void HEXNODALMETIS(int, int, idxtype *, idxtype *, idxtype *adjncy); +void QUADNODALMETIS(int, int, idxtype *, idxtype *, idxtype *adjncy); + +/* meshpart.c */ +void METIS_PartMeshNodal(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); +void METIS_PartMeshDual(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); + +/* mfm.c */ +void MocFM_2WayEdgeRefine(CtrlType *, GraphType *, float *, int); +void SelectQueue(int, float *, float *, int *, int *, PQueueType [MAXNCON][2]); +int BetterBalance(int, float *, float *, float *); +float Compute2WayHLoadImbalance(int, float *, float *); +void Compute2WayHLoadImbalanceVec(int, float *, float *, float *); + +/* mfm2.c */ +void MocFM_2WayEdgeRefine2(CtrlType *, GraphType *, float *, float *, int); +void SelectQueue2(int, float *, float *, int *, int *, PQueueType [MAXNCON][2], float *); +int IsBetter2wayBalance(int, float *, float *, float *); + +/* mincover.o */ +void MinCover(idxtype *, idxtype *, int, int, idxtype *, int *); +int MinCover_Augment(idxtype *, idxtype *, int, idxtype *, idxtype *, idxtype *, int); +void MinCover_Decompose(idxtype *, idxtype *, int, int, idxtype *, idxtype *, int *); +void MinCover_ColDFS(idxtype *, idxtype *, int, idxtype *, idxtype *, int); +void MinCover_RowDFS(idxtype *, idxtype *, int, idxtype *, idxtype *, int); + +/* minitpart.c */ +void MocInit2WayPartition(CtrlType *, GraphType *, float *, float); +void MocGrowBisection(CtrlType *, GraphType *, float *, float); +void MocRandomBisection(CtrlType *, GraphType *, float *, float); +void MocInit2WayBalance(CtrlType *, GraphType *, float *); +int SelectQueueoneWay(int, float *, float *, int, PQueueType [MAXNCON][2]); + +/* minitpart2.c */ +void MocInit2WayPartition2(CtrlType *, GraphType *, float *, float *); +void MocGrowBisection2(CtrlType *, GraphType *, float *, float *); +void MocGrowBisectionNew2(CtrlType *, GraphType *, float *, float *); +void MocInit2WayBalance2(CtrlType *, GraphType *, float *, float *); +int SelectQueueOneWay2(int, float *, PQueueType [MAXNCON][2], float *); + +/* mkmetis.c */ +void METIS_mCPartGraphKway(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +int MCMlevelKWayPartitioning(CtrlType *, GraphType *, int, idxtype *, float *); + +/* mkwayfmh.c */ +void MCRandom_KWayEdgeRefineHorizontal(CtrlType *, GraphType *, int, float *, int); +void MCGreedy_KWayEdgeBalanceHorizontal(CtrlType *, GraphType *, int, float *, int); +int AreAllHVwgtsBelow(int, float, float *, float, float *, float *); +int AreAllHVwgtsAbove(int, float, float *, float, float *, float *); +void ComputeHKWayLoadImbalance(int, int, float *, float *); +int MocIsHBalanced(int, int, float *, float *); +int IsHBalanceBetterFT(int, int, float *, float *, float *, float *); +int IsHBalanceBetterTT(int, int, float *, float *, float *, float *); + +/* mkwayrefine.c */ +void MocRefineKWayHorizontal(CtrlType *, GraphType *, GraphType *, int, float *); +void MocAllocateKWayPartitionMemory(CtrlType *, GraphType *, int); +void MocComputeKWayPartitionParams(CtrlType *, GraphType *, int); +void MocProjectKWayPartition(CtrlType *, GraphType *, int); +void MocComputeKWayBalanceBoundary(CtrlType *, GraphType *, int); + +/* mmatch.c */ +void MCMatch_RM(CtrlType *, GraphType *); +void MCMatch_HEM(CtrlType *, GraphType *); +void MCMatch_SHEM(CtrlType *, GraphType *); +void MCMatch_SHEBM(CtrlType *, GraphType *, int); +void MCMatch_SBHEM(CtrlType *, GraphType *, int); +float BetterVBalance(int, int, float *, float *, float *); +int AreAllVwgtsBelowFast(int, float *, float *, float); + +/* mmd.c */ +void genmmd(int, idxtype *, idxtype *, idxtype *, idxtype *, int , idxtype *, idxtype *, idxtype *, idxtype *, int, int *); +void mmdelm(int, idxtype *xadj, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, int, int); +int mmdint(int, idxtype *xadj, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *); +void mmdnum(int, idxtype *, idxtype *, idxtype *); +void mmdupd(int, int, idxtype *, idxtype *, int, int *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, int, int *tag); + +/* mpmetis.c */ +void METIS_mCPartGraphRecursive(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_mCHPartGraphRecursive(int *, int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void METIS_mCPartGraphRecursiveInternal(int *, int *, idxtype *, idxtype *, float *, idxtype *, int *, int *, int *, idxtype *); +void METIS_mCHPartGraphRecursiveInternal(int *, int *, idxtype *, idxtype *, float *, idxtype *, int *, float *, int *, int *, idxtype *); +int MCMlevelRecursiveBisection(CtrlType *, GraphType *, int, idxtype *, float, int); +int MCHMlevelRecursiveBisection(CtrlType *, GraphType *, int, idxtype *, float *, int); +void MCMlevelEdgeBisection(CtrlType *, GraphType *, float *, float); +void MCHMlevelEdgeBisection(CtrlType *, GraphType *, float *, float *); + +/* mrefine.c */ +void MocRefine2Way(CtrlType *, GraphType *, GraphType *, float *, float); +void MocAllocate2WayPartitionMemory(CtrlType *, GraphType *); +void MocCompute2WayPartitionParams(CtrlType *, GraphType *); +void MocProject2WayPartition(CtrlType *, GraphType *); + +/* mrefine2.c */ +void MocRefine2Way2(CtrlType *, GraphType *, GraphType *, float *, float *); + +/* mutil.c */ +int AreAllVwgtsBelow(int, float, float *, float, float *, float); +int AreAnyVwgtsBelow(int, float, float *, float, float *, float); +int AreAllVwgtsAbove(int, float, float *, float, float *, float); +float ComputeLoadImbalance(int, int, float *, float *); +int AreAllBelow(int, float *, float *); + +/* myqsort.c */ +void iidxsort(int, idxtype *); +void iintsort(int, int *); +void ikeysort(int, KeyValueType *); +void ikeyvalsort(int, KeyValueType *); + +/* ometis.c */ +void METIS_EdgeND(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_NodeND(int *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void METIS_NodeWND(int *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *, idxtype *); +void MlevelNestedDissection(CtrlType *, GraphType *, idxtype *, float, int); +void MlevelNestedDissectionCC(CtrlType *, GraphType *, idxtype *, float, int); +void MlevelNodeBisectionMultiple(CtrlType *, GraphType *, int *, float); +void MlevelNodeBisection(CtrlType *, GraphType *, int *, float); +void SplitGraphOrder(CtrlType *, GraphType *, GraphType *, GraphType *); +void MMDOrder(CtrlType *, GraphType *, idxtype *, int); +int SplitGraphOrderCC(CtrlType *, GraphType *, GraphType *, int, idxtype *, idxtype *); + +/* parmetis.c */ +void METIS_PartGraphKway2(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPartGraphKway2(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +void METIS_NodeNDP(int, idxtype *, idxtype *, int, int *, idxtype *, idxtype *, idxtype *); +void MlevelNestedDissectionP(CtrlType *, GraphType *, idxtype *, int, int, int, idxtype *); +void METIS_NodeComputeSeparator(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *); +void METIS_EdgeComputeSeparator(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, idxtype *); + +/* pmetis.c */ +void METIS_PartGraphRecursive(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); +void METIS_WPartGraphRecursive(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, float *, int *, int *, idxtype *); +int MlevelRecursiveBisection(CtrlType *, GraphType *, int, idxtype *, float *, float, int); +void MlevelEdgeBisection(CtrlType *, GraphType *, int *, float); +void SplitGraphPart(CtrlType *, GraphType *, GraphType *, GraphType *); +void SetUpSplitGraph(GraphType *, GraphType *, int, int); + +/* pqueue.c */ +void PQueueInit(CtrlType *ctrl, PQueueType *, int, int); +void PQueueReset(PQueueType *); +void PQueueFree(CtrlType *ctrl, PQueueType *); +int PQueueGetSize(PQueueType *); +int PQueueInsert(PQueueType *, int, int); +int PQueueDelete(PQueueType *, int, int); +int PQueueUpdate(PQueueType *, int, int, int); +void PQueueUpdateUp(PQueueType *, int, int, int); +int PQueueGetMax(PQueueType *); +int PQueueSeeMax(PQueueType *); +int PQueueGetKey(PQueueType *); +int CheckHeap(PQueueType *); + +/* refine.c */ +void Refine2Way(CtrlType *, GraphType *, GraphType *, int *, float ubfactor); +void Allocate2WayPartitionMemory(CtrlType *, GraphType *); +void Compute2WayPartitionParams(CtrlType *, GraphType *); +void Project2WayPartition(CtrlType *, GraphType *); + +/* separator.c */ +void ConstructSeparator(CtrlType *, GraphType *, float); +void ConstructMinCoverSeparator0(CtrlType *, GraphType *, float); +void ConstructMinCoverSeparator(CtrlType *, GraphType *, float); + +/* sfm.c */ +void FM_2WayNodeRefine(CtrlType *, GraphType *, float, int); +void FM_2WayNodeRefineEqWgt(CtrlType *, GraphType *, int); +void FM_2WayNodeRefine_OneSided(CtrlType *, GraphType *, float, int); +void FM_2WayNodeBalance(CtrlType *, GraphType *, float); +int ComputeMaxNodeGain(int, idxtype *, idxtype *, idxtype *); + +/* srefine.c */ +void Refine2WayNode(CtrlType *, GraphType *, GraphType *, float); +void Allocate2WayNodePartitionMemory(CtrlType *, GraphType *); +void Compute2WayNodePartitionParams(CtrlType *, GraphType *); +void Project2WayNodePartition(CtrlType *, GraphType *); + +/* stat.c */ +void ComputePartitionInfo(GraphType *, int, idxtype *); +void ComputePartitionInfoBipartite(GraphType *, int, idxtype *); +void ComputePartitionBalance(GraphType *, int, idxtype *, float *); +float ComputeElementBalance(int, int, idxtype *); + +/* subdomains.c */ +void Random_KWayEdgeRefineMConn(CtrlType *, GraphType *, int, float *, float, int, int); +void Greedy_KWayEdgeBalanceMConn(CtrlType *, GraphType *, int, float *, float, int); +void PrintSubDomainGraph(GraphType *, int, idxtype *); +void ComputeSubDomainGraph(GraphType *, int, idxtype *, idxtype *); +void EliminateSubDomainEdges(CtrlType *, GraphType *, int, float *); +void MoveGroupMConn(CtrlType *, GraphType *, idxtype *, idxtype *, int, int, int, idxtype *); +void EliminateComponents(CtrlType *, GraphType *, int, float *, float); +void MoveGroup(CtrlType *, GraphType *, int, int, int, idxtype *, idxtype *); + +/* timing.c */ +void InitTimers(CtrlType *); +void PrintTimers(CtrlType *); +double seconds(void); + +/* util.c */ +void errexit(char *,...); +#ifndef DMALLOC +int *imalloc(int, char *); +idxtype *idxmalloc(int, char *); +float *fmalloc(int, char *); +int *ismalloc(int, int, char *); +idxtype *idxsmalloc(int, idxtype, char *); +void *GKmalloc(int, char *); +#endif +/*void GKfree(void **,...); */ +int *iset(int n, int val, int *x); +idxtype *idxset(int n, idxtype val, idxtype *x); +float *sset(int n, float val, float *x); +int iamax(int, int *); +int idxamax(int, idxtype *); +int idxamax_strd(int, idxtype *, int); +int samax(int, float *); +int samax2(int, float *); +int idxamin(int, idxtype *); +int samin(int, float *); +int idxsum(int, idxtype *); +int idxsum_strd(int, idxtype *, int); +void idxadd(int, idxtype *, idxtype *); +int charsum(int, char *); +int isum(int, int *); +float ssum(int, float *); +float ssum_strd(int n, float *x, int); +void sscale(int n, float, float *x); +float snorm2(int, float *); +float sdot(int n, float *, float *); +void saxpy(int, float, float *, int, float *, int); +void RandomPermute(int, idxtype *, int); +double drand48(); +void srand48(long); +int ispow2(int); +void InitRandom(int); +int ilog2(int); + + + + + + + + + + +/*************************************************************** +* Programs Directory +****************************************************************/ + +/* io.c */ +void ReadGraph(GraphType *, char *, int *); +void WritePartition(char *, idxtype *, int, int); +void WriteMeshPartition(char *, int, int, idxtype *, int, idxtype *); +void WritePermutation(char *, idxtype *, int); +int CheckGraph(GraphType *); +idxtype *ReadMesh(char *, int *, int *, int *); +void WriteGraph(char *, int, idxtype *, idxtype *); + +/* smbfactor.c */ +void ComputeFillIn(GraphType *, idxtype *); +idxtype ComputeFillIn2(GraphType *, idxtype *); +int smbfct(int, idxtype *, idxtype *, idxtype *, idxtype *, idxtype *, int *, idxtype *, idxtype *, int *); + + +/*************************************************************** +* Test Directory +****************************************************************/ +void Test_PartGraph(int, idxtype *, idxtype *); +int VerifyPart(int, idxtype *, idxtype *, idxtype *, idxtype *, int, int, idxtype *); +int VerifyWPart(int, idxtype *, idxtype *, idxtype *, idxtype *, int, float *, int, idxtype *); +void Test_PartGraphV(int, idxtype *, idxtype *); +int VerifyPartV(int, idxtype *, idxtype *, idxtype *, idxtype *, int, int, idxtype *); +int VerifyWPartV(int, idxtype *, idxtype *, idxtype *, idxtype *, int, float *, int, idxtype *); +void Test_PartGraphmC(int, idxtype *, idxtype *); +int VerifyPartmC(int, int, idxtype *, idxtype *, idxtype *, idxtype *, int, float *, int, idxtype *); +void Test_ND(int, idxtype *, idxtype *); +int VerifyND(int, idxtype *, idxtype *); + diff --git a/thirdparty/linux/include/coin/ThirdParty/rename.h b/thirdparty/linux/include/coin/ThirdParty/rename.h new file mode 100644 index 0000000..d096b46 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/rename.h @@ -0,0 +1,418 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * rename.h + * + * This file contains header files + * + * Started 10/2/97 + * George + * + * $Id: rename.h,v 1.1 1998/11/27 17:59:29 karypis Exp $ + * + */ + +/* balance.c */ +#define Balance2Way __Balance2Way +#define Bnd2WayBalance __Bnd2WayBalance +#define General2WayBalance __General2WayBalance + + +/* bucketsort.c */ +#define BucketSortKeysInc __BucketSortKeysInc + + +/* ccgraph.c */ +#define CreateCoarseGraph __CreateCoarseGraph +#define CreateCoarseGraphNoMask __CreateCoarseGraphNoMask +#define CreateCoarseGraph_NVW __CreateCoarseGraph_NVW +#define SetUpCoarseGraph __SetUpCoarseGraph +#define ReAdjustMemory __ReAdjustMemory + + +/* coarsen.c */ +#define Coarsen2Way __Coarsen2Way + + +/* compress.c */ +#define CompressGraph __CompressGraph +#define PruneGraph __PruneGraph + + +/* debug.c */ +#define ComputeCut __ComputeCut +#define CheckBnd __CheckBnd +#define CheckBnd2 __CheckBnd2 +#define CheckNodeBnd __CheckNodeBnd +#define CheckRInfo __CheckRInfo +#define CheckNodePartitionParams __CheckNodePartitionParams +#define IsSeparable __IsSeparable + + +/* estmem.c */ +#define EstimateCFraction __EstimateCFraction +#define ComputeCoarseGraphSize __ComputeCoarseGraphSize + + +/* fm.c */ +#define FM_2WayEdgeRefine __FM_2WayEdgeRefine + + +/* fortran.c */ +#define Change2CNumbering __Change2CNumbering +#define Change2FNumbering __Change2FNumbering +#define Change2FNumbering2 __Change2FNumbering2 +#define Change2FNumberingOrder __Change2FNumberingOrder +#define ChangeMesh2CNumbering __ChangeMesh2CNumbering +#define ChangeMesh2FNumbering __ChangeMesh2FNumbering +#define ChangeMesh2FNumbering2 __ChangeMesh2FNumbering2 + + +/* graph.c */ +#define SetUpGraph __SetUpGraph +#define SetUpGraphKway __SetUpGraphKway +#define SetUpGraph2 __SetUpGraph2 +#define VolSetUpGraph __VolSetUpGraph +#define RandomizeGraph __RandomizeGraph +#define IsConnectedSubdomain __IsConnectedSubdomain +#define IsConnected __IsConnected +#define IsConnected2 __IsConnected2 +#define FindComponents __FindComponents + + +/* initpart.c */ +#define Init2WayPartition __Init2WayPartition +#define InitSeparator __InitSeparator +#define GrowBisection __GrowBisection +#define GrowBisectionNode __GrowBisectionNode +#define RandomBisection __RandomBisection + + +/* kmetis.c */ +#define MlevelKWayPartitioning __MlevelKWayPartitioning + + +/* kvmetis.c */ +#define MlevelVolKWayPartitioning __MlevelVolKWayPartitioning + + +/* kwayfm.c */ +#define Random_KWayEdgeRefine __Random_KWayEdgeRefine +#define Greedy_KWayEdgeRefine __Greedy_KWayEdgeRefine +#define Greedy_KWayEdgeBalance __Greedy_KWayEdgeBalance + + +/* kwayrefine.c */ +#define RefineKWay __RefineKWay +#define AllocateKWayPartitionMemory __AllocateKWayPartitionMemory +#define ComputeKWayPartitionParams __ComputeKWayPartitionParams +#define ProjectKWayPartition __ProjectKWayPartition +#define IsBalanced __IsBalanced +#define ComputeKWayBoundary __ComputeKWayBoundary +#define ComputeKWayBalanceBoundary __ComputeKWayBalanceBoundary + + +/* kwayvolfm.c */ +#define Random_KWayVolRefine __Random_KWayVolRefine +#define Random_KWayVolRefineMConn __Random_KWayVolRefineMConn +#define Greedy_KWayVolBalance __Greedy_KWayVolBalance +#define Greedy_KWayVolBalanceMConn __Greedy_KWayVolBalanceMConn +#define KWayVolUpdate __KWayVolUpdate +#define ComputeKWayVolume __ComputeKWayVolume +#define ComputeVolume __ComputeVolume +#define CheckVolKWayPartitionParams __CheckVolKWayPartitionParams +#define ComputeVolSubDomainGraph __ComputeVolSubDomainGraph +#define EliminateVolSubDomainEdges __EliminateVolSubDomainEdges + + +/* kwayvolrefine.c */ +#define RefineVolKWay __RefineVolKWay +#define AllocateVolKWayPartitionMemory __AllocateVolKWayPartitionMemory +#define ComputeVolKWayPartitionParams __ComputeVolKWayPartitionParams +#define ComputeKWayVolGains __ComputeKWayVolGains +#define ProjectVolKWayPartition __ProjectVolKWayPartition +#define ComputeVolKWayBoundary __ComputeVolKWayBoundary +#define ComputeVolKWayBalanceBoundary __ComputeVolKWayBalanceBoundary + + +/* match.c */ +#define Match_RM __Match_RM +#define Match_RM_NVW __Match_RM_NVW +#define Match_HEM __Match_HEM +#define Match_SHEM __Match_SHEM + + +/* mbalance.c */ +#define MocBalance2Way __MocBalance2Way +#define MocGeneral2WayBalance __MocGeneral2WayBalance + + +/* mbalance2.c */ +#define MocBalance2Way2 __MocBalance2Way2 +#define MocGeneral2WayBalance2 __MocGeneral2WayBalance2 +#define SelectQueue3 __SelectQueue3 + + +/* mcoarsen.c */ +#define MCCoarsen2Way __MCCoarsen2Way + + +/* memory.c */ +#define AllocateWorkSpace __AllocateWorkSpace +#define FreeWorkSpace __FreeWorkSpace +#define WspaceAvail __WspaceAvail +#define idxwspacemalloc __idxwspacemalloc +#define idxwspacefree __idxwspacefree +#define fwspacemalloc __fwspacemalloc +#define CreateGraph __CreateGraph +#define InitGraph __InitGraph +#define FreeGraph __FreeGraph + + +/* mesh.c */ +#define TRIDUALMETIS __TRIDUALMETIS +#define TETDUALMETIS __TETDUALMETIS +#define HEXDUALMETIS __HEXDUALMETIS +#define TRINODALMETIS __TRINODALMETIS +#define TETNODALMETIS __TETNODALMETIS +#define HEXNODALMETIS __HEXNODALMETIS + + +/* mfm.c */ +#define MocFM_2WayEdgeRefine __MocFM_2WayEdgeRefine +#define SelectQueue __SelectQueue +#define BetterBalance __BetterBalance +#define Compute2WayHLoadImbalance __Compute2WayHLoadImbalance +#define Compute2WayHLoadImbalanceVec __Compute2WayHLoadImbalanceVec + + +/* mfm2.c */ +#define MocFM_2WayEdgeRefine2 __MocFM_2WayEdgeRefine2 +#define SelectQueue2 __SelectQueue2 +#define IsBetter2wayBalance __IsBetter2wayBalance + + +/* mincover.c */ +#define MinCover __MinCover +#define MinCover_Augment __MinCover_Augment +#define MinCover_Decompose __MinCover_Decompose +#define MinCover_ColDFS __MinCover_ColDFS +#define MinCover_RowDFS __MinCover_RowDFS + + +/* minitpart.c */ +#define MocInit2WayPartition __MocInit2WayPartition +#define MocGrowBisection __MocGrowBisection +#define MocRandomBisection __MocRandomBisection +#define MocInit2WayBalance __MocInit2WayBalance +#define SelectQueueoneWay __SelectQueueoneWay + + +/* minitpart2.c */ +#define MocInit2WayPartition2 __MocInit2WayPartition2 +#define MocGrowBisection2 __MocGrowBisection2 +#define MocGrowBisectionNew2 __MocGrowBisectionNew2 +#define MocInit2WayBalance2 __MocInit2WayBalance2 +#define SelectQueueOneWay2 __SelectQueueOneWay2 + + +/* mkmetis.c */ +#define MCMlevelKWayPartitioning __MCMlevelKWayPartitioning + + +/* mkwayfmh.c */ +#define MCRandom_KWayEdgeRefineHorizontal __MCRandom_KWayEdgeRefineHorizontal +#define MCGreedy_KWayEdgeBalanceHorizontal __MCGreedy_KWayEdgeBalanceHorizontal +#define AreAllHVwgtsBelow __AreAllHVwgtsBelow +#define AreAllHVwgtsAbove __AreAllHVwgtsAbove +#define ComputeHKWayLoadImbalance __ComputeHKWayLoadImbalance +#define MocIsHBalanced __MocIsHBalanced +#define IsHBalanceBetterFT __IsHBalanceBetterFT +#define IsHBalanceBetterTT __IsHBalanceBetterTT + + +/* mkwayrefine.c */ +#define MocRefineKWayHorizontal __MocRefineKWayHorizontal +#define MocAllocateKWayPartitionMemory __MocAllocateKWayPartitionMemory +#define MocComputeKWayPartitionParams __MocComputeKWayPartitionParams +#define MocProjectKWayPartition __MocProjectKWayPartition +#define MocComputeKWayBalanceBoundary __MocComputeKWayBalanceBoundary + + +/* mmatch.c */ +#define MCMatch_RM __MCMatch_RM +#define MCMatch_HEM __MCMatch_HEM +#define MCMatch_SHEM __MCMatch_SHEM +#define MCMatch_SHEBM __MCMatch_SHEBM +#define MCMatch_SBHEM __MCMatch_SBHEM +#define BetterVBalance __BetterVBalance +#define AreAllVwgtsBelowFast __AreAllVwgtsBelowFast + + +/* mmd.c */ +#define genmmd __genmmd +#define mmdelm __mmdelm +#define mmdint __mmdint +#define mmdnum __mmdnum +#define mmdupd __mmdupd + + +/* mpmetis.c */ +#define MCMlevelRecursiveBisection __MCMlevelRecursiveBisection +#define MCHMlevelRecursiveBisection __MCHMlevelRecursiveBisection +#define MCMlevelEdgeBisection __MCMlevelEdgeBisection +#define MCHMlevelEdgeBisection __MCHMlevelEdgeBisection + + +/* mrefine.c */ +#define MocRefine2Way __MocRefine2Way +#define MocAllocate2WayPartitionMemory __MocAllocate2WayPartitionMemory +#define MocCompute2WayPartitionParams __MocCompute2WayPartitionParams +#define MocProject2WayPartition __MocProject2WayPartition + + +/* mrefine2.c */ +#define MocRefine2Way2 __MocRefine2Way2 + + +/* mutil.c */ +#define AreAllVwgtsBelow __AreAllVwgtsBelow +#define AreAnyVwgtsBelow __AreAnyVwgtsBelow +#define AreAllVwgtsAbove __AreAllVwgtsAbove +#define ComputeLoadImbalance __ComputeLoadImbalance +#define AreAllBelow __AreAllBelow + + +/* myqsort.c */ +#define iidxsort __iidxsort +#define iintsort __iintsort +#define ikeysort __ikeysort +#define ikeyvalsort __ikeyvalsort + + +/* ometis.c */ +#define MlevelNestedDissection __MlevelNestedDissection +#define MlevelNestedDissectionCC __MlevelNestedDissectionCC +#define MlevelNodeBisectionMultiple __MlevelNodeBisectionMultiple +#define MlevelNodeBisection __MlevelNodeBisection +#define SplitGraphOrder __SplitGraphOrder +#define MMDOrder __MMDOrder +#define SplitGraphOrderCC __SplitGraphOrderCC + + +/* parmetis.c */ +#define MlevelNestedDissectionP __MlevelNestedDissectionP + + +/* pmetis.c */ +#define MlevelRecursiveBisection __MlevelRecursiveBisection +#define MlevelEdgeBisection __MlevelEdgeBisection +#define SplitGraphPart __SplitGraphPart +#define SetUpSplitGraph __SetUpSplitGraph + + +/* pqueue.c */ +#define PQueueInit __PQueueInit +#define PQueueReset __PQueueReset +#define PQueueFree __PQueueFree +#define PQueueInsert __PQueueInsert +#define PQueueDelete __PQueueDelete +#define PQueueUpdate __PQueueUpdate +#define PQueueUpdateUp __PQueueUpdateUp +#define PQueueGetMax __PQueueGetMax +#define PQueueSeeMax __PQueueSeeMax +#define CheckHeap __CheckHeap + + +/* refine.c */ +#define Refine2Way __Refine2Way +#define Allocate2WayPartitionMemory __Allocate2WayPartitionMemory +#define Compute2WayPartitionParams __Compute2WayPartitionParams +#define Project2WayPartition __Project2WayPartition + + +/* separator.c */ +#define ConstructSeparator __ConstructSeparator +#define ConstructMinCoverSeparator0 __ConstructMinCoverSeparator0 +#define ConstructMinCoverSeparator __ConstructMinCoverSeparator + + +/* sfm.c */ +#define FM_2WayNodeRefine __FM_2WayNodeRefine +#define FM_2WayNodeRefineEqWgt __FM_2WayNodeRefineEqWgt +#define FM_2WayNodeRefine_OneSided __FM_2WayNodeRefine_OneSided +#define FM_2WayNodeBalance __FM_2WayNodeBalance +#define ComputeMaxNodeGain __ComputeMaxNodeGain + + +/* srefine.c */ +#define Refine2WayNode __Refine2WayNode +#define Allocate2WayNodePartitionMemory __Allocate2WayNodePartitionMemory +#define Compute2WayNodePartitionParams __Compute2WayNodePartitionParams +#define Project2WayNodePartition __Project2WayNodePartition + + +/* stat.c */ +#define ComputePartitionInfo __ComputePartitionInfo +#define ComputePartitionBalance __ComputePartitionBalance +#define ComputeElementBalance __ComputeElementBalance + + +/* subdomains.c */ +#define Random_KWayEdgeRefineMConn __Random_KWayEdgeRefineMConn +#define Greedy_KWayEdgeBalanceMConn __Greedy_KWayEdgeBalanceMConn +#define PrintSubDomainGraph __PrintSubDomainGraph +#define ComputeSubDomainGraph __ComputeSubDomainGraph +#define EliminateSubDomainEdges __EliminateSubDomainEdges +#define MoveGroupMConn __MoveGroupMConn +#define EliminateComponents __EliminateComponents +#define MoveGroup __MoveGroup + + +/* timing.c */ +#define InitTimers __InitTimers +#define PrintTimers __PrintTimers +#define seconds __seconds + + +/* util.c */ +#define errexit __errexit +#define GKfree __GKfree +#ifndef DMALLOC +#define imalloc __imalloc +#define idxmalloc __idxmalloc +#define fmalloc __fmalloc +#define ismalloc __ismalloc +#define idxsmalloc __idxsmalloc +#define GKmalloc __GKmalloc +#endif +#define iset __iset +#define idxset __idxset +#define sset __sset +#define iamax __iamax +#define idxamax __idxamax +#define idxamax_strd __idxamax_strd +#define samax __samax +#define samax2 __samax2 +#define idxamin __idxamin +#define samin __samin +#define idxsum __idxsum +#define idxsum_strd __idxsum_strd +#define idxadd __idxadd +#define charsum __charsum +#define isum __isum +#define ssum __ssum +#define ssum_strd __ssum_strd +#define sscale __sscale +#define snorm2 __snorm2 +#define sdot __sdot +#define saxpy __saxpy +#define RandomPermute __RandomPermute +#define ispow2 __ispow2 +#define InitRandom __InitRandom +#define ilog2 __ilog2 + + + + + diff --git a/thirdparty/linux/include/coin/ThirdParty/struct.h b/thirdparty/linux/include/coin/ThirdParty/struct.h new file mode 100644 index 0000000..63c7c65 --- /dev/null +++ b/thirdparty/linux/include/coin/ThirdParty/struct.h @@ -0,0 +1,251 @@ +/* + * Copyright 1997, Regents of the University of Minnesota + * + * struct.h + * + * This file contains data structures for ILU routines. + * + * Started 9/26/95 + * George + * + * $Id: struct.h,v 1.1 1998/11/27 17:59:31 karypis Exp $ + */ + +/* Undefine the following #define in order to use short int as the idxtype */ +#define IDXTYPE_INT + +/* Indexes are as long as integers for now */ +#ifdef IDXTYPE_INT +typedef int idxtype; +#else +typedef short idxtype; +#endif + +#define MAXIDX (1<<8*sizeof(idxtype)-2) + + +/************************************************************************* +* The following data structure stores key-value pair +**************************************************************************/ +struct KeyValueType { + idxtype key; + idxtype val; +}; + +typedef struct KeyValueType KeyValueType; + + +/************************************************************************* +* The following data structure will hold a node of a doubly-linked list. +**************************************************************************/ +struct ListNodeType { + int id; /* The id value of the node */ + struct ListNodeType *prev, *next; /* It's a doubly-linked list */ +}; + +typedef struct ListNodeType ListNodeType; + + + +/************************************************************************* +* The following data structure is used to store the buckets for the +* refinment algorithms +**************************************************************************/ +struct PQueueType { + int type; /* The type of the representation used */ + int nnodes; + int maxnodes; + int mustfree; + + /* Linear array version of the data structures */ + int pgainspan, ngainspan; /* plus and negative gain span */ + int maxgain; + ListNodeType *nodes; + ListNodeType **buckets; + + /* Heap version of the data structure */ + KeyValueType *heap; + idxtype *locator; +}; + +typedef struct PQueueType PQueueType; + + +/************************************************************************* +* The following data structure stores an edge +**************************************************************************/ +struct edegreedef { + idxtype pid; + idxtype ed; +}; +typedef struct edegreedef EDegreeType; + + +/************************************************************************* +* The following data structure stores an edge for vol +**************************************************************************/ +struct vedegreedef { + idxtype pid; + idxtype ed, ned; + idxtype gv; +}; +typedef struct vedegreedef VEDegreeType; + + +/************************************************************************* +* This data structure holds various working space data +**************************************************************************/ +struct workspacedef { + idxtype *core; /* Where pairs, indices, and degrees are coming from */ + int maxcore, ccore; + + EDegreeType *edegrees; + VEDegreeType *vedegrees; + int cdegree; + + idxtype *auxcore; /* This points to the memory of the edegrees */ + + idxtype *pmat; /* An array of k^2 used for eliminating domain + connectivity in k-way refinement */ +}; + +typedef struct workspacedef WorkSpaceType; + + +/************************************************************************* +* The following data structure holds information on degrees for k-way +* partition +**************************************************************************/ +struct rinfodef { + int id, ed; /* ID/ED of nodes */ + int ndegrees; /* The number of different ext-degrees */ + EDegreeType *edegrees; /* List of edges */ +}; + +typedef struct rinfodef RInfoType; + + +/************************************************************************* +* The following data structure holds information on degrees for k-way +* vol-based partition +**************************************************************************/ +struct vrinfodef { + int id, ed, nid; /* ID/ED of nodes */ + int gv; /* IV/EV of nodes */ + int ndegrees; /* The number of different ext-degrees */ + VEDegreeType *edegrees; /* List of edges */ +}; + +typedef struct vrinfodef VRInfoType; + + +/************************************************************************* +* The following data structure holds information on degrees for k-way +* partition +**************************************************************************/ +struct nrinfodef { + idxtype edegrees[2]; +}; + +typedef struct nrinfodef NRInfoType; + + +/************************************************************************* +* This data structure holds the input graph +**************************************************************************/ +struct graphdef { + idxtype *gdata, *rdata; /* Memory pools for graph and refinement data. + This is where memory is allocated and used + the rest of the fields in this structure */ + + int nvtxs, nedges; /* The # of vertices and edges in the graph */ + idxtype *xadj; /* Pointers to the locally stored vertices */ + idxtype *vwgt; /* Vertex weights */ + idxtype *vsize; /* Vertex sizes for min-volume formulation */ + idxtype *adjncy; /* Array that stores the adjacency lists of nvtxs */ + idxtype *adjwgt; /* Array that stores the weights of the adjacency lists */ + + idxtype *adjwgtsum; /* The sum of the adjacency weight of each vertex */ + + idxtype *label; + + idxtype *cmap; + + /* Partition parameters */ + int mincut, minvol; + idxtype *where, *pwgts; + int nbnd; + idxtype *bndptr, *bndind; + + /* Bisection refinement parameters */ + idxtype *id, *ed; + + /* K-way refinement parameters */ + RInfoType *rinfo; + + /* K-way volume refinement parameters */ + VRInfoType *vrinfo; + + /* Node refinement information */ + NRInfoType *nrinfo; + + + /* Additional info needed by the MOC routines */ + int ncon; /* The # of constrains */ + float *nvwgt; /* Normalized vertex weights */ + float *npwgts; /* The normalized partition weights */ + + struct graphdef *coarser, *finer; +}; + +typedef struct graphdef GraphType; + + + +/************************************************************************* +* The following data type implements a timer +**************************************************************************/ +typedef double timer; + + +/************************************************************************* +* The following structure stores information used by Metis +**************************************************************************/ +struct controldef { + int CoarsenTo; /* The # of vertices in the coarsest graph */ + int dbglvl; /* Controls the debuging output of the program */ + int CType; /* The type of coarsening */ + int IType; /* The type of initial partitioning */ + int RType; /* The type of refinement */ + int maxvwgt; /* The maximum allowed weight for a vertex */ + float nmaxvwgt; /* The maximum allowed weight for a vertex for each constrain */ + int optype; /* Type of operation */ + int pfactor; /* .1*prunning factor */ + int nseps; /* The number of separators to be found during multiple bisections */ + int oflags; + + WorkSpaceType wspace; /* Work Space Informations */ + + /* Various Timers */ + timer TotalTmr, InitPartTmr, MatchTmr, ContractTmr, CoarsenTmr, UncoarsenTmr, + SepTmr, RefTmr, ProjectTmr, SplitTmr, AuxTmr1, AuxTmr2, AuxTmr3, AuxTmr4, AuxTmr5, AuxTmr6; + +}; + +typedef struct controldef CtrlType; + + +/************************************************************************* +* The following data structure stores max-partition weight info for +* Vertical MOC k-way refinement +**************************************************************************/ +struct vpwgtdef { + float max[2][MAXNCON]; + int imax[2][MAXNCON]; +}; + +typedef struct vpwgtdef VPInfoType; + + + + |