Scippy

SCIP

Solving Constraint Integer Programs

struct_nlp.h
Go to the documentation of this file.
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  /* nonlinear rows in NLPI problem */
129  int nnlrows_solver; /**< number of nonlinear rows in solver */
130  int sizenlrows_solver; /**< allocated space for nonlinear rows in solver */
131  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 */
132 
133  /* objective function */
134  SCIP_Bool objflushed; /**< is the objective in the NLPI up to date? */
135  SCIP_NLROW* divingobj; /**< objective function during diving */
136 
137  /* initial guess */
138  SCIP_Bool haveinitguess; /**< is an initial guess available? */
139  SCIP_Real* initialguess; /**< initial guess of primal values to use in next NLP solve, if available */
140 
141  /* solution of NLP */
142  SCIP_Real primalsolobjval; /**< objective function value of primal solution */
143  SCIP_NLPSOLSTAT solstat; /**< status of NLP solution (feasible, optimal, unknown...) */
144  SCIP_NLPTERMSTAT termstat; /**< termination status of NLP (normal, some limit reached, ...) */
145  SCIP_Real* varlbdualvals; /**< dual values associated with variable lower bounds */
146  SCIP_Real* varubdualvals; /**< dual values associated with variable upper bounds */
147 
148  /* event handling */
149  SCIP_EVENTHDLR* eventhdlr; /**< event handler for bound change events */
150  int globalfilterpos; /**< position of event handler in event handler filter */
151 
152  /* fractional variables in last NLP solution */
153  SCIP_VAR** fracvars; /**< fractional variables */
154  SCIP_Real* fracvarssol; /**< values of the fractional variables */
155  SCIP_Real* fracvarsfrac; /**< fractionality of the fractional variables */
156  int nfracvars; /**< number of fractional variables */
157  int npriofracvars; /**< number of fractional variables with highest branching priority */
158  int fracvarssize; /**< size of fracvars arrays */
159  SCIP_Longint validfracvars; /**< the NLP solve for which the fractional variables are valid, or -1 if never setup */
160 
161  /* miscellaneous */
162  char* name; /**< problem name */
163 };
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* __SCIP_STRUCT_NLP_H__ */
int nfracvars
Definition: struct_nlp.h:156
SCIP_Real * fracvarssol
Definition: struct_nlp.h:154
SCIP_Longint validpsactivitydomchg
Definition: struct_nlp.h:89
int * varmap_nlpi2nlp
Definition: struct_nlp.h:122
enum SCIP_NlpTermStat SCIP_NLPTERMSTAT
Definition: type_nlpi.h:194
type definitions for miscellaneous datastructures
int linvarssize
Definition: struct_nlp.h:75
type definitions for NLP management
SCIP_NLROW * divingobj
Definition: struct_nlp.h:135
SCIP_VAR ** linvars
Definition: struct_nlp.h:76
SCIP_VAR ** fracvars
Definition: struct_nlp.h:153
int nnlrows
Definition: struct_nlp.h:125
SCIP_NLPSOLSTAT solstat
Definition: struct_nlp.h:143
SCIP_Real * initialguess
Definition: struct_nlp.h:139
SCIP_NLPIPROBLEM * problem
Definition: struct_nlp.h:104
SCIP_Real pseudoactivity
Definition: struct_nlp.h:88
int nvars_solver
Definition: struct_nlp.h:119
int nnlrows_solver
Definition: struct_nlp.h:129
SCIP_Real dualsol
Definition: struct_nlp.h:95
int nunflushedvaradd
Definition: struct_nlp.h:107
SCIP_NLPI * solver
Definition: struct_nlp.h:103
char * name
Definition: struct_nlp.h:84
SCIP_Real minactivity
Definition: struct_nlp.h:90
int fracvarssize
Definition: struct_nlp.h:158
SCIP_Longint validfracvars
Definition: struct_nlp.h:159
int sizenlrows
Definition: struct_nlp.h:126
SCIP_Longint validactivitybdsdomchg
Definition: struct_nlp.h:92
SCIP_Real * varubdualvals
Definition: struct_nlp.h:146
SCIP_Real rhs
Definition: struct_nlp.h:68
SCIP_Real lhs
Definition: struct_nlp.h:67
SCIP_Bool objflushed
Definition: struct_nlp.h:134
SCIP_Real maxactivity
Definition: struct_nlp.h:91
SCIP_Real * fracvarsfrac
Definition: struct_nlp.h:155
SCIP_HASHMAP * varhash
Definition: struct_nlp.h:117
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
Definition: type_nlpi.h:168
int nlpiindex
Definition: struct_nlp.h:94
SCIP_EVENTHDLR * eventhdlr
Definition: struct_nlp.h:149
SCIP_Real * varlbdualvals
Definition: struct_nlp.h:145
SCIP_EXPRCURV curvature
Definition: struct_nlp.h:96
SCIP_EXPR * expr
Definition: struct_nlp.h:81
SCIP_VAR ** vars
Definition: struct_nlp.h:116
type definitions for problem variables
SCIP_NLPTERMSTAT termstat
Definition: struct_nlp.h:144
type definitions for managing events
#define SCIP_Bool
Definition: def.h:93
SCIP_EXPRCURV
Definition: type_expr.h:57
char * name
Definition: struct_nlp.h:162
int globalfilterpos
Definition: struct_nlp.h:150
SCIP_NLROW ** nlrows
Definition: struct_nlp.h:127
SCIP_Bool haveinitguess
Definition: struct_nlp.h:138
int nunflushedvardel
Definition: struct_nlp.h:108
int nunflushednlrowadd
Definition: struct_nlp.h:109
int nvars
Definition: struct_nlp.h:114
int sizevars
Definition: struct_nlp.h:115
SCIP_Bool indiving
Definition: struct_nlp.h:111
int * varmap_nlp2nlpi
Definition: struct_nlp.h:121
type and macro definitions related to algebraic expressions
#define SCIP_Real
Definition: def.h:186
int nunflushednlrowdel
Definition: struct_nlp.h:110
SCIP_Real activity
Definition: struct_nlp.h:86
#define SCIP_Longint
Definition: def.h:171
int nlinvars
Definition: struct_nlp.h:74
int sizevars_solver
Definition: struct_nlp.h:120
int nlpindex
Definition: struct_nlp.h:93
common defines and data types used in all packages of SCIP
int * nlrowmap_nlpi2nlp
Definition: struct_nlp.h:131
SCIP_Real constant
Definition: struct_nlp.h:71
SCIP_Real primalsolobjval
Definition: struct_nlp.h:142
double * lincoefs
Definition: struct_nlp.h:77
SCIP_Bool linvarssorted
Definition: struct_nlp.h:78
int npriofracvars
Definition: struct_nlp.h:157
SCIP_Longint validactivitynlp
Definition: struct_nlp.h:87
int sizenlrows_solver
Definition: struct_nlp.h:130
type definitions for NLP solver interfaces