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-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 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
48extern "C" {
49#endif
50
51/**@addtogroup PublicSolutionMethods
52 *
53 * @{
54 */
55
56
57/** gets origin of solution */
58SCIP_EXPORT
60 SCIP_SOL* sol /**< primal CIP solution */
61 );
62
63/** returns whether the given solution is defined on original variables */
64SCIP_EXPORT
66 SCIP_SOL* sol /**< primal CIP solution */
67 );
68
69/** returns whether the given solution is partial */
70SCIP_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 */
76SCIP_EXPORT
78 SCIP_SOL* sol /**< primal CIP solution */
79 );
80
81/** gets clock time, when this solution was found */
82SCIP_EXPORT
84 SCIP_SOL* sol /**< primal CIP solution */
85 );
86
87/** gets branch and bound run number, where this solution was found */
88SCIP_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 */
94SCIP_EXPORT
96 SCIP_SOL* sol /**< primal CIP solution */
97 );
98
99/** gets node's depth, where this solution was found */
100SCIP_EXPORT
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 */
106SCIP_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 */
112SCIP_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 */
118SCIP_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 */
128SCIP_EXPORT
129void 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 */
135SCIP_EXPORT
136void 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 */
142SCIP_EXPORT
144 SCIP_SOL* sol /**< primal CIP solution */
145 );
146
147/** informs the solution that it is a solution found during strong branching */
148SCIP_EXPORT
150 SCIP_SOL* sol /**< primal CIP solution */
151 );
152
153/** informs the solution that it originates from a pseudo solution */
154SCIP_EXPORT
156 SCIP_SOL* sol /**< primal CIP solution */
157 );
158
159/** returns unique index of given solution */
160SCIP_EXPORT
162 SCIP_SOL* sol /**< primal CIP solution */
163 );
164
165/** get maximum absolute bound violation of solution */
166SCIP_EXPORT
168 SCIP_SOL* sol /**< primal CIP solution */
169 );
170
171/** get maximum relative bound violation of solution */
172SCIP_EXPORT
174 SCIP_SOL* sol /**< primal CIP solution */
175 );
176
177/** get maximum absolute integrality violation of solution */
178SCIP_EXPORT
180 SCIP_SOL* sol /**< primal CIP solution */
181 );
182
183/** get maximum absolute LP row violation of solution */
184SCIP_EXPORT
186 SCIP_SOL* sol /**< primal CIP solution */
187 );
188
189/** get maximum relative LP row violation of solution */
190SCIP_EXPORT
192 SCIP_SOL* sol /**< primal CIP solution */
193 );
194
195/** get maximum absolute constraint violation of solution */
196SCIP_EXPORT
198 SCIP_SOL* sol /**< primal CIP solution */
199 );
200
201/** get maximum relative constraint violation of solution */
202SCIP_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
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_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2711
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2741
void SCIPsolSetLPRelaxation(SCIP_SOL *sol)
Definition: sol.c:2899
void SCIPsolSetStrongbranching(SCIP_SOL *sol)
Definition: sol.c:2909
SCIP_Real SCIPsolGetRelBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2623
SCIP_Real SCIPsolGetAbsConsViolation(SCIP_SOL *sol)
Definition: sol.c:2663
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2764
SCIP_RELAX * SCIPsolGetRelax(SCIP_SOL *sol)
Definition: sol.c:2876
SCIP_Real SCIPsolGetAbsBoundViolation(SCIP_SOL *sol)
Definition: sol.c:2613
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2784
SCIP_Real SCIPsolGetAbsIntegralityViolation(SCIP_SOL *sol)
Definition: sol.c:2633
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2804
SCIP_Real SCIPsolGetAbsLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2643
void SCIPsolSetRelax(SCIP_SOL *sol, SCIP_RELAX *relax)
Definition: sol.c:2886
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2721
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2835
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2794
SCIP_Real SCIPsolGetRelLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:2653
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2731
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2774
SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
Definition: sol.c:2866
SCIP_Real SCIPsolGetRelConsViolation(SCIP_SOL *sol)
Definition: sol.c:2673
void SCIPsolSetPseudo(SCIP_SOL *sol)
Definition: sol.c:2919
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2849
datastructures for storing primal CIP solutions
type definitions for primal heuristics
type definitions for relaxators
type definitions for storing primal CIP solutions
enum SCIP_SolType SCIP_SOLTYPE
Definition: type_sol.h:71
enum SCIP_SolOrigin SCIP_SOLORIGIN
Definition: type_sol.h:55