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-2025 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_rational.h"
40#include "scip/type_sol.h"
41#include "scip/type_heur.h"
42#include "scip/type_relax.h"
43
44#ifdef NDEBUG
45#include "scip/struct_sol.h"
46#endif
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/**@addtogroup PublicSolutionMethods
53 *
54 * @{
55 */
56
57
58/** gets origin of solution */
59SCIP_EXPORT
61 SCIP_SOL* sol /**< primal CIP solution */
62 );
63
64/** returns whether the given solution is defined on original variables */
65SCIP_EXPORT
67 SCIP_SOL* sol /**< primal CIP solution */
68 );
69
70/** returns whether a solution is an exact rational solution */
71SCIP_EXPORT
73 SCIP_SOL* sol /**< primal CIP solution */
74 );
75
76/** returns whether the given solution is partial */
77SCIP_EXPORT
79 SCIP_SOL* sol /**< primal CIP solution */
80 );
81
82/** gets objective value of primal CIP solution which lives in the original problem space */
83SCIP_EXPORT
85 SCIP_SOL* sol /**< primal CIP solution */
86 );
87
88/** adds value to the objective value of a given original primal CIP solution */
89SCIP_EXPORT
91 SCIP_SOL* sol, /**< primal CIP solution */
92 SCIP_RATIONAL* addval /**< offset value to add */
93 );
94
95/** gets clock time, when this solution was found */
96SCIP_EXPORT
98 SCIP_SOL* sol /**< primal CIP solution */
99 );
100
101/** gets branch and bound run number, where this solution was found */
102SCIP_EXPORT
104 SCIP_SOL* sol /**< primal CIP solution */
105 );
106
107/** gets node number of the specific branch and bound run, where this solution was found */
108SCIP_EXPORT
110 SCIP_SOL* sol /**< primal CIP solution */
111 );
112
113/** gets node's depth, where this solution was found */
114SCIP_EXPORT
116 SCIP_SOL* sol /**< primal CIP solution */
117 );
118
119/** gets information if solution was found by the LP, a primal heuristic, or a custom relaxator */
120SCIP_EXPORT
122 SCIP_SOL* sol /**< primal CIP solution */
123 );
124
125/** gets heuristic that found this solution, or NULL if solution has type different than SCIP_SOLTYPE_HEUR */
126SCIP_EXPORT
128 SCIP_SOL* sol /**< primal CIP solution */
129 );
130
131/** gets relaxation handler that found this solution, or NULL if solution has different type than SCIP_SOLTYPE_RELAX */
132SCIP_EXPORT
134 SCIP_SOL* sol /**< primal CIP solution */
135 );
136
137/** informs the solution that it now belongs to the given primal heuristic. For convenience and backwards compatibility,
138 * the method accepts NULL as input for \p heur, in which case the solution type is set to SCIP_SOLTYPE_LPRELAX.
139 *
140 * @note Relaxation handlers should use SCIPsolSetRelax() instead.
141 */
142SCIP_EXPORT
143void SCIPsolSetHeur(
144 SCIP_SOL* sol, /**< primal CIP solution */
145 SCIP_HEUR* heur /**< primal heuristic that found the solution, or NULL for LP solutions */
146 );
147
148/** informs the solution that it now belongs to the given relaxation handler */
149SCIP_EXPORT
150void SCIPsolSetRelax(
151 SCIP_SOL* sol, /**< primal CIP solution */
152 SCIP_RELAX* relax /**< relaxator that found the solution */
153 );
154
155/** informs the solution that it is an LP relaxation solution */
156SCIP_EXPORT
158 SCIP_SOL* sol /**< primal CIP solution */
159 );
160
161/** informs the solution that it is a solution found during strong branching */
162SCIP_EXPORT
164 SCIP_SOL* sol /**< primal CIP solution */
165 );
166
167/** informs the solution that it originates from a pseudo solution */
168SCIP_EXPORT
170 SCIP_SOL* sol /**< primal CIP solution */
171 );
172
173/** returns unique index of given solution */
174SCIP_EXPORT
176 SCIP_SOL* sol /**< primal CIP solution */
177 );
178
179/** get maximum absolute bound violation of solution */
180SCIP_EXPORT
182 SCIP_SOL* sol /**< primal CIP solution */
183 );
184
185/** get maximum relative bound violation of solution */
186SCIP_EXPORT
188 SCIP_SOL* sol /**< primal CIP solution */
189 );
190
191/** get maximum absolute integrality violation of solution */
192SCIP_EXPORT
194 SCIP_SOL* sol /**< primal CIP solution */
195 );
196
197/** get maximum absolute LP row violation of solution */
198SCIP_EXPORT
200 SCIP_SOL* sol /**< primal CIP solution */
201 );
202
203/** get maximum relative LP row violation of solution */
204SCIP_EXPORT
206 SCIP_SOL* sol /**< primal CIP solution */
207 );
208
209/** get maximum absolute constraint violation of solution */
210SCIP_EXPORT
212 SCIP_SOL* sol /**< primal CIP solution */
213 );
214
215/** get maximum relative constraint violation of solution */
216SCIP_EXPORT
218 SCIP_SOL* sol /**< primal CIP solution */
219 );
220
221/** comparison method for sorting solution by decreasing objective value (best solution will be sorted to the end) */
222SCIP_EXPORT
223SCIP_DECL_SORTPTRCOMP(SCIPsolComp);
224
225#ifdef NDEBUG
226
227/* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
228 * speed up the algorithms.
229 */
230
231#define SCIPsolGetOrigin(sol) ((sol)->solorigin)
232#define SCIPsolIsOriginal(sol) ((sol)->solorigin == SCIP_SOLORIGIN_ORIGINAL || (sol)->solorigin == SCIP_SOLORIGIN_PARTIAL)
233#define SCIPsolGetOrigObj(sol) (sol)->obj
234#define SCIPsolGetTime(sol) (sol)->time
235#define SCIPsolGetNodenum(sol) (sol)->nodenum
236#define SCIPsolGetRunnum(sol) (sol)->runnum
237#define SCIPsolGetDepth(sol) (sol)->depth
238#define SCIPsolGetHeur(sol) ((sol)->type == SCIP_SOLTYPE_HEUR ? (sol)->creator.heur : NULL)
239#define SCIPsolGetRelax(sol) ((sol)->type == SCIP_SOLTYPE_RELAX ? (sol)->creator.relax : NULL)
240#define SCIPsolGetIndex(sol) (sol)->index
241#define SCIPsolGetType(sol) (sol)->type
242#define SCIPsolSetLPRelaxation(sol) ((sol)->type = SCIP_SOLTYPE_LPRELAX)
243#define SCIPsolSetStrongbranching(sol) ((sol)->type = SCIP_SOLTYPE_STRONGBRANCH)
244#define SCIPsolSetPseudo(sol) ((sol)->type = SCIP_SOLTYPE_PSEUDO)
245#endif
246
247/** @} */
248
249#ifdef __cplusplus
250}
251#endif
252
253#endif
common defines and data types used in all packages of SCIP
#define SCIP_Longint
Definition: def.h:141
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:4130
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:4170
void SCIPsolSetLPRelaxation(SCIP_SOL *sol)
Definition: sol.c:4354
void SCIPsolOrigAddObjvalExact(SCIP_SOL *sol, SCIP_RATIONAL *addval)
Definition: sol.c:4205
void SCIPsolSetStrongbranching(SCIP_SOL *sol)
Definition: sol.c:4364
SCIP_Real SCIPsolGetRelBoundViolation(SCIP_SOL *sol)
Definition: sol.c:3977
SCIP_Real SCIPsolGetAbsConsViolation(SCIP_SOL *sol)
Definition: sol.c:4017
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:4219
SCIP_RELAX * SCIPsolGetRelax(SCIP_SOL *sol)
Definition: sol.c:4331
SCIP_Real SCIPsolGetAbsBoundViolation(SCIP_SOL *sol)
Definition: sol.c:3967
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:4239
SCIP_Real SCIPsolGetAbsIntegralityViolation(SCIP_SOL *sol)
Definition: sol.c:3987
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:4259
SCIP_Real SCIPsolGetAbsLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:3997
void SCIPsolSetRelax(SCIP_SOL *sol, SCIP_RELAX *relax)
Definition: sol.c:4341
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:4140
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:4290
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:4249
SCIP_Real SCIPsolGetRelLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:4007
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:4160
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:4229
SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
Definition: sol.c:4321
SCIP_Real SCIPsolGetRelConsViolation(SCIP_SOL *sol)
Definition: sol.c:4027
void SCIPsolSetPseudo(SCIP_SOL *sol)
Definition: sol.c:4374
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:4304
SCIP_DECL_SORTPTRCOMP(SCIPsolComp)
Definition: sol.c:4091
SCIP_Bool SCIPsolIsExact(SCIP_SOL *sol)
Definition: sol.c:4150
datastructures for storing primal CIP solutions
type definitions for primal heuristics
type definitions for rational numbers
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