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 2002-2022 Zuse Institute Berlin */
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 pub_sol.h
26  * @ingroup PUBLICCOREAPI
27  * @brief public methods for primal CIP solutions
28  * @author Tobias Achterberg
29  * @author Timo Berthold
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #ifndef __SCIP_PUB_SOL_H__
35 #define __SCIP_PUB_SOL_H__
36 
37 
38 #include "scip/def.h"
39 #include "scip/type_sol.h"
40 #include "scip/type_heur.h"
41 #include "scip/type_relax.h"
42 
43 #ifdef NDEBUG
44 #include "scip/struct_sol.h"
45 #endif
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /**@addtogroup PublicSolutionMethods
52  *
53  * @{
54  */
55 
56 
57 /** gets origin of solution */
58 SCIP_EXPORT
60  SCIP_SOL* sol /**< primal CIP solution */
61  );
62 
63 /** returns whether the given solution is defined on original variables */
64 SCIP_EXPORT
66  SCIP_SOL* sol /**< primal CIP solution */
67  );
68 
69 /** returns whether the given solution is partial */
70 SCIP_EXPORT
72  SCIP_SOL* sol /**< primal CIP solution */
73  );
74 
75 /** gets objective value of primal CIP solution which lives in the original problem space */
76 SCIP_EXPORT
78  SCIP_SOL* sol /**< primal CIP solution */
79  );
80 
81 /** gets clock time, when this solution was found */
82 SCIP_EXPORT
84  SCIP_SOL* sol /**< primal CIP solution */
85  );
86 
87 /** gets branch and bound run number, where this solution was found */
88 SCIP_EXPORT
90  SCIP_SOL* sol /**< primal CIP solution */
91  );
92 
93 /** gets node number of the specific branch and bound run, where this solution was found */
94 SCIP_EXPORT
96  SCIP_SOL* sol /**< primal CIP solution */
97  );
98 
99 /** gets node's depth, where this solution was found */
100 SCIP_EXPORT
101 int SCIPsolGetDepth(
102  SCIP_SOL* sol /**< primal CIP solution */
103  );
104 
105 /** gets information if solution was found by the LP, a primal heuristic, or a custom relaxator */
106 SCIP_EXPORT
108  SCIP_SOL* sol /**< primal CIP solution */
109  );
110 
111 /** gets heuristic that found this solution, or NULL if solution has type different than SCIP_SOLTYPE_HEUR */
112 SCIP_EXPORT
114  SCIP_SOL* sol /**< primal CIP solution */
115  );
116 
117 /** gets relaxation handler that found this solution, or NULL if solution has different type than SCIP_SOLTYPE_RELAX */
118 SCIP_EXPORT
120  SCIP_SOL* sol /**< primal CIP solution */
121  );
122 
123 /** informs the solution that it now belongs to the given primal heuristic. For convenience and backwards compatibility,
124  * the method accepts NULL as input for \p heur, in which case the solution type is set to SCIP_SOLTYPE_LPRELAX.
125  *
126  * @note Relaxation handlers should use SCIPsolSetRelax() instead.
127  */
128 SCIP_EXPORT
129 void SCIPsolSetHeur(
130  SCIP_SOL* sol, /**< primal CIP solution */
131  SCIP_HEUR* heur /**< primal heuristic that found the solution, or NULL for LP solutions */
132  );
133 
134 /** informs the solution that it now belongs to the given relaxation handler */
135 SCIP_EXPORT
136 void SCIPsolSetRelax(
137  SCIP_SOL* sol, /**< primal CIP solution */
138  SCIP_RELAX* relax /**< relaxator that found the solution */
139  );
140 
141 /** informs the solution that it is an LP relaxation solution */
142 SCIP_EXPORT
144  SCIP_SOL* sol /**< primal CIP solution */
145  );
146 
147 /** informs the solution that it is a solution found during strong branching */
148 SCIP_EXPORT
150  SCIP_SOL* sol /**< primal CIP solution */
151  );
152 
153 /** informs the solution that it originates from a pseudo solution */
154 SCIP_EXPORT
155 void SCIPsolSetPseudo(
156  SCIP_SOL* sol /**< primal CIP solution */
157  );
158 
159 /** returns unique index of given solution */
160 SCIP_EXPORT
161 int SCIPsolGetIndex(
162  SCIP_SOL* sol /**< primal CIP solution */
163  );
164 
165 /** get maximum absolute bound violation of solution */
166 SCIP_EXPORT
168  SCIP_SOL* sol /**< primal CIP solution */
169  );
170 
171 /** get maximum relative bound violation of solution */
172 SCIP_EXPORT
174  SCIP_SOL* sol /**< primal CIP solution */
175  );
176 
177 /** get maximum absolute integrality violation of solution */
178 SCIP_EXPORT
180  SCIP_SOL* sol /**< primal CIP solution */
181  );
182 
183 /** get maximum absolute LP row violation of solution */
184 SCIP_EXPORT
186  SCIP_SOL* sol /**< primal CIP solution */
187  );
188 
189 /** get maximum relative LP row violation of solution */
190 SCIP_EXPORT
192  SCIP_SOL* sol /**< primal CIP solution */
193  );
194 
195 /** get maximum absolute constraint violation of solution */
196 SCIP_EXPORT
198  SCIP_SOL* sol /**< primal CIP solution */
199  );
200 
201 /** get maximum relative constraint violation of solution */
202 SCIP_EXPORT
204  SCIP_SOL* sol /**< primal CIP solution */
205  );
206 
207 #ifdef NDEBUG
208 
209 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
210  * speed up the algorithms.
211  */
212 
213 #define SCIPsolGetOrigin(sol) ((sol)->solorigin)
214 #define SCIPsolIsOriginal(sol) ((sol)->solorigin == SCIP_SOLORIGIN_ORIGINAL || (sol)->solorigin == SCIP_SOLORIGIN_PARTIAL)
215 #define SCIPsolGetOrigObj(sol) (sol)->obj
216 #define SCIPsolGetTime(sol) (sol)->time
217 #define SCIPsolGetNodenum(sol) (sol)->nodenum
218 #define SCIPsolGetRunnum(sol) (sol)->runnum
219 #define SCIPsolGetDepth(sol) (sol)->depth
220 #define SCIPsolGetHeur(sol) ((sol)->type == SCIP_SOLTYPE_HEUR ? (sol)->creator.heur : NULL)
221 #define SCIPsolGetRelax(sol) ((sol)->type == SCIP_SOLTYPE_RELAX ? (sol)->creator.relax : NULL)
222 #define SCIPsolGetIndex(sol) (sol)->index
223 #define SCIPsolGetType(sol) (sol)->type
224 #define SCIPsolSetLPRelaxation(sol) ((sol)->type = SCIP_SOLTYPE_LPRELAX)
225 #define SCIPsolSetStrongbranching(sol) ((sol)->type = SCIP_SOLTYPE_STRONGBRANCH)
226 #define SCIPsolSetPseudo(sol) ((sol)->type = SCIP_SOLTYPE_PSEUDO)
227 #endif
228 
229 /** @} */
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2530
void SCIPsolSetLPRelaxation(SCIP_SOL *sol)
Definition: sol.c:2708
SCIP_Real SCIPsolGetRelBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2432
void SCIPsolSetRelax(SCIP_SOL *sol, SCIP_RELAX *relax)
Definition: sol.c:2695
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2573
SCIP_Real SCIPsolGetAbsConsViolation(SCIP_SOL *sol)
Definition: sol.c:2472
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2550
SCIP_Real SCIPsolGetRelConsViolation(SCIP_SOL *sol)
Definition: sol.c:2482
SCIP_Real SCIPsolGetAbsIntegralityViolation(SCIP_SOL *sol)
Definition: sol.c:2442
type definitions for primal heuristics
SCIP_RELAX * SCIPsolGetRelax(SCIP_SOL *sol)
Definition: sol.c:2685
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2613
void SCIPsolSetPseudo(SCIP_SOL *sol)
Definition: sol.c:2728
type definitions for relaxators
datastructures for storing primal CIP solutions
SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
Definition: sol.c:2675
#define SCIP_Bool
Definition: def.h:93
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2593
SCIP_Real SCIPsolGetAbsBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2422
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2658
type definitions for storing primal CIP solutions
SCIP_Real SCIPsolGetRelLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2462
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2520
#define SCIP_Real
Definition: def.h:186
enum SCIP_SolType SCIP_SOLTYPE
Definition: type_sol.h:71
enum SCIP_SolOrigin SCIP_SOLORIGIN
Definition: type_sol.h:55
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2603
#define SCIP_Longint
Definition: def.h:171
void SCIPsolSetStrongbranching(SCIP_SOL *sol)
Definition: sol.c:2718
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2540
common defines and data types used in all packages of SCIP
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2583
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2644
SCIP_Real SCIPsolGetAbsLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2452