Scippy

SCIP

Solving Constraint Integer Programs

reader_rlp.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_rlp.c
17  * @brief RLP file reader (LP format with generic variables and row names)
18  * @author Stefan Heinz
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <string.h>
24 
25 #include "scip/reader_lp.h"
26 #include "scip/reader_rlp.h"
27 
28 #define READER_NAME "rlpreader"
29 #define READER_DESC "file reader for MIPs in IBM CPLEX's RLP file format"
30 #define READER_EXTENSION "rlp"
31 
32 
33 /*
34  * Callback methods of reader
35  */
36 
37 /** copy method for reader plugins (called when SCIP copies plugins) */
38 static
39 SCIP_DECL_READERCOPY(readerCopyRlp)
40 { /*lint --e{715}*/
41  assert(scip != NULL);
42  assert(reader != NULL);
43  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
44 
45  /* call inclusion method of reader */
47 
48  return SCIP_OKAY;
49 }
50 
51 
52 /** problem reading method of reader */
53 static
54 SCIP_DECL_READERREAD(readerReadRlp)
55 { /*lint --e{715}*/
56 
57  SCIP_CALL( SCIPreadLp(scip, reader, filename, result) );
58 
59  return SCIP_OKAY;
60 }
61 
62 
63 /** problem writing method of reader */
64 static
65 SCIP_DECL_READERWRITE(readerWriteRlp)
66 { /*lint --e{715}*/
67  if( genericnames )
68  {
69  SCIP_CALL( SCIPwriteLp(scip, file, name, transformed, objsense, objscale, objoffset, vars,
70  nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
71  }
72  else
73  {
74  SCIPwarningMessage(scip, "RLP format is LP format with generic variable and constraint names\n");
75 
76  if( transformed )
77  {
78  SCIPwarningMessage(scip, "write transformed problem with generic variable and constraint names\n");
79  SCIP_CALL( SCIPprintTransProblem(scip, file, "rlp", TRUE) );
80  }
81  else
82  {
83  SCIPwarningMessage(scip, "write original problem with generic variable and constraint names\n");
84  SCIP_CALL( SCIPprintOrigProblem(scip, file, "rlp", TRUE) );
85  }
86  *result = SCIP_SUCCESS;
87  }
88  return SCIP_OKAY;
89 }
90 
91 
92 /*
93  * reader specific interface methods
94  */
95 
96 /** includes the rlp file reader in SCIP */
98  SCIP* scip /**< SCIP data structure */
99  )
100 {
101  SCIP_READERDATA* readerdata;
102  SCIP_READER* reader;
103 
104  /* create reader data */
105  readerdata = NULL;
106 
107  /* include reader */
109 
110  assert(reader != NULL);
111 
112  /* set non fundamental callbacks via setter functions */
113  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyRlp) );
114  SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadRlp) );
115  SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteRlp) );
116 
117  return SCIP_OKAY;
118 }
119