<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Shahin,<br>
<br>
I haven't run your code but I think there are two issues:<br>
1. In the commented part<br>
<div> // FILE* f=fopen("tri", "w");</div>
//SCIP_CALL(SCIPprintOrigProblem(scip,f, "lp", 0));<br>
<div><br>
there is no fclose(f), that's probably why you see no output
from this method (and the reason why you commented it out)<br>
<br>
2. It is not possible to call SCIPwriteLP() at that point in
time because after SCIP has returned from SCIPsolve() you're not
in the solving stage anymore, and the LP data structure has
already been cleared. <br>
<br>
I think you most likely want to use SCIPprintOrigProblem(). <br>
<br>
Regards,<br>
Gregor<br>
</div>
<br>
<br>
Am 01.10.2013 15:20, schrieb Shahin Gelareh:<br>
</div>
<blockquote
cite="mid:CA+r-pT55B3muA1CPJquFPZJUeNRB8BEfAOE6FanHm2ViqgWjWA@mail.gmail.com"
type="cite">
<div dir="ltr">The code is the following --very simple.<br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>I use VS2010. The same result under Ubuntu.</div>
</div>
</blockquote>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>regards,</div>
<div>Shahin</div>
<div>
<div><br>
</div>
<div><br>
</div>
<div>/**@file triKnapsack.c</div>
<div> * @brief The first example for solving a
three-constraint knapsack problem</div>
<div> * @author Shahin Gelareh</div>
<div> *</div>
<div> * This example shows how to setup and solve the
model using SCIP as callable library.</div>
<div> *</div>
<div><br>
</div>
<div>/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/</div>
<div><br>
</div>
<div>#include <stdio.h></div>
<div><br>
</div>
<div>//#include "scip/scip.h"</div>
<div>//#include "scip/scipdefplugins.h"</div>
<div>/* include SCIP components */</div>
<div>#include "objscip/objscip.h"</div>
<div>#include "objscip/objscipdefplugins.h"</div>
<div><br>
</div>
<div>#include <iostream></div>
<div>#include <sstream></div>
<div>#include <string></div>
<div>#include <vector></div>
<div>using namespace scip;</div>
<div>using namespace std;</div>
<div>
<br>
</div>
<div>string itos(int arg) //converts an integer to a
std::string</div>
<div>{</div>
<div> ostringstream buffer;</div>
<div> buffer << arg;</div>
<div> return buffer.str();</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>/** main method starting SCIP */</div>
<div>int main(</div>
<div> int argc,
/**< number of arguments from the shell */</div>
<div> char** argv
/**< array of shell arguments */</div>
<div> ) /*lint --e{715}*/</div>
<div>{</div>
<div> SCIP_RETCODE retcode;</div>
<div> SCIP* scip;<span style="white-space:pre-wrap">
</span>// create the null pointer to SCIP</div>
<div> SCIP_CALL(SCIPcreate(&scip));<span
style="white-space:pre-wrap"> </span>//
initialize the SCIP instance</div>
<div><br>
</div>
<div> SCIP_CALL(SCIPincludeDefaultPlugins(scip));<span
style="white-space:pre-wrap"> </span>// load the
default plugins</div>
<div> // create an empty problem</div>
<div> SCIP_CALL(SCIPcreateProb(scip, "triKnapsack",
NULL, NULL, NULL,</div>
<div><span style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> NULL,
NULL, NULL, NULL</div>
<div> ));</div>
<div> SCIP_CALL(SCIPsetObjsense(scip,
SCIP_OBJSENSE_MAXIMIZE));</div>
<div><br>
</div>
<div> std::vector<SCIP_VAR*> var(3);</div>
<div> for(int i = 0; i < 3; i++)</div>
<div> {</div>
<div><span style="white-space:pre-wrap"> </span>
string name = "x[" + itos(i) + "]";</div>
<div><span style="white-space:pre-wrap"> </span>
SCIP_CALL(SCIPcreateVar(scip, &var[i], (const
char*)name.c_str(), </div>
<div><span style="white-space:pre-wrap"> </span>0.0,
1.0, i+1, SCIP_VARTYPE_BINARY,</div>
<div><span style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span>TRUE, FALSE,
NULL, </div>
<div><span style="white-space:pre-wrap"> </span>NULL,
NULL, NULL, NULL));</div>
<div><span style="white-space:pre-wrap"> </span>
SCIP_CALL(SCIPaddVar(scip, var[i]));</div>
<div> }</div>
<div> std::vector<SCIP_CONS*> cons(3);</div>
<div> for(int i = 0; i < 3; i++)</div>
<div> {</div>
<div><span style="white-space:pre-wrap"> </span>
string name = "const[" + itos(i) + "]";</div>
<div><span style="white-space:pre-wrap"> </span>
SCIP_CALL(SCIPcreateConsLinear(scip, &cons[i],
(const char*)name.c_str(), 0.0, </div>
<div><span style="white-space:pre-wrap"> </span>NULL,
NULL, 0, 3+i,</div>
<div><span style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span>TRUE, TRUE,
TRUE, TRUE, TRUE,</div>
<div><span style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span>FALSE,
FALSE, FALSE, FALSE, FALSE</div>
<div><span style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span> <span
style="white-space:pre-wrap"> </span>));</div>
<div><br>
</div>
<div> }</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[0],
var[0], 2));</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[0],
var[1], 3));</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[0],
var[2], 4));</div>
<div><br>
</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[1],
var[0], 3));</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[1],
var[1], 4));</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[1],
var[2], 5));</div>
<div><br>
</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[2],
var[0], 4));</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[2],
var[1], 5));</div>
<div> SCIP_CALL(SCIPaddCoefLinear(scip, cons[2],
var[2], 6));</div>
<div> // solve</div>
<div> SCIP_CALL(SCIPsolve(scip));</div>
<div> SCIP_CALL(SCIPwriteLP(scip, "triKP"));</div>
<div> // FILE* f=fopen("tri", "w");</div>
<div> </div>
<div> //SCIP_CALL(SCIPprintOrigProblem(scip,f, "lp",
0));</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> if( SCIPgetNSols(scip) > 0 )</div>
<div> {</div>
<div><span style="white-space:pre-wrap"> </span>
SCIPinfoMessage(scip, NULL, "\nSolution:\n");</div>
<div><span style="white-space:pre-wrap"> </span>
SCIP_CALL( SCIPprintSol(scip, SCIPgetBestSol(scip),
NULL, FALSE) );</div>
<div> }</div>
<div><br>
</div>
<div> SCIP_CALL( SCIPfree(&scip) );</div>
<div><br>
</div>
<div>
return SCIP_OKAY;</div>
<div>}</div>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra">
<div>
<div class="h5"><br>
<br>
<div class="gmail_quote">On Tue, Oct 1, 2013 at 2:03
PM, Ambros Gleixner <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:gleixner@zib.de" target="_blank">gleixner@zib.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0
0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">Hello Shahin,<br>
<br>
you need to give us some more details. Can you
compile SCIP in debug mode (make OPT=dbg), run
everything in a debugger, and send us the
backtrace?<br>
<br>
Also, how and where exactly do you call
SCIPwriteLP()?<br>
<br>
Best regards,<br>
<br>
Ambros<br>
<br>
<br>
Am <a moz-do-not-send="true"
href="tel:01.10.2013%2013"
value="+33110201313" target="_blank">01.10.2013
13</a>:41, schrieb Shahin Gelareh:<br>
<blockquote class="gmail_quote" style="margin:0
0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div>
<div>
Dear SCIPers<br>
<br>
I build my model and it solves fine.<br>
I need to extract the LP model to verify
my mode.<br>
<br>
When I call it for the first time I get no
output and at the same time<br>
no error message.<br>
The next time I run the executable it
crashes :(<br>
<br>
Anything I am missing here?<br>
<br>
Best<br>
Shahin<br>
<br>
--<br>
<br>
<br>
<br>
<br>
</div>
</div>
_______________________________________________<br>
Scip mailing list<br>
<a moz-do-not-send="true"
href="mailto:Scip@zib.de" target="_blank">Scip@zib.de</a><br>
<a moz-do-not-send="true"
href="http://listserv.zib.de/mailman/listinfo/scip"
target="_blank">http://listserv.zib.de/mailman/listinfo/scip</a><br>
<br>
</blockquote>
_______________________________________________<br>
Scip mailing list<br>
<a moz-do-not-send="true"
href="mailto:Scip@zib.de" target="_blank">Scip@zib.de</a><br>
<a moz-do-not-send="true"
href="http://listserv.zib.de/mailman/listinfo/scip"
target="_blank">http://listserv.zib.de/mailman/listinfo/scip</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
</div>
</div>
<span class="HOEnZb"><font color="#888888">-- <br>
<blockquote style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div style="margin-left:40px">
<img moz-do-not-send="true"
src="http://www.lgi2a.univ-artois.fr/%7Egelareh/signature.png"><br>
</div>
</blockquote>
</font></span></div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px
solid rgb(204,204,204);padding-left:1ex">
<div style="margin-left:40px"><img moz-do-not-send="true"
src="http://www.lgi2a.univ-artois.fr/%7Egelareh/signature.png"><br>
</div>
</blockquote>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Scip mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Scip@zib.de">Scip@zib.de</a>
<a class="moz-txt-link-freetext" href="http://listserv.zib.de/mailman/listinfo/scip">http://listserv.zib.de/mailman/listinfo/scip</a>
</pre>
</blockquote>
<br>
</body>
</html>