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-2016 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 }
RLP file reader (LP format with generic variables and row names)
SCIP_RETCODE SCIPreadLp(SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
Definition: reader_lp.c:3421
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:510
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1248
#define NULL
Definition: lpi_spx.cpp:130
#define TRUE
Definition: def.h:55
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIP_CALL(x)
Definition: def.h:266
SCIP_RETCODE SCIPincludeReaderRlp(SCIP *scip)
Definition: reader_rlp.c:97
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip.c:4601
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:3493
static SCIP_DECL_READERREAD(readerReadRlp)
Definition: reader_rlp.c:54
static SCIP_DECL_READERWRITE(readerWriteRlp)
Definition: reader_rlp.c:65
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip.c:4649
struct SCIP_ReaderData SCIP_READERDATA
Definition: type_reader.h:37
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip.c:4563
#define READER_EXTENSION
Definition: reader_rlp.c:30
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
Definition: scip.c:39265
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip.c:4673
#define READER_NAME
Definition: reader_rlp.c:28
LP file reader.
#define READER_DESC
Definition: reader_rlp.c:29
static SCIP_DECL_READERCOPY(readerCopyRlp)
Definition: reader_rlp.c:39
SCIP_RETCODE SCIPprintTransProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
Definition: scip.c:39309