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-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 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 */
49 SCIP_EXPORT
51  SCIP_SOL* sol /**< primal CIP solution */
52  );
53 
54 /** returns whether the given solution is defined on original variables */
55 SCIP_EXPORT
57  SCIP_SOL* sol /**< primal CIP solution */
58  );
59 
60 /** returns whether the given solution is partial */
61 SCIP_EXPORT
63  SCIP_SOL* sol /**< primal CIP solution */
64  );
65 
66 /** gets objective value of primal CIP solution which lives in the original problem space */
67 SCIP_EXPORT
69  SCIP_SOL* sol /**< primal CIP solution */
70  );
71 
72 /** gets clock time, when this solution was found */
73 SCIP_EXPORT
75  SCIP_SOL* sol /**< primal CIP solution */
76  );
77 
78 /** gets branch and bound run number, where this solution was found */
79 SCIP_EXPORT
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 */
85 SCIP_EXPORT
87  SCIP_SOL* sol /**< primal CIP solution */
88  );
89 
90 /** gets node's depth, where this solution was found */
91 SCIP_EXPORT
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 */
97 SCIP_EXPORT
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 */
103 SCIP_EXPORT
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 */
109 SCIP_EXPORT
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  */
119 SCIP_EXPORT
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 */
126 SCIP_EXPORT
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 */
133 SCIP_EXPORT
135  SCIP_SOL* sol /**< primal CIP solution */
136  );
137 
138 /** informs the solution that it is a solution found during strong branching */
139 SCIP_EXPORT
141  SCIP_SOL* sol /**< primal CIP solution */
142  );
143 
144 /** informs the solution that it originates from a pseudo solution */
145 SCIP_EXPORT
146 void SCIPsolSetPseudo(
147  SCIP_SOL* sol /**< primal CIP solution */
148  );
149 
150 /** returns unique index of given solution */
151 SCIP_EXPORT
152 int SCIPsolGetIndex(
153  SCIP_SOL* sol /**< primal CIP solution */
154  );
155 
156 /** get maximum absolute bound violation of solution */
157 SCIP_EXPORT
159  SCIP_SOL* sol /**< primal CIP solution */
160  );
161 
162 /** get maximum relative bound violation of solution */
163 SCIP_EXPORT
165  SCIP_SOL* sol /**< primal CIP solution */
166  );
167 
168 /** get maximum absolute integrality violation of solution */
169 SCIP_EXPORT
171  SCIP_SOL* sol /**< primal CIP solution */
172  );
173 
174 /** get maximum absolute LP row violation of solution */
175 SCIP_EXPORT
177  SCIP_SOL* sol /**< primal CIP solution */
178  );
179 
180 /** get maximum relative LP row violation of solution */
181 SCIP_EXPORT
183  SCIP_SOL* sol /**< primal CIP solution */
184  );
185 
186 /** get maximum absolute constraint violation of solution */
187 SCIP_EXPORT
189  SCIP_SOL* sol /**< primal CIP solution */
190  );
191 
192 /** get maximum relative constraint violation of solution */
193 SCIP_EXPORT
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_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2521
void SCIPsolSetLPRelaxation(SCIP_SOL *sol)
Definition: sol.c:2699
SCIP_Real SCIPsolGetRelBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2423
void SCIPsolSetRelax(SCIP_SOL *sol, SCIP_RELAX *relax)
Definition: sol.c:2686
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2564
SCIP_Real SCIPsolGetAbsConsViolation(SCIP_SOL *sol)
Definition: sol.c:2463
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2541
SCIP_Real SCIPsolGetRelConsViolation(SCIP_SOL *sol)
Definition: sol.c:2473
SCIP_Real SCIPsolGetAbsIntegralityViolation(SCIP_SOL *sol)
Definition: sol.c:2433
type definitions for primal heuristics
SCIP_RELAX * SCIPsolGetRelax(SCIP_SOL *sol)
Definition: sol.c:2676
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2604
void SCIPsolSetPseudo(SCIP_SOL *sol)
Definition: sol.c:2719
type definitions for relaxators
datastructures for storing primal CIP solutions
SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
Definition: sol.c:2666
#define SCIP_Bool
Definition: def.h:84
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2584
SCIP_Real SCIPsolGetAbsBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2413
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2649
type definitions for storing primal CIP solutions
SCIP_Real SCIPsolGetRelLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2453
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2511
#define SCIP_Real
Definition: def.h:177
enum SCIP_SolType SCIP_SOLTYPE
Definition: type_sol.h:62
enum SCIP_SolOrigin SCIP_SOLORIGIN
Definition: type_sol.h:46
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2594
#define SCIP_Longint
Definition: def.h:162
void SCIPsolSetStrongbranching(SCIP_SOL *sol)
Definition: sol.c:2709
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2531
common defines and data types used in all packages of SCIP
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2574
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2635
SCIP_Real SCIPsolGetAbsLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2443