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-2019 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 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 "scip/pub_message.h"
24 #include "scip/pub_reader.h"
25 #include "scip/reader_lp.h"
26 #include "scip/reader_rlp.h"
27 #include "scip/scip_message.h"
28 #include "scip/scip_reader.h"
29 #include "scip/scip_solvingstats.h"
30 #include <string.h>
31 
32 #define READER_NAME "rlpreader"
33 #define READER_DESC "file reader for MIPs in IBM CPLEX's RLP file format"
34 #define READER_EXTENSION "rlp"
35 
36 
37 /*
38  * Callback methods of reader
39  */
40 
41 /** copy method for reader plugins (called when SCIP copies plugins) */
42 static
43 SCIP_DECL_READERCOPY(readerCopyRlp)
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 */
51 
52  return SCIP_OKAY;
53 }
54 
55 
56 /** problem reading method of reader */
57 static
58 SCIP_DECL_READERREAD(readerReadRlp)
59 { /*lint --e{715}*/
60 
61  SCIP_CALL( SCIPreadLp(scip, reader, filename, result) );
62 
63  return SCIP_OKAY;
64 }
65 
66 
67 /** problem writing method of reader */
68 static
69 SCIP_DECL_READERWRITE(readerWriteRlp)
70 { /*lint --e{715}*/
71  if( genericnames )
72  {
73  SCIP_CALL( SCIPwriteLp(scip, file, name, transformed, objsense, objscale, objoffset, vars,
74  nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
75  }
76  else
77  {
78  SCIPwarningMessage(scip, "RLP format is LP format with generic variable and constraint names\n");
79 
80  if( transformed )
81  {
82  SCIPwarningMessage(scip, "write transformed problem with generic variable and constraint names\n");
83  SCIP_CALL( SCIPprintTransProblem(scip, file, "rlp", TRUE) );
84  }
85  else
86  {
87  SCIPwarningMessage(scip, "write original problem with generic variable and constraint names\n");
88  SCIP_CALL( SCIPprintOrigProblem(scip, file, "rlp", TRUE) );
89  }
90  *result = SCIP_SUCCESS;
91  }
92  return SCIP_OKAY;
93 }
94 
95 
96 /*
97  * reader specific interface methods
98  */
99 
100 /** includes the rlp file reader in SCIP */
102  SCIP* scip /**< SCIP data structure */
103  )
104 {
105  SCIP_READER* reader;
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 }
#define NULL
Definition: def.h:246
RLP file reader (LP format with generic variables and row names)
SCIP_RETCODE SCIPprintTransProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:547
#define TRUE
Definition: def.h:71
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:203
public methods for querying solving statistics
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
static SCIP_DECL_READERREAD(readerReadRlp)
Definition: reader_rlp.c:58
#define SCIP_CALL(x)
Definition: def.h:358
static SCIP_DECL_READERWRITE(readerWriteRlp)
Definition: reader_rlp.c:69
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:180
#define READER_EXTENSION
Definition: reader_rlp.c:34
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip_reader.c:290
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip_reader.c:218
#define READER_NAME
Definition: reader_rlp.c:32
LP file reader.
#define READER_DESC
Definition: reader_rlp.c:33
public methods for message output
public methods for input file readers
public methods for message handling
SCIP_RETCODE SCIPreadLp(SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
Definition: reader_lp.c:3466
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:266
SCIP_RETCODE SCIPincludeReaderRlp(SCIP *scip)
Definition: reader_rlp.c:101
static SCIP_DECL_READERCOPY(readerCopyRlp)
Definition: reader_rlp.c:43
SCIP_RETCODE SCIPwriteLp(SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objscale, SCIP_Real objoffset, SCIP_VAR **vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)
Definition: reader_lp.c:3539
public methods for reader plugins