Scippy

SCIP

Solving Constraint Integer Programs

pub_sol.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-2020 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 pub_sol.h
17  * @ingroup PUBLICCOREAPI
18  * @brief public methods for primal CIP solutions
19  * @author Tobias Achterberg
20  * @author Timo Berthold
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef __SCIP_PUB_SOL_H__
26 #define __SCIP_PUB_SOL_H__
27 
28 
29 #include "scip/def.h"
30 #include "scip/type_sol.h"
31 #include "scip/type_heur.h"
32 #include "scip/type_relax.h"
33 
34 #ifdef NDEBUG
35 #include "scip/struct_sol.h"
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /**@addtogroup PublicSolutionMethods
43  *
44  * @{
45  */
46 
47 
48 /** gets origin of solution */
51  SCIP_SOL* sol /**< primal CIP solution */
52  );
53 
54 /** returns whether the given solution is defined on original variables */
57  SCIP_SOL* sol /**< primal CIP solution */
58  );
59 
60 /** returns whether the given solution is partial */
63  SCIP_SOL* sol /**< primal CIP solution */
64  );
65 
66 /** gets objective value of primal CIP solution which lives in the original problem space */
69  SCIP_SOL* sol /**< primal CIP solution */
70  );
71 
72 /** gets clock time, when this solution was found */
75  SCIP_SOL* sol /**< primal CIP solution */
76  );
77 
78 /** gets branch and bound run number, where this solution was found */
81  SCIP_SOL* sol /**< primal CIP solution */
82  );
83 
84 /** gets node number of the specific branch and bound run, where this solution was found */
87  SCIP_SOL* sol /**< primal CIP solution */
88  );
89 
90 /** gets node's depth, where this solution was found */
92 int SCIPsolGetDepth(
93  SCIP_SOL* sol /**< primal CIP solution */
94  );
95 
96 /** gets information if solution was found by the LP, a primal heuristic, or a custom relaxator */
99  SCIP_SOL* sol /**< primal CIP solution */
100  );
101 
102 /** gets heuristic that found this solution, or NULL if solution has type different than SCIP_SOLTYPE_HEUR */
105  SCIP_SOL* sol /**< primal CIP solution */
106  );
107 
108 /** gets relaxation handler that found this solution, or NULL if solution has different type than SCIP_SOLTYPE_RELAX */
111  SCIP_SOL* sol /**< primal CIP solution */
112  );
113 
114 /** informs the solution that it now belongs to the given primal heuristic. For convenience and backwards compatibility,
115  * the method accepts NULL as input for \p heur, in which case the solution type is set to SCIP_SOLTYPE_LPRELAX.
116  *
117  * @note Relaxation handlers should use SCIPsolSetRelax() instead.
118  */
120 void SCIPsolSetHeur(
121  SCIP_SOL* sol, /**< primal CIP solution */
122  SCIP_HEUR* heur /**< primal heuristic that found the solution, or NULL for LP solutions */
123  );
124 
125 /** informs the solution that it now belongs to the given relaxation handler */
127 void SCIPsolSetRelax(
128  SCIP_SOL* sol, /**< primal CIP solution */
129  SCIP_RELAX* relax /**< relaxator that found the solution */
130  );
131 
132 /** informs the solution that it is an LP relaxation solution */
135  SCIP_SOL* sol /**< primal CIP solution */
136  );
137 
138 /** informs the solution that it is a solution found during strong branching */
141  SCIP_SOL* sol /**< primal CIP solution */
142  );
143 
144 /** informs the solution that it originates from a pseudo solution */
146 void SCIPsolSetPseudo(
147  SCIP_SOL* sol /**< primal CIP solution */
148  );
149 
150 /** returns unique index of given solution */
152 int SCIPsolGetIndex(
153  SCIP_SOL* sol /**< primal CIP solution */
154  );
155 
156 /** get maximum absolute bound violation of solution */
159  SCIP_SOL* sol /**< primal CIP solution */
160  );
161 
162 /** get maximum relative bound violation of solution */
165  SCIP_SOL* sol /**< primal CIP solution */
166  );
167 
168 /** get maximum absolute integrality violation of solution */
171  SCIP_SOL* sol /**< primal CIP solution */
172  );
173 
174 /** get maximum absolute LP row violation of solution */
177  SCIP_SOL* sol /**< primal CIP solution */
178  );
179 
180 /** get maximum relative LP row violation of solution */
183  SCIP_SOL* sol /**< primal CIP solution */
184  );
185 
186 /** get maximum absolute constraint violation of solution */
189  SCIP_SOL* sol /**< primal CIP solution */
190  );
191 
192 /** get maximum relative constraint violation of solution */
195  SCIP_SOL* sol /**< primal CIP solution */
196  );
197 
198 #ifdef NDEBUG
199 
200 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
201  * speed up the algorithms.
202  */
203 
204 #define SCIPsolGetOrigin(sol) ((sol)->solorigin)
205 #define SCIPsolIsOriginal(sol) ((sol)->solorigin == SCIP_SOLORIGIN_ORIGINAL || (sol)->solorigin == SCIP_SOLORIGIN_PARTIAL)
206 #define SCIPsolGetOrigObj(sol) (sol)->obj
207 #define SCIPsolGetTime(sol) (sol)->time
208 #define SCIPsolGetNodenum(sol) (sol)->nodenum
209 #define SCIPsolGetRunnum(sol) (sol)->runnum
210 #define SCIPsolGetDepth(sol) (sol)->depth
211 #define SCIPsolGetHeur(sol) ((sol)->type == SCIP_SOLTYPE_HEUR ? (sol)->creator.heur : NULL)
212 #define SCIPsolGetRelax(sol) ((sol)->type == SCIP_SOLTYPE_RELAX ? (sol)->creator.relax : NULL)
213 #define SCIPsolGetIndex(sol) (sol)->index
214 #define SCIPsolGetType(sol) (sol)->type
215 #define SCIPsolSetLPRelaxation(sol) ((sol)->type = SCIP_SOLTYPE_LPRELAX)
216 #define SCIPsolSetStrongbranching(sol) ((sol)->type = SCIP_SOLTYPE_STRONGBRANCH)
217 #define SCIPsolSetPseudo(sol) ((sol)->type = SCIP_SOLTYPE_PSEUDO)
218 #endif
219 
220 /** @} */
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif
SCIP_EXPORT void SCIPsolSetPseudo(SCIP_SOL *sol)
Definition: sol.c:2719
SCIP_EXPORT SCIP_Real SCIPsolGetAbsLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2443
SCIP_EXPORT SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2521
#define SCIP_EXPORT
Definition: def.h:100
SCIP_EXPORT SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2604
SCIP_EXPORT SCIP_Real SCIPsolGetRelBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2423
SCIP_EXPORT SCIP_Real SCIPsolGetRelLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2453
SCIP_EXPORT SCIP_Real SCIPsolGetAbsConsViolation(SCIP_SOL *sol)
Definition: sol.c:2463
SCIP_EXPORT void SCIPsolSetLPRelaxation(SCIP_SOL *sol)
Definition: sol.c:2699
SCIP_EXPORT SCIP_Real SCIPsolGetAbsIntegralityViolation(SCIP_SOL *sol)
Definition: sol.c:2433
SCIP_EXPORT int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2574
SCIP_EXPORT void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2649
SCIP_EXPORT SCIP_RELAX * SCIPsolGetRelax(SCIP_SOL *sol)
Definition: sol.c:2676
type definitions for primal heuristics
SCIP_EXPORT SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2511
SCIP_EXPORT int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2594
SCIP_EXPORT SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
Definition: sol.c:2666
type definitions for relaxators
datastructures for storing primal CIP solutions
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT void SCIPsolSetStrongbranching(SCIP_SOL *sol)
Definition: sol.c:2709
SCIP_EXPORT int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2635
SCIP_EXPORT SCIP_Real SCIPsolGetAbsBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2413
SCIP_EXPORT SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2531
type definitions for storing primal CIP solutions
SCIP_EXPORT SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2541
SCIP_EXPORT SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2564
SCIP_EXPORT SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2584
#define SCIP_Real
Definition: def.h:163
SCIP_EXPORT void SCIPsolSetRelax(SCIP_SOL *sol, SCIP_RELAX *relax)
Definition: sol.c:2686
enum SCIP_SolType SCIP_SOLTYPE
Definition: type_sol.h:62
enum SCIP_SolOrigin SCIP_SOLORIGIN
Definition: type_sol.h:46
#define SCIP_Longint
Definition: def.h:148
SCIP_EXPORT SCIP_Real SCIPsolGetRelConsViolation(SCIP_SOL *sol)
Definition: sol.c:2473
common defines and data types used in all packages of SCIP