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