Scippy

SCIP

Solving Constraint Integer Programs

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