[SCIP] MPS Read and Write and Structure Detection

Gregor Hendel hendel at zib.de
Mon Jun 17 12:43:50 CEST 2019


Hi Henrik,

the queens example (introd)uses a data structure "QueensSolver" that 
stores variables in a 2D array, which is a very intuitive representation 
of an n-by-n checkers board. Make sure you read the comments when you 
start working with an example (queens.hpp):

       /** @brief one binary variable for each field (i,j) on the chess bord
        *
        * To access variable information (objective value, bounds,
        * etc.) use the SCIP_VAR * pointer. Since we want to know the
        * value of each variable in the solution, we have to store
        * these pointers.
        */
       std::vector<std::vector<SCIP_VAR *> > _vars;


The result of SCIPgetVars() is a 1D-Array, which you should indeed 
**not** access by a 2D-index.

Regarding your question about detection: The mps-format does not 
preserve decomposition label information. A detected arrowhead structure 
will be lost. SCIP in its current version does not support reading 
decompositions.
It would be good if you could elaborate a little bit more on what you 
are trying to achieve, so that the SCIP and GCG team can give you a 
better suggestion how to pursue that.

Cheers,
Gregor



Am 17.06.19 um 11:01 schrieb "Büsing, Henrik":
>
> Dear SCIP users,
>
> I would like to read in an MPS-file, detect a possible arrowhead 
> structure via dec_hcgpartition.cpp and then write the MPS-file with 
> the new structure. I was able to read in an MPS-file and solve it, but 
> I get a segmentation fault while writing the MPS-file (see [2] for the 
> code). When running in debugger I get error [1].
>
> Could you point out what I am doing wrong while trying to write the 
> MPS-file?
> Additionally, why is vars two-dimensional? Should this not be just a 
> long array with all the variables in it? How do I print the solution 
> in a correct way? A nested loop over i and j does not honor the sparse 
> structure of the constraint matrix A.
>
> Finally, is there an example on how to use the structure detection of 
> GCG?
>
> Thank you very much for your help!
>
> Best,
> Henrik
>
> [1]
>
> Program received signal SIGSEGV, Segmentation fault.
>
> SCIPreaderGetData (reader=reader at entry=0x0)
>
>     at /home/henrik/Code/scipoptsuite-6.0.1/scip/src/scip/reader.c:488
>
> 488            return reader->readerdata;
>
> [2]
>
> // Derived from Queens example by Cornelius Schwarz
>
> #include <scip/scip.h>
>
> #include <scip/scipdefplugins.h>
>
> #include "scip_exception.hpp"
>
> #include <iostream>
>
> using namespace std;
>
> /** main function **/
>
> int
>
> main()
>
> {
>
>    // Define scip pointer and filename
>
>    SCIP* scip;
>
>    SCIP_READER* reader;
>
>    const char* filename="/home/henrik/JSC/FINE_exampleMpsFiles/toy.MPS";
>
>    cout << filename  << endl;
>
>    SCIP_RESULT* result;
>
>    result = new SCIP_RESULT[3];
>
>    // Create scip environment
>
> SCIP_CALL_EXC(SCIPcreate(& scip));
>
>    // Load desired plugins
>
> SCIP_CALL_EXC(SCIPincludeDefaultPlugins(scip));
>
>    // disable scip output to stdout
>
> SCIPmessagehdlrSetQuiet(SCIPgetMessagehdlr(scip), TRUE);
>
>    // Read in *.MPS file
>
>    SCIPreadMps(scip, reader, filename, result,
>
> NULL,NULL,
>
>                 NULL,NULL,
>
>                NULL,NULL
>
> );
>
>    // Solve
>
> SCIP_CALL_EXC(SCIPsolve(scip));
>
>    // Display solution
>
>    SCIP_VAR** vars;
>
>    vars  = SCIPgetVars(scip);
>
>    SCIP_SOL* sol;
>
>    sol = SCIPgetBestSol(scip);
>
>    for (int i=0; i<3; ++i)
>
>      for (int j=0; j<3; ++j)
>
>    {
>
>      cout << "Solution: " << SCIPgetSolVal(scip, sol, &vars[i][j]) << 
> endl;
>
>    }
>
>    int nvars = SCIPgetNVars(scip);
>
>    int nbinvars = SCIPgetNBinVars(scip);
>
>    int nintvars = SCIPgetNIntVars(scip);
>
>    int nimplvars = SCIPgetNImplVars(scip);
>
>    int ncontvars = SCIPgetNContVars(scip);
>
>    SCIP_Real objscale = 1.0;
>
>    SCIP_Real objoffset = 0.0;
>
>    SCIP_VAR** fixedvars = SCIPgetFixedVars(scip);
>
>    int nfixedvars = SCIPgetNFixedVars(scip);
>
>    SCIP_CONS** conss = SCIPgetConss(scip);
>
>    int nconss = SCIPgetNConss(scip);
>
>    const char* name="Toy";
>
>    SCIPwriteMps(scip, reader, NULL, name, FALSE, SCIP_OBJSENSE_MINIMIZE,
>
> objscale, objoffset, vars, nvars, nbinvars, nintvars,
>
> nimplvars, ncontvars, fixedvars, nfixedvars, conss,
>
> nconss, result
>
>                 );
>
>    return EXIT_SUCCESS;
>
> }
>
> -- 
>
> Dipl.-Math. Henrik Büsing
>
> Jülich Supercomputing Centre
>
> Institute for Advanced Simulation
>
> Forschungszentrum Jülich
>
> Wilhelm-Johnen-Straße
>
> 52425 Jülich, Germany
>
> Phone: +49-2461-61-9884
>
> Fax: +49-2461-61-6656
>
> E-Mail: H.Buesing at fz-juelich.de
>
> WWW: http://www.fz-juelich.de/ias/jsc
>
> -------------------------------------------------------------------------------------
>
> -------------------------------------------------------------------------------------
>
> Forschungszentrum Juelich GmbH
>
> 52425 Juelich
>
> Sitz der Gesellschaft: Juelich
>
> Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
>
> Vorsitzender des Aufsichtsrats: MinDir Volker Rieke
>
> Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),
>
> Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
>
> Prof. Dr. Sebastian M. Schmidt
>
> -------------------------------------------------------------------------------------
>
> -------------------------------------------------------------------------------------
>
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> https://listserv.zib.de/mailman/listinfo/scip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.zib.de/pipermail/scip/attachments/20190617/d4276dfd/attachment.html>


More information about the Scip mailing list