<div dir="ltr">Dear Naga and SCIP menbers,<div><br></div><div>I am thankful for the help.</div><div>I have tried FILE* fp, and VS 2019 forced me to use fopen_s, then SCIPprintSol() accepted the fp.</div><div>However, an Exception Unhandled occurs. </div><div>The screen picture is attached.</div><div><br></div><div>Actually, I need to print my problem and solution into a file to check details, no matter using SCIP_FILE* or FILE*.</div><div>The file is also needed for further applications.</div><div>cmd screen cannot satisfy the needs.</div><div><br></div><div>Many thanks for your help.</div><div>Look forward to further response from you or SCIP menbers.<br></div><div><br></div><div>Sincerely,</div><div><div><br></div></div><div>Melvin Shih</div><div><br></div><div><div><img src="cid:ii_kf27prv22" alt="16.png" width="472" height="296"><br></div></div><div><div class="gmail-tw-src-ltr" id="gmail-tw-ob" style="display:flex;min-height:140px;font-family:arial,sans-serif;font-size:14px"><div class="gmail-oSioSc" style="width:0px;display:flex"><div id="gmail-tw-target" style="font-size:0px;text-align:initial;background-color:rgb(248,249,250);min-width:0px;width:0px;display:flex"><div id="gmail-kAz1tf" class="gmail-g9WsWb" style="margin:0px;text-align:initial;padding:10px 16px 52px"><div class="gmail-iYB33c" style="display:flex;width:309px;height:48px"><div class="gmail-tw-menu" id="gmail-tw-tmenu" style="display:inline-block;line-height:normal;white-space:nowrap"><span class="gmail-tw-menu-btn gmail-hide-focus-ring" id="gmail-tw-spkr-button" tabindex="0" style="display:inline-block;height:48px;color:rgba(0,0,0,0.54);overflow:hidden;width:48px;outline:0px"><span class="gmail-tw-menu-btn-image gmail-z1asCe gmail-JKu1je" title="聆聽" style="display:inline-block;height:26px;line-height:24px;width:26px;border:1px solid transparent;padding:10px"></span><div><br></div></span></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Naga Venkata Chaitanya Gudapati - <a href="mailto:nagavenkata.gudapati@studio.unibo.it">nagavenkata.gudapati@studio.unibo.it</a> <<a href="mailto:nagavenkata.gudapati@studio.unibo.it">nagavenkata.gudapati@studio.unibo.it</a>> 於 2020年9月14日 週一 下午3:14寫道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Looks like I jumped the gun a little and just saw your full email and the attempt at trying to print the solution to a file. I am not sure about the inner workings of SCIP_FILE * but a normal C-style FILE * seems to be working okay.<br>
<br>
________________________________________<br>
From: Scip <<a href="mailto:scip-bounces@zib.de" target="_blank">scip-bounces@zib.de</a>> on behalf of Naga Venkata Chaitanya Gudapati - <a href="mailto:nagavenkata.gudapati@studio.unibo.it" target="_blank">nagavenkata.gudapati@studio.unibo.it</a> <<a href="mailto:nagavenkata.gudapati@studio.unibo.it" target="_blank">nagavenkata.gudapati@studio.unibo.it</a>><br>
Sent: Monday, September 14, 2020 7:56 AM<br>
To: Melvin Shih; <a href="mailto:scip@zib.de" target="_blank">scip@zib.de</a><br>
Subject: Re: [SCIP] how can I output my best solution using SCIPgetBestSol() to a file?<br>
<br>
Hi!<br>
<br>
If I understood your question correctly,<br>
<br>
You need to use<br>
<br>
SCIP_RETCODE SCIPprintSol(SCIP * scip, SCIP_SOL * sol, FILE * file, SCIP_Bool printzeros ) ;<br>
<br>
In c++, if you just want to print the solution to the console with all the 0 variable printed too, you can use:<br>
SCIP_SOL* sol = nullptr;<br>
sol = SCIPgetBestSol(scip);<br>
SCIP_CALL(SCIPprintSol (scip, sol, nullptr, 1));<br>
<br>
If you want to write to a file with 0s,<br>
SCIP_SOL* sol = nullptr;<br>
sol = SCIPgetBestSol(scip);<br>
FILE *fp;<br>
fp = fopen("MYSOL.TXT", "w+");<br>
SCIP_CALL(SCIPprintSol (scip, sol, fp, 1));<br>
fclose(fp);<br>
<br>
I also have a Minimum Working Example if you need. I hope this is what you are looking for. I hope other SCIP members will chime in if I am wrong.<br>
<br>
Regards,<br>
Naga<br>
<br>
<br>
<br>
________________________________________<br>
From: Scip <<a href="mailto:scip-bounces@zib.de" target="_blank">scip-bounces@zib.de</a>> on behalf of Melvin Shih <<a href="mailto:melvinshih@gmail.com" target="_blank">melvinshih@gmail.com</a>><br>
Sent: Sunday, September 13, 2020 8:09 PM<br>
To: <a href="mailto:scip@zib.de" target="_blank">scip@zib.de</a><br>
Subject: [SCIP] how can I output my best solution using SCIPgetBestSol() to a file?<br>
<br>
Dear SCIP members,<br>
<br>
I have tried functions of fstream and SCIP_FILE to open a file for SCIPgetBestSol(), and they do not work.<br>
Is there any example to define a file for SCIPgetBestSol() or is there another way to do so using C++?<br>
<br>
Sincerely,<br>
<br>
Melvin shih<br>
<br>
<br>
Here are my codes:<br>
.............<br>
// fstream file;<br>
// file.open("Reader.txt", ios::out | ios::trunc); //not work<br>
<br>
SCIP_FILE* schedulingfile;<br>
char filename[255];<br>
(void)SCIPsnprintf(filename, 255, "Sintex.txt");<br>
schedulingfile = SCIPfopen(filename, "r");<br>
if (schedulingfile == NULL)<br>
{<br>
SCIPerrorMessage("cannot open file <%s> for reading\n", filename);<br>
SCIPprintSysError(filename);<br>
return SCIP_NOFILE;<br>
}<br>
if (SCIPgetNSols(scip) > 0)<br>
{<br>
SCIPinfoMessage(scip, NULL, "\nSolution:\n");<br>
SCIP_CALL(SCIPprintSol(scip, SCIPgetBestSol(scip), schedulingfile, FALSE)); //SCIP_FILE is not accepted<br>
}<br>
SCIPfclose(schedulingfile);<br>
..........<br>
<br>
<br>
_______________________________________________<br>
Scip mailing list<br>
<a href="mailto:Scip@zib.de" target="_blank">Scip@zib.de</a><br>
<a href="https://listserv.zib.de/mailman/listinfo/scip" rel="noreferrer" target="_blank">https://listserv.zib.de/mailman/listinfo/scip</a><br>
</blockquote></div>