SCIP

    Solving Constraint Integer Programs

    reader_wbo.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-2026 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_wbo.c
    26 * @ingroup DEFPLUGINS_READER
    27 * @brief WBO file reader (OPB format with weighted constraints)
    28 * @author Michael Winkler
    29 */
    30
    31/* For file format description see opb-reader. */
    32
    33/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    34
    35#include "scip/pub_message.h"
    36#include "scip/pub_reader.h"
    37#include "scip/reader_opb.h"
    38#include "scip/reader_wbo.h"
    39#include "scip/scip_exact.h"
    40#include "scip/scip_reader.h"
    41
    42
    43#define READER_NAME "wboreader"
    44#define READER_DESC "file reader for pseudoboolean wbo file format"
    45#define READER_EXTENSION "wbo"
    46
    47/*
    48 * Callback methods of reader
    49 */
    50
    51/** copy method for reader plugins (called when SCIP copies plugins) */
    52static
    54{ /*lint --e{715}*/
    55 assert(scip != NULL);
    56 assert(reader != NULL);
    57
    59
    60 /* call inclusion method of reader */
    62
    63 return SCIP_OKAY;
    64}
    65
    66
    67/** problem reading method of reader */
    68static
    70{ /*lint --e{715}*/
    71
    72 SCIP_CALL( SCIPreadOpb(scip, reader, filename, result) );
    73
    74 return SCIP_OKAY;
    75}
    76
    77
    78/** problem writing method of reader */
    79static
    80SCIP_DECL_READERWRITE(readerWriteWbo)
    81{ /*lint --e{715}*/
    82 assert(reader != NULL);
    83
    85
    86 if( SCIPisExact(scip) )
    87 {
    88 SCIPerrorMessage("WBO reader cannot yet write problems in exact solving mode\n");
    89 return SCIP_WRITEERROR;
    90 }
    91
    92 SCIP_CALL( SCIPwriteOpb(scip, file, name, transformed, objsense, objoffset, objscale, objoffsetexact, objscaleexact,
    93 vars, nvars, nbinvars, nintvars, nimplvars, ncontvars, fixedvars, nfixedvars, conss, nconss, genericnames, result) );
    94
    95 return SCIP_OKAY;
    96}
    97
    98
    99/*
    100 * reader specific interface methods
    101 */
    102
    103/** includes the wbo file reader in SCIP */
    105 SCIP* scip /**< SCIP data structure */
    106 )
    107{
    108 SCIP_READER* reader;
    109
    110 /* include reader with opb data */
    112
    113 assert(reader != NULL);
    114
    115 /* reader is safe to use in exact solving mode, but exact writing still needs to be implemented (in OPB reader) */
    116 SCIPreaderMarkExact(reader);
    117
    118 /* set non fundamental callbacks via setter functions */
    119 SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyWbo) );
    120 SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadWbo) );
    121 SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteWbo) );
    122
    123 return SCIP_OKAY;
    124}
    #define NULL
    Definition: def.h:257
    #define SCIP_STRINGEQ(name, reference, retcode)
    Definition: def.h:454
    #define SCIP_CALL(x)
    Definition: def.h:364
    SCIP_RETCODE SCIPreadOpb(SCIP *scip, SCIP_READER *reader, const char *filename, SCIP_RESULT *result)
    Definition: reader_opb.c:4551
    SCIP_RETCODE SCIPwriteOpb(SCIP *scip, FILE *file, const char *name, SCIP_Bool transformed, SCIP_OBJSENSE objsense, SCIP_Real objoffset, SCIP_Real objscale, SCIP_RATIONAL *objoffsetexact, SCIP_RATIONAL *objscaleexact, SCIP_VAR **vars, int nvars, int nbinvars, int nintvars, int nimplvars, int ncontvars, SCIP_VAR **fixedvars, int nfixedvars, SCIP_CONS **conss, int nconss, SCIP_Bool genericnames, SCIP_RESULT *result)
    Definition: reader_opb.c:4632
    SCIP_RETCODE SCIPincludeReaderWbo(SCIP *scip)
    Definition: reader_wbo.c:104
    SCIP_Bool SCIPisExact(SCIP *scip)
    Definition: scip_exact.c:193
    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
    SCIP_RETCODE SCIPsetReaderCopy(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERCOPY((*readercopy)))
    Definition: scip_reader.c:147
    SCIP_READERDATA * SCIPreaderGetData(SCIP_READER *reader)
    Definition: reader.c:625
    SCIP_READER * SCIPfindReader(SCIP *scip, const char *name)
    Definition: scip_reader.c:235
    const char * SCIPreaderGetName(SCIP_READER *reader)
    Definition: reader.c:700
    SCIP_RETCODE SCIPsetReaderRead(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERREAD((*readerread)))
    Definition: scip_reader.c:195
    void SCIPreaderMarkExact(SCIP_READER *reader)
    Definition: reader.c:690
    SCIP_RETCODE SCIPsetReaderWrite(SCIP *scip, SCIP_READER *reader, SCIP_DECL_READERWRITE((*readerwrite)))
    Definition: scip_reader.c:219
    public methods for message output
    #define SCIPerrorMessage
    Definition: pub_message.h:64
    public methods for input file readers
    pseudo-Boolean file reader (opb format)
    static SCIP_DECL_READERREAD(readerReadWbo)
    Definition: reader_wbo.c:69
    #define READER_DESC
    Definition: reader_wbo.c:44
    #define READER_EXTENSION
    Definition: reader_wbo.c:45
    static SCIP_DECL_READERCOPY(readerCopyWbo)
    Definition: reader_wbo.c:53
    #define READER_NAME
    Definition: reader_wbo.c:43
    static SCIP_DECL_READERWRITE(readerWriteWbo)
    Definition: reader_wbo.c:80
    WBO file reader (LP format with generic variables and row names)
    public methods for exact solving
    public methods for reader plugins
    @ SCIP_WRITEERROR
    Definition: type_retcode.h:46
    @ SCIP_OKAY
    Definition: type_retcode.h:42
    @ SCIP_INVALIDCALL
    Definition: type_retcode.h:51
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63