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