Scippy

GCG

Branch-and-Price & Column Generation for Everyone

score_border.cpp
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_border.cpp
30 * @brief border area score
31 * @author Jurgen Lentz
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
38#include "gcg/cons_decomp.h"
39#include "gcg/cons_decomp.hpp"
40#include "gcg/score_border.h"
41
42/* score properties */
43#define SCORE_NAME "border area"
44#define SCORE_SHORTNAME "border"
45#define SCORE_DESC "minimum border score (i.e. minimizes fraction of border area score)"
46
47
48/*
49 * Data structures
50 */
51struct GCG_ScoreData
52{
53};
54
55
56/*
57 * Local methods
58 */
59
60/* put your local methods here, and declare them static */
61
62
63
64
65/*
66 * score callback methods
67 */
68
69/** destructor of score to free user data (called when GCG is exiting) */
70#define scoreFreeBorder NULL
71
72static
73GCG_DECL_SCORECALC(scoreCalcBorder)
74{
75 unsigned long matrixarea;
76 unsigned long borderarea;
77
79
80 matrixarea = (unsigned long) partialdec->getNVars() * (unsigned long)partialdec->getNConss();
81 borderarea = 0;
82
83 borderarea += (unsigned long) ( partialdec->getNLinkingvars() + partialdec->getNTotalStairlinkingvars() ) * (unsigned long) partialdec->getNConss();
84 borderarea += (unsigned long) partialdec->getNMasterconss() * ( (unsigned long) partialdec->getNVars() - ( partialdec->getNLinkingvars() + partialdec->getNTotalStairlinkingvars() ) ) ;
85
86 *scorevalue = 1. - (matrixarea == 0 ? 0 : ( (SCIP_Real) borderarea / (SCIP_Real) matrixarea ));
87
88 return SCIP_OKAY;
89}
90
91
92
93
94/*
95 * score specific interface methods
96 */
97
98/** creates the border score and includes it in SCIP */
100 GCG* gcg /**< GCG data structure */
101 )
102{
103 GCG_SCOREDATA* scoredata = NULL;
104
105 SCIP_CALL(
107 scoreFreeBorder, scoreCalcBorder) );
108
109 return SCIP_OKAY;
110}
class storing partialdecs and the problem matrix
class storing (potentially incomplete) decompositions
class to manage partial decompositions
GCG_EXPORT int getNConss()
Gets the number of constraints.
GCG_EXPORT int getNMasterconss()
Gets size of the vector containing master conss.
GCG_EXPORT int getNVars()
Gets number of vars.
GCG_EXPORT int getNLinkingvars()
Gets size of the vector containing linking vars.
GCG_EXPORT int getNTotalStairlinkingvars()
Gets total number of stairlinking vars.
PARTIALDECOMP * GCGconshdlrDecompGetPartialdecFromID(GCG *gcg, int partialdecid)
local method to find a partialdec for a given id or NULL if no partialdec with such id is found
constraint handler for structure detection
C++ interface of cons_decomp.
#define SCIP_Real
#define SCIP_CALL(x)
GCG_EXPORT 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
#define NULL
SCIP_RETCODE GCGincludeScoreBorder(GCG *gcg)
static GCG_DECL_SCORECALC(scoreCalcBorder)
#define SCORE_SHORTNAME
#define SCORE_NAME
#define scoreFreeBorder
#define SCORE_DESC
border area score
Definition: struct_gcg.h:55
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE