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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file reader_rlp.c
26  * @ingroup DEFPLUGINS_READER
27  * @brief RLP file reader (LP format with generic variables and row names)
28  * @author Stefan Heinz
29  */
30 
31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32 
33 #include "scip/pub_message.h"
34 #include "scip/pub_reader.h"
35 #include "scip/reader_lp.h"
36 #include "scip/reader_rlp.h"
37 #include "scip/scip_message.h"
38 #include "scip/scip_reader.h"
39 #include "scip/scip_solvingstats.h"
40 #include <string.h>
41 
42 #define READER_NAME "rlpreader"
43 #define READER_DESC "file reader for MIPs in IBM CPLEX's RLP file format"
44 #define READER_EXTENSION "rlp"
45 
46 
47 /*
48  * Callback methods of reader
49  */
50 
51 /** copy method for reader plugins (called when SCIP copies plugins) */
52 static
53 SCIP_DECL_READERCOPY(readerCopyRlp)
54 { /*lint --e{715}*/
55  assert(scip != NULL);
56  assert(reader != NULL);
57  assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
58 
59  /* call inclusion method of reader */
61 
62  return SCIP_OKAY;
63 }
64 
65 
66 /** problem reading method of reader */
67 static
68 SCIP_DECL_READERREAD(readerReadRlp)
69 { /*lint --e{715}*/
70 
71  SCIP_CALL( SCIPreadLp(scip, reader, filename, result) );
72 
73  return SCIP_OKAY;
74 }
75 
76 
77 /** problem writing method of reader */
78 static
79 SCIP_DECL_READERWRITE(readerWriteRlp)
80 { /*lint --e{715}*/
81  if( genericnames )
82  {
83  SCIP_CALL( SCIPwriteLp(scip, file, name, transformed, objsense, objscale, objoffset, vars,
84  nvars, nbinvars, nintvars, nimplvars, ncontvars, conss, nconss, result) );
85  }
86  else
87  {
88  SCIPwarningMessage(scip, "RLP format is LP format with generic variable and constraint names\n");
89 
90  if( transformed )
91  {
92  SCIPwarningMessage(scip, "write transformed problem with generic variable and constraint names\n");
93  SCIP_CALL( SCIPprintTransProblem(scip, file, "rlp", TRUE) );
94  }
95  else
96  {
97  SCIPwarningMessage(scip, "write original problem with generic variable and constraint names\n");
98  SCIP_CALL( SCIPprintOrigProblem(scip, file, "rlp", TRUE) );
99  }
100  *result = SCIP_SUCCESS;
101  }
102  return SCIP_OKAY;
103 }
104 
105 
106 /*
107  * reader specific interface methods
108  */
109 
110 /** includes the rlp file reader in SCIP */
112  SCIP* scip /**< SCIP data structure */
113  )
114 {
115  SCIP_READER* reader;
116 
117  /* include reader */
119 
120  assert(reader != NULL);
121 
122  /* set non fundamental callbacks via setter functions */
123  SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyRlp) );
124  SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadRlp) );
125  SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteRlp) );
126 
127  return SCIP_OKAY;
128 }
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:557
#define TRUE
Definition: def.h:95
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:120
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:164
static SCIP_DECL_READERREAD(readerReadRlp)
Definition: reader_rlp.c:68
#define SCIP_CALL(x)
Definition: def.h:394
static SCIP_DECL_READERWRITE(readerWriteRlp)
Definition: reader_rlp.c:79
SCIP_RETCODE SCIPincludeReaderBasic(SCIP *scip, SCIP_READER **readerptr, const char *name, const char *desc, const char *extension, SCIP_READERDATA *readerdata)
Definition: scip_reader.c:109
#define READER_EXTENSION
Definition: reader_rlp.c:44
SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
Definition: scip_reader.c:219
SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
Definition: scip_reader.c:147
#define READER_NAME
Definition: reader_rlp.c:42
LP file reader.
#define READER_DESC
Definition: reader_rlp.c:43
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:3430
SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
Definition: scip_reader.c:195
SCIP_RETCODE SCIPincludeReaderRlp(SCIP *scip)
Definition: reader_rlp.c:111
static SCIP_DECL_READERCOPY(readerCopyRlp)
Definition: reader_rlp.c:53
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:3507
public methods for reader plugins