Scippy

GCG

Branch-and-Price & Column Generation for Everyone

score.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file score.c
30 * @ingroup DECOMP
31 * @brief interface for score
32 * @author Jurgen Lentz
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#include "gcg/pub_score.h"
38#include "gcg/gcg.h"
39#include "scip/scip.h"
40#include "gcg/struct_score.h"
41#include "gcg/cons_decomp.h"
42
43#include <assert.h>
44
45
46/**
47 * @brief creates a score and includes it in GCG
48 * @returns scip return code
49 */
51 GCG* gcg, /**< GCG data structure */
52 const char* name, /**< name of score */
53 const char* shortname, /**< shortname of score */
54 const char* description, /**< description of score */
55 GCG_SCOREDATA* scoredata, /**< score data */
56 GCG_DECL_SCOREFREE ((*scorefree)), /**< destructor of score */
57 GCG_DECL_SCORECALC ((*scorecalc)) /**< score calculation method of score */
58 )
59{
60 /* check whether score is already present */
61 if( GCGfindScore(gcg, name) != NULL || GCGfindScoreByShortname(gcg, shortname) != NULL )
62 {
63 SCIPerrorMessage("Score <%s> is already included.\n", name);
64 return SCIP_INVALIDDATA;
65 }
66
67 SCIP_CALL( GCGconshdlrDecompIncludeScore(gcg, name, shortname, description, scoredata, scorefree, scorecalc) );
68
69 return SCIP_OKAY;
70}
71
72/**
73 * @brief searches for the score with the given name and returns it or NULL if score is not found
74 * @returns score pointer or NULL if score with given name is not found
75 */
77 GCG* gcg, /**< GCG data structure */
78 const char* name /**< name of score */
79 )
80{
81 assert(gcg != NULL);
82 assert(name != NULL);
83
84 return GCGconshdlrDecompFindScore(gcg, name);
85}
86
87/**
88 * @brief searches for the score with the given shortname and returns it or NULL if score is not found
89 * @returns score pointer or NULL if score with given shortname is not found
90 */
92 GCG* gcg, /**< GCG data structure */
93 const char* shortname /**< shortname of score */
94 )
95{
96 assert(gcg != NULL);
97 assert(shortname != NULL);
98
100}
101
102/** returns the array of currently available scores */
104 GCG* gcg /**< GCG data structure */
105 )
106{
107 assert(gcg != NULL);
108
110}
111
112/** returns the number of currently available scores */
114 GCG* gcg /**< GCG data structure */
115 )
116{
117 assert(gcg != NULL);
118
120}
121
122/** gets user data of score */
124 GCG_SCORE* score /**< score */
125 )
126{
127 assert(score != NULL);
128
129 return score->scoredata;
130}
131
132/** sets user data of score; user has to free old data in advance! */
134 GCG_SCORE* score, /**< score */
135 GCG_SCOREDATA* scoredata /**< new score user data */
136 )
137{
138 assert(score != NULL);
139
140 score->scoredata = scoredata;
141}
142
143
144/** gets name of score */
145const char* GCGscoreGetName(
146 GCG_SCORE* score /**< score */
147 )
148{
149 assert(score != NULL);
150
151 return score->name;
152}
153
154/** gets shortname of score */
156 GCG_SCORE* score /**< score */
157 )
158{
159 assert(score != NULL);
160
161 return score->shortname;
162}
163
164/** gets description of score */
165const char* GCGscoreGetDesc(
166 GCG_SCORE* score /**< score */
167 )
168{
169 assert(score != NULL);
170
171 return score->description;
172}
GCG_SCORE ** GCGconshdlrDecompGetScores(GCG *gcg)
Gets an array of all scores.
GCG_SCORE * GCGconshdlrDecompFindScoreByShortname(GCG *gcg, const char *shortname)
searches for the score with the given shortname and returns it or NULL if score is not found
int GCGconshdlrDecompGetNScores(GCG *gcg)
Gets the number of all scores.
SCIP_RETCODE GCGconshdlrDecompIncludeScore(GCG *gcg, const char *name, const char *shortname, const char *description, GCG_SCOREDATA *scoredata, GCG_DECL_SCOREFREE((*scorefree)),)
GCG_SCORE * GCGconshdlrDecompFindScore(GCG *gcg, const char *name)
searches for the score with the given name and returns it or NULL if score is not found
constraint handler for structure detection
#define SCIP_CALL(x)
GCG interface methods.
GCG_SCOREDATA * GCGscoreGetData(GCG_SCORE *score)
Definition: score.c:123
const char * GCGscoreGetName(GCG_SCORE *score)
Definition: score.c:145
int GCGgetNScores(GCG *gcg)
Definition: score.c:113
void GCGscoreSetData(GCG_SCORE *score, GCG_SCOREDATA *scoredata)
Definition: score.c:133
GCG_SCORE * GCGfindScoreByShortname(GCG *gcg, const char *shortname)
searches for the score with the given shortname and returns it or NULL if score is not found
Definition: score.c:91
GCG_SCORE ** GCGgetScores(GCG *gcg)
Definition: score.c:103
SCIP_RETCODE GCGincludeScore(GCG *gcg, const char *name, const char *shortname, const char *description, GCG_SCOREDATA *scoredata, GCG_DECL_SCOREFREE((*scorefree)), GCG_DECL_SCORECALC((*scorecalc)))
creates a score and includes it in GCG
Definition: score.c:50
const char * GCGscoreGetDesc(GCG_SCORE *score)
Definition: score.c:165
const char * GCGscoreGetShortname(GCG_SCORE *score)
Definition: score.c:155
GCG_SCORE * GCGfindScore(GCG *gcg, const char *name)
searches for the score with the given name and returns it or NULL if score is not found
Definition: score.c:76
#define NULL
#define SCIPerrorMessage
public methods for score
const char * name
Definition: struct_score.h:50
const char * description
Definition: struct_score.h:52
const char * shortname
Definition: struct_score.h:51
GCG_SCOREDATA * scoredata
Definition: struct_score.h:55
Definition: struct_gcg.h:55
data structures for score
SCIP_INVALIDDATA
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE
#define GCG_DECL_SCOREFREE(x)
Definition: type_score.h:55
#define GCG_DECL_SCORECALC(x)
Definition: type_score.h:66