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 visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 /**@file reader_wbo.c
17 * @ingroup DEFPLUGINS_READER
18 * @brief WBO file reader (OPB format with weighted constraints)
19 * @author Michael Winkler
20 */
21
22 /* For file format description see opb-reader. */
23
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25
26 #include "scip/pub_message.h"
27 #include "scip/pub_reader.h"
28 #include "scip/reader_opb.h"
29 #include "scip/reader_wbo.h"
30 #include "scip/scip_reader.h"
31 #include <string.h>
32
33 #define READER_NAME "wboreader"
34 #define READER_DESC "file reader for pseudoboolean wbo file format"
35 #define READER_EXTENSION "wbo"
36
37 /*
38 * Callback methods of reader
39 */
40
41 /** copy method for reader plugins (called when SCIP copies plugins) */
42 static
SCIP_DECL_READERCOPY(readerCopyWbo)43 SCIP_DECL_READERCOPY(readerCopyWbo)
44 { /*lint --e{715}*/
45 assert(scip != NULL);
46 assert(reader != NULL);
47 assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
48
49 /* call inclusion method of reader */
50 SCIP_CALL( SCIPincludeReaderWbo(scip) );
51
52 return SCIP_OKAY;
53 }
54
55
56 /** problem reading method of reader */
57 static
SCIP_DECL_READERREAD(readerReadWbo)58 SCIP_DECL_READERREAD(readerReadWbo)
59 { /*lint --e{715}*/
60
61 SCIP_CALL( SCIPreadOpb(scip, reader, filename, result) );
62
63 return SCIP_OKAY;
64 }
65
66
67 /** problem writing method of reader */
68 static
SCIP_DECL_READERWRITE(readerWriteWbo)69 SCIP_DECL_READERWRITE(readerWriteWbo)
70 { /*lint --e{715}*/
71 SCIP_CALL( SCIPwriteOpb(scip, file, name, transformed, objsense, objscale, objoffset, vars,
72 nvars, nbinvars, nintvars, nimplvars, ncontvars, fixedvars, nfixedvars, conss, nconss, genericnames, result) );
73
74 return SCIP_OKAY;
75 }
76
77
78 /*
79 * reader specific interface methods
80 */
81
82 /** includes the wbo file reader in SCIP */
SCIPincludeReaderWbo(SCIP * scip)83 SCIP_RETCODE SCIPincludeReaderWbo(
84 SCIP* scip /**< SCIP data structure */
85 )
86 {
87 SCIP_READER* reader;
88
89 /* include reader */
90 SCIP_CALL( SCIPincludeReaderBasic(scip, &reader, READER_NAME, READER_DESC, READER_EXTENSION, NULL) );
91
92 assert(reader != NULL);
93
94 /* set non fundamental callbacks via setter functions */
95 SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyWbo) );
96 SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadWbo) );
97 SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteWbo) );
98
99 return SCIP_OKAY;
100 }
101