[SCIP] MPS Read and Write and Structure Detection
"Büsing, Henrik"
h.buesing at fz-juelich.de
Mon Jun 17 11:01:50 CEST 2019
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
----------------------------------------------------------------------------
---------
----------------------------------------------------------------------------
---------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.zib.de/pipermail/scip/attachments/20190617/b2046fba/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 7628 bytes
Desc: not available
URL: <http://listserv.zib.de/pipermail/scip/attachments/20190617/b2046fba/attachment.p7s>
More information about the Scip
mailing list