Scippy

SCIP

Solving Constraint Integer Programs

reader_gr.c
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-2021 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file reader_gr.c
17  * @brief Steiner tree problem file reader
18  * @author Daniel Rehfeldt
19  *
20  * This file implements the reader used to read and write Steiner tree problems.
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #include <assert.h>
26 #include <string.h>
27 
28 #include "probdata_stp.h"
29 #include "reader_gr.h"
30 #include "grph.h"
31 
32 
33 /**@name Reader properties
34  *
35  * @{
36  */
37 
38 #define READER_NAME "grreader"
39 #define READER_DESC "file reader for Steiner tree data format (gr)"
40 #define READER_EXTENSION "gr"
41 
42 
43 /**@} */
44 
45 
46 /**@name Callback methods
47  *
48  * @{
49  */
50 
51 /** copy method for reader plugins (called when SCIP copies plugins) */
52 static
53 SCIP_DECL_READERCOPY(readerCopyGr)
54 { /*lint --e{715}*/
55  assert(scip != NULL);
56  assert(reader != NULL);
57  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
58 
59  /* call inclusion method of reader */
61 
62  return SCIP_OKAY;
63 }
64 
65 /** problem reading method of the reader */
66 static
67 SCIP_DECL_READERREAD(readerReadGr)
68 { /*lint --e{715}*/
69  SCIP_RETCODE retcode;
70  SCIP_PROBDATA* probdata;
71 
72  *result = SCIP_DIDNOTRUN;
73 
74  retcode = SCIPprobdataCreate(scip, filename);
75 
76  if( retcode == SCIP_READERROR )
77  return SCIP_READERROR;
78 
79  SCIP_CALL( retcode );
80 
81  probdata = SCIPgetProbData(scip);
82  if( SCIPgetStage(scip) == SCIP_STAGE_INIT || probdata == NULL )
83  return SCIP_READERROR;
84 
85  *result = SCIP_SUCCESS;
86  return SCIP_OKAY;
87 }
88 
89 
90 /**@} */
91 
92 
93 /**@name Interface methods
94  *
95  * @{
96  */
97 
98 
99 /** includes the gr file reader in SCIP */
101  SCIP* scip /**< SCIP data structure */
102  )
103 {
104  SCIP_READERDATA* readerdata;
105  SCIP_READER* reader;
106 
107  /* create reader data */
108  readerdata = NULL;
109 
110  /* include reader */
112  assert(reader != NULL);
113 
114  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyGr) );
115  SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadGr) );
116 
117  return SCIP_OKAY;
118 }
119 
120 /**@} */
SCIP_EXPORT const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:548
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:186
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip_reader.c:138
Problem data for stp problem.
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_PROBDATA * SCIPgetProbData(SCIP *scip)
Definition: scip_prob.c:962
SCIP_RETCODE SCIPprobdataCreate(SCIP *scip, const char *probname, int *demands, SCIP_Real *rints, SCIP_Real *rexts, int ntypes, SCIP_Real width, SCIP_Real height)
#define READER_EXTENSION
Definition: reader_gr.c:40
#define READER_DESC
Definition: reader_gr.c:39
#define NULL
Definition: lpi_spx1.cpp:155
#define SCIP_CALL(x)
Definition: def.h:370
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:44
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:100
includes various files containing graph methods used for Steiner tree problems
struct SCIP_ProbData SCIP_PROBDATA
Definition: type_prob.h:44
static SCIP_DECL_READERREAD(readerReadGr)
Definition: reader_gr.c:67
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:356
SCIP_RETCODE SCIPincludeReaderGr(SCIP *scip)
Definition: reader_gr.c:100
#define READER_NAME
Definition: reader_gr.c:38
static SCIP_DECL_READERCOPY(readerCopyGr)
Definition: reader_gr.c:53