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-2024 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
60extern "C" {
61#endif
62
63/** NLP row */
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 */
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__ */
common defines and data types used in all packages of SCIP
#define SCIP_Longint
Definition: def.h:157
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:172
SCIP_EXPR * expr
Definition: struct_nlp.h:81
int linvarssize
Definition: struct_nlp.h:75
SCIP_Longint validactivitybdsdomchg
Definition: struct_nlp.h:92
int nlpiindex
Definition: struct_nlp.h:94
SCIP_EXPRCURV curvature
Definition: struct_nlp.h:96
SCIP_Real minactivity
Definition: struct_nlp.h:90
char * name
Definition: struct_nlp.h:84
SCIP_Real lhs
Definition: struct_nlp.h:67
SCIP_Longint validactivitynlp
Definition: struct_nlp.h:87
double * lincoefs
Definition: struct_nlp.h:77
SCIP_Real activity
Definition: struct_nlp.h:86
SCIP_Real maxactivity
Definition: struct_nlp.h:91
SCIP_Real pseudoactivity
Definition: struct_nlp.h:88
SCIP_Real dualsol
Definition: struct_nlp.h:95
SCIP_Real rhs
Definition: struct_nlp.h:68
SCIP_Real constant
Definition: struct_nlp.h:71
SCIP_VAR ** linvars
Definition: struct_nlp.h:76
int nlinvars
Definition: struct_nlp.h:74
SCIP_Longint validpsactivitydomchg
Definition: struct_nlp.h:89
int nlpindex
Definition: struct_nlp.h:93
SCIP_Bool linvarssorted
Definition: struct_nlp.h:78
SCIP_Real primalsolobjval
Definition: struct_nlp.h:146
int sizevars_solver
Definition: struct_nlp.h:120
SCIP_NLROW * divingobj
Definition: struct_nlp.h:139
SCIP_Bool objflushed
Definition: struct_nlp.h:138
SCIP_Longint validfracvars
Definition: struct_nlp.h:163
int sizenlrows_solver
Definition: struct_nlp.h:134
SCIP_VAR ** fracvars
Definition: struct_nlp.h:157
SCIP_Bool haveinitguess
Definition: struct_nlp.h:142
int sizevars
Definition: struct_nlp.h:115
int nnlrowconvexineq
Definition: struct_nlp.h:129
SCIP_EVENTHDLR * eventhdlr
Definition: struct_nlp.h:153
int * nlrowmap_nlpi2nlp
Definition: struct_nlp.h:135
int nnlrows
Definition: struct_nlp.h:125
int nnlrowlinear
Definition: struct_nlp.h:128
int fracvarssize
Definition: struct_nlp.h:162
char * name
Definition: struct_nlp.h:166
int nunflushednlrowdel
Definition: struct_nlp.h:110
int nunflushednlrowadd
Definition: struct_nlp.h:109
int npriofracvars
Definition: struct_nlp.h:161
int sizenlrows
Definition: struct_nlp.h:126
int globalfilterpos
Definition: struct_nlp.h:154
SCIP_NLPSOLSTAT solstat
Definition: struct_nlp.h:147
SCIP_Real * fracvarsfrac
Definition: struct_nlp.h:159
int nvars_solver
Definition: struct_nlp.h:119
SCIP_HASHMAP * varhash
Definition: struct_nlp.h:117
SCIP_NLPI * solver
Definition: struct_nlp.h:103
int nunflushedvaradd
Definition: struct_nlp.h:107
int nnlrows_solver
Definition: struct_nlp.h:133
SCIP_NLPTERMSTAT termstat
Definition: struct_nlp.h:148
SCIP_NLROW ** nlrows
Definition: struct_nlp.h:127
int nnlrownonconvexineq
Definition: struct_nlp.h:130
SCIP_VAR ** vars
Definition: struct_nlp.h:116
int * varmap_nlp2nlpi
Definition: struct_nlp.h:121
int nvars
Definition: struct_nlp.h:114
int nnlrownonlineareq
Definition: struct_nlp.h:131
SCIP_NLPIPROBLEM * problem
Definition: struct_nlp.h:104
SCIP_Real * varubdualvals
Definition: struct_nlp.h:150
int nfracvars
Definition: struct_nlp.h:160
SCIP_Bool indiving
Definition: struct_nlp.h:111
int * varmap_nlpi2nlp
Definition: struct_nlp.h:122
SCIP_Real * varlbdualvals
Definition: struct_nlp.h:149
int nunflushedvardel
Definition: struct_nlp.h:108
SCIP_Real * initialguess
Definition: struct_nlp.h:143
SCIP_Real * fracvarssol
Definition: struct_nlp.h:158
type definitions for managing events
type and macro definitions related to algebraic expressions
SCIP_EXPRCURV
Definition: type_expr.h:61
type definitions for miscellaneous datastructures
type definitions for NLP management
type definitions for NLP solver interfaces
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
Definition: type_nlpi.h:168
enum SCIP_NlpTermStat SCIP_NLPTERMSTAT
Definition: type_nlpi.h:194
type definitions for problem variables