1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ 7 /* */ 8 /* Licensed under the Apache License, Version 2.0 (the "License"); */ 9 /* you may not use this file except in compliance with the License. */ 10 /* You may obtain a copy of the License at */ 11 /* */ 12 /* http://www.apache.org/licenses/LICENSE-2.0 */ 13 /* */ 14 /* Unless required by applicable law or agreed to in writing, software */ 15 /* distributed under the License is distributed on an "AS IS" BASIS, */ 16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 17 /* See the License for the specific language governing permissions and */ 18 /* limitations under the License. */ 19 /* */ 20 /* You should have received a copy of the Apache-2.0 license */ 21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ 22 /* */ 23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 24 25 /**@file struct_nlp.h 26 * @ingroup INTERNALAPI 27 * @brief datastructures for NLP management 28 * @author Thorsten Gellermann 29 * @author Stefan Vigerske 30 * 31 * In SCIP, the NLP relaxation is defined as follows: 32 * <pre> 33 * min const + obj * x 34 * lhs <= const + A * x + f(x) <= rhs 35 * lb <= x <= ub 36 * </pre> 37 * 38 * The main datastructures for storing an NLP are the nonlinear rows. 39 * A nonlinear row can live on its own (if it was created by a separator), 40 * or as relaxation of a constraint. Thus, it has a nuses-counter and is 41 * deleted if not used any more. 42 * In difference to columns of an LP, nonlinear rows are defined 43 * with respect SCIP variables. 44 */ 45 46 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 47 48 #ifndef __SCIP_STRUCT_NLP_H__ 49 #define __SCIP_STRUCT_NLP_H__ 50 51 #include "scip/def.h" 52 #include "scip/type_nlp.h" 53 #include "scip/type_var.h" 54 #include "scip/type_misc.h" 55 #include "scip/type_event.h" 56 #include "scip/type_nlpi.h" 57 #include "scip/type_expr.h" 58 59 #ifdef __cplusplus 60 extern "C" { 61 #endif 62 63 /** NLP row */ 64 struct SCIP_NlRow 65 { 66 /* sides */ 67 SCIP_Real lhs; /**< left hand side */ 68 SCIP_Real rhs; /**< right hand side */ 69 70 /* constant part */ 71 SCIP_Real constant; /**< constant value */ 72 73 /* linear part */ 74 int nlinvars; /**< number of linear variables */ 75 int linvarssize; /**< size of arrays storing linear part of row */ 76 SCIP_VAR** linvars; /**< linear variables */ 77 double* lincoefs; /**< coefficients of linear variables */ 78 SCIP_Bool linvarssorted; /**< are the linear coefficients sorted (by variable indices?) */ 79 80 /* nonlinear part */ 81 SCIP_EXPR* expr; /**< expression representing nonlinear part */ 82 83 /* miscellaneous */ 84 char* name; /**< name */ 85 int nuses; /**< number of times, this row is referenced */ 86 SCIP_Real activity; /**< row activity value in NLP, or SCIP_INVALID if not yet calculated */ 87 SCIP_Longint validactivitynlp; /**< NLP number for which activity value is valid */ 88 SCIP_Real pseudoactivity; /**< row activity value in pseudo solution, or SCIP_INVALID if not yet calculated */ 89 SCIP_Longint validpsactivitydomchg; /**< domain change number for which pseudo activity value is valid */ 90 SCIP_Real minactivity; /**< minimal activity value w.r.t. the variables' bounds, or SCIP_INVALID */ 91 SCIP_Real maxactivity; /**< maximal activity value w.r.t. the variables' bounds, or SCIP_INVALID */ 92 SCIP_Longint validactivitybdsdomchg; /**< domain change number for which activity bound values are valid */ 93 int nlpindex; /**< index of this row in NLP, or -1 if not added */ 94 int nlpiindex; /**< index of this row in NLPI problem, or -1 if not in there */ 95 SCIP_Real dualsol; /**< dual value associated with row in last NLP solve */ 96 SCIP_EXPRCURV curvature; /**< curvature of the nonlinear row */ 97 }; 98 99 /** current NLP data */ 100 struct SCIP_Nlp 101 { 102 /* NLP solver */ 103 SCIP_NLPI* solver; /**< interface to NLP solver, or NULL if no NLP solvers are available */ 104 SCIP_NLPIPROBLEM* problem; /**< problem in NLP solver */ 105 106 /* status */ 107 int nunflushedvaradd; /**< number of variable additions not flushed to NLPI problem yet */ 108 int nunflushedvardel; /**< number of variable deletions not flushed to NLPI problem yet */ 109 int nunflushednlrowadd; /**< number of nonlinear row additions not flushed to NLPI problem yet */ 110 int nunflushednlrowdel; /**< number of nonlinear row deletions not flushed to NLPI problem yet */ 111 SCIP_Bool indiving; /**< are we currently in diving mode? */ 112 113 /* variables in problem */ 114 int nvars; /**< number of variables */ 115 int sizevars; /**< allocated space for variables */ 116 SCIP_VAR** vars; /**< variables */ 117 SCIP_HASHMAP* varhash; /**< variable hash: map SCIP_VAR* to index of variable in NLP */ 118 /* variables in NLPI problem */ 119 int nvars_solver; /**< number of variables in NLPI problem */ 120 int sizevars_solver; /**< allocated space for variables in NLPI problem */ 121 int* varmap_nlp2nlpi; /**< index of variables in NLPI problem, or -1 if variable has not been added to NLPI problem yet */ 122 int* varmap_nlpi2nlp; /**< index of a NLPI problem variable in NLP (`varmap_nlp2nlpi[varmap_nlpi2nlp[i]] == i` for `i = 0..nvars_solver-1`), or -1 if variable has been deleted from NLP */ 123 124 /* nonlinear rows in problem */ 125 int nnlrows; /**< number of nonlinear rows */ 126 int sizenlrows; /**< allocated space for nonlinear rows */ 127 SCIP_NLROW** nlrows; /**< nonlinear rows */ 128 int nnlrowlinear; /**< number of linear rows in NLP */ 129 int nnlrowconvexineq; /**< number of convex one-sided inequalities in NLP */ 130 int nnlrownonconvexineq;/**< number of nonconvex one-sided inequalities in NLP */ 131 int nnlrownonlineareq; /**< number of nonlinear equalities and two-sided inequalities in NLP */ 132 /* nonlinear rows in NLPI problem */ 133 int nnlrows_solver; /**< number of nonlinear rows in solver */ 134 int sizenlrows_solver; /**< allocated space for nonlinear rows in solver */ 135 int* nlrowmap_nlpi2nlp; /**< index of a NLPI row in NLP (`nlrows[nlrowmap_nlpi2nlp[i]]->nlpiidx == i` for `i = 0..nnlrows_solver-1`), or -1 if row has been deleted from NLP */ 136 137 /* objective function */ 138 SCIP_Bool objflushed; /**< is the objective in the NLPI up to date? */ 139 SCIP_NLROW* divingobj; /**< objective function during diving */ 140 141 /* initial guess */ 142 SCIP_Bool haveinitguess; /**< is an initial guess available? */ 143 SCIP_Real* initialguess; /**< initial guess of primal values to use in next NLP solve, if available */ 144 145 /* solution of NLP */ 146 SCIP_Real primalsolobjval; /**< objective function value of primal solution */ 147 SCIP_NLPSOLSTAT solstat; /**< status of NLP solution (feasible, optimal, unknown...) */ 148 SCIP_NLPTERMSTAT termstat; /**< termination status of NLP (normal, some limit reached, ...) */ 149 SCIP_Real* varlbdualvals; /**< dual values associated with variable lower bounds */ 150 SCIP_Real* varubdualvals; /**< dual values associated with variable upper bounds */ 151 152 /* event handling */ 153 SCIP_EVENTHDLR* eventhdlr; /**< event handler for bound change events */ 154 int globalfilterpos; /**< position of event handler in event handler filter */ 155 156 /* fractional variables in last NLP solution */ 157 SCIP_VAR** fracvars; /**< fractional variables */ 158 SCIP_Real* fracvarssol; /**< values of the fractional variables */ 159 SCIP_Real* fracvarsfrac; /**< fractionality of the fractional variables */ 160 int nfracvars; /**< number of fractional variables */ 161 int npriofracvars; /**< number of fractional variables with highest branching priority */ 162 int fracvarssize; /**< size of fracvars arrays */ 163 SCIP_Longint validfracvars; /**< the NLP solve for which the fractional variables are valid, or -1 if never setup */ 164 165 /* miscellaneous */ 166 char* name; /**< problem name */ 167 }; 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* __SCIP_STRUCT_NLP_H__ */ 174