Scippy

    SCIP

    Solving Constraint Integer Programs

    cmain.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-2025 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 GMI/src/cmain.c
    26 * @brief main file for GMI cut example
    27 * @author Marc Pfetsch
    28 */
    29
    30/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    31
    32#include <scip/scip.h>
    33#include <scip/scipdefplugins.h>
    34#include "sepa_gmi.h"
    35
    36/** reads parameters */
    37static
    39 SCIP* scip, /**< SCIP data structure */
    40 const char* filename /**< parameter file name, or NULL */
    41 )
    42{
    43 if ( filename != NULL )
    44 {
    45 if ( SCIPfileExists(filename) )
    46 {
    47 SCIPinfoMessage(scip, NULL, "reading parameter file <%s> ...\n", filename);
    48 SCIP_CALL( SCIPreadParams(scip, filename) );
    49 }
    50 else
    51 SCIPinfoMessage(scip, NULL, "parameter file <%s> not found - using default parameters.\n", filename);
    52 }
    53 else if ( SCIPfileExists("scipgmi.set") )
    54 {
    55 SCIPinfoMessage(scip, NULL, "reading parameter file <scipgmi.set> ...\n");
    56 SCIP_CALL( SCIPreadParams(scip, "scipgmi.set") );
    57 }
    58
    59 return SCIP_OKAY;
    60}
    61
    62/** starts SCIP */
    63static
    65 SCIP* scip, /**< SCIP data structure */
    66 const char* filename /**< input file name */
    67 )
    68{
    69 /********************
    70 * Problem Creation *
    71 ********************/
    72
    73 SCIPinfoMessage(scip, NULL, "read problem <%s> ...\n\n", filename);
    74 SCIP_CALL( SCIPreadProb(scip, filename, NULL) );
    75
    76 /*******************
    77 * Problem Solving *
    78 *******************/
    79
    80 /* solve problem */
    81 SCIPinfoMessage(scip, NULL, "solve problem ...\n\n");
    83
    84 SCIPinfoMessage(scip, NULL, "primal solution:\n");
    86
    87 /**************
    88 * Statistics *
    89 **************/
    90
    91 SCIPinfoMessage(scip, NULL, "Statistics:\n");
    93
    94 return SCIP_OKAY;
    95}
    96
    97/** starts user interactive mode */
    98static
    100 SCIP* scip /**< SCIP data structure */
    101 )
    102{
    104
    105 return SCIP_OKAY;
    106}
    107
    108/** creates a SCIP instance with default plugins, evaluates command line parameters, runs SCIP appropriately,
    109 * and frees the SCIP instance
    110 */
    111static
    113 int argc, /**< number of shell parameters */
    114 char** argv /**< array with shell parameters */
    115 )
    116{
    117 SCIP* scip = NULL;
    118
    119 /*********
    120 * Setup *
    121 *********/
    122
    123 /* initialize SCIP */
    125
    126 /* we explicitly enable the use of a debug solution for this main SCIP instance */
    128
    129 /***********************
    130 * Version information *
    131 ***********************/
    132
    134 SCIPinfoMessage(scip, NULL, "\n");
    135
    136 /* include default SCIP plugins */
    138
    139 /* include GMI cut separator */
    141
    142 /**************
    143 * Parameters *
    144 **************/
    145
    146 if ( argc >= 3 )
    147 {
    148 SCIP_CALL( readParams(scip, argv[2]) );
    149 }
    150 else
    151 {
    153 }
    154
    155 /**************
    156 * Start SCIP *
    157 **************/
    158
    159 if ( argc >= 2 )
    160 {
    161 SCIP_CALL( fromCommandLine(scip, argv[1]) );
    162 }
    163 else
    164 {
    165 SCIPinfoMessage(scip, NULL, "\n");
    166
    168 }
    169
    170 /********************
    171 * Deinitialization *
    172 ********************/
    173
    175
    177
    178 return SCIP_OKAY;
    179}
    180
    181/** main method starting SCIP */
    183 int argc, /**< number of arguments from the shell */
    184 char** argv /**< array of shell arguments */
    185 )
    186{
    187 SCIP_RETCODE retcode;
    188
    189 retcode = runSCIP(argc, argv);
    190 if ( retcode != SCIP_OKAY )
    191 {
    192 SCIPprintError(retcode);
    193 return -1;
    194 }
    195
    196 return 0;
    197}
    int main(int argc, char **argv)
    Definition: cmain.c:111
    #define NULL
    Definition: def.h:248
    #define FALSE
    Definition: def.h:94
    #define SCIP_CALL(x)
    Definition: def.h:355
    static SCIP_RETCODE interactive(SCIP *scip)
    Definition: cmain.c:99
    static SCIP_RETCODE runSCIP(int argc, char **argv)
    Definition: cmain.c:112
    static SCIP_RETCODE fromCommandLine(SCIP *scip, const char *filename)
    Definition: cmain.c:64
    static SCIP_RETCODE readParams(SCIP *scip, const char *filename)
    Definition: cmain.c:38
    void SCIPenableDebugSol(SCIP *scip)
    Definition: scip_debug.c:58
    SCIP_Bool SCIPfileExists(const char *filename)
    Definition: misc.c:11057
    SCIP_RETCODE SCIPfree(SCIP **scip)
    Definition: scip_general.c:402
    SCIP_RETCODE SCIPcreate(SCIP **scip)
    Definition: scip_general.c:370
    SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
    Definition: scip_prob.c:341
    void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
    Definition: scip_message.c:208
    void SCIPprintError(SCIP_RETCODE retcode)
    Definition: scip_general.c:231
    void SCIPprintVersion(SCIP *scip, FILE *file)
    Definition: scip_general.c:169
    SCIP_RETCODE SCIPreadParams(SCIP *scip, const char *filename)
    Definition: scip_param.c:772
    SCIP_RETCODE SCIPstartInteraction(SCIP *scip)
    Definition: scip_dialog.c:242
    SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
    Definition: scip_sol.c:3047
    SCIP_RETCODE SCIPsolve(SCIP *scip)
    Definition: scip_solve.c:2635
    SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
    #define BMScheckEmptyMemory()
    Definition: memory.h:155
    SCIP callable library.
    SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
    default SCIP plugins
    SCIP_RETCODE SCIPincludeSepaGMI(SCIP *scip)
    Definition: sepa_gmi.c:824
    Gomory Mixed-Integer Cuts.
    @ SCIP_OKAY
    Definition: type_retcode.h:42
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63