[SCIP] SCIP 8 can read AMPL NL-file but how to write AMPL SOL-file ?

Stefan Vigerske svigerske at gams.com
Mon Mar 14 12:27:33 CET 2022


Hi,

1. Using SCIPAMPL 7 for format conversion should be fine.

2. If you want SCIP 8 for format conversion as well, then to convert the 
the SCIP solution back to a AMPL solution, you can use the patch I send 
you, start SCIP with on the original .nl file with -AMPL option, and use 
the commands "read /path/to/scip.sol quit" in the interactive shell. 
That should then write an AMPL solution file (fingers crossed).

3. With reader_nl moved into the main SCIP source, ug[SCIP,*] should be 
able to read AMPL .nl now. But it won't know that it should write an 
AMPL solution file. Somewhere a call to SCIPwriteSolutionNl(scip) would 
need to be added. Yuji should be able to tell where that should be.
Having an "AMPL-mode" for the ug[scip,*] executables, i.e., 
understanding the -AMPL flag, would surely be nice. (@Yuji:) That would 
require replicating the logic from scip/src/scipshell.c:fromAmpl() in ug 
somewhere. It's not much, it's just i) tell the SCIP solvers to read 
argv[1], ii) solve, iii) use one of the SCIP solvers to call 
SCIPwriteSolutionNl(). I'm not so familiar with the ug API that I could 
write a driver that does this with the ug lib instantaneously.

Stefan

On 3/14/22 11:09, Vladimir V. Voloshinov wrote:
> Dear Stefan,
> besides "single-threaded" SCIP/SCIPAMPL we use ParaSCIP and/or FiberSCIP.
> 
> In the previous versions parallel solvers did not read AMPL NL-files.
> So we used interactive shell of SCIPAMPL for conversion (see
> http://listserv.zib.de/pipermail/scip/2020-February/003876.html):
> 1. NL-files to CIP-files (to pass them to Para/FiberSCIP);
> 2. CIP SOL-files (from parallel solvers) to AMPL SOL-files (to read them by
> Pyomo)
>      BTW, since SCIP v7, the last conversion doesn't need patch, which was
> required for SCIP v6.
> 
> Can you, please, tell me if Para/FiberSCIP v8 support AMPL NL/SOL formats?
> 
> If not, I see two ways:
> 1) to use SCIPAMPL v7 as format converter;
> 2) to patch SCIP as you wrote in the previous email.
> BUT, besides activating interactive shell option for "AMPL mode" we'll need
> to add "write/amplsol" command to the shell.
> 
> Am I right?
> 
> Vladimir.
> 
> On Mon, Mar 14, 2022 at 11:42 AM Stefan Vigerske <svigerske at gams.com> wrote:
> 
>> Hi,
>>
>> On 3/13/22 23:41, Vladimir V. Voloshinov wrote:
>>> Sorry,
>>> when I read the Section 7.1 of "The SCIP Optimization Suite 8.0" again I
>>> understood that I did not follow your instructions.
>>> I erroneously have run SCIP by interactive shell:
>>> "SCIP> read problem.nl optimize write/solution"...
>>>
>>> The command
>>> $ scip problem.nl -AMPL
>>> gave the AMPL SOL-file as I expected.
>>>
>>> And still the question remains: is it possible to get AMPL SOL via SCIP
>>> interactive shell?
>>> I see the function SCIPwriteSolutionNl() in SCIP API (
>>> https://scipopt.org/doc/html/reader__nl_8h.php)...
>>
>> No.
>>
>> There is no shell command that would trigger SCIPwriteSolutionNl(). I
>> also think it isn't a good idea to have this in general, as we can write
>> AMPL .sol files only when the problem has been read from an AMPL .nl
>> file. If the problem was read from somewhere else, bad things could
>> happen when attempting to write an AMPL .sol file.
>>
>> I don't know (or better, I forgot) what you need the interactive shell
>> for when running from Pyomo.
>> With this change, you will get a shell when running scip problem -AMPL:
>> --- a/src/scip/scipshell.c
>> +++ b/src/scip/scipshell.c
>> @@ -192,7 +192,7 @@ SCIP_RETCODE fromAmpl(
>>       SCIPinfoMessage(scip, NULL, "\nsolve problem\n");
>>       SCIPinfoMessage(scip, NULL, "=============\n\n");
>>
>> -   SCIP_CALL( SCIPsolve(scip) );
>> +   SCIP_CALL( SCIPstartInteraction(scip) );
>>
>>       SCIP_CALL( SCIPgetBoolParam(scip, "display/statistics", &printstat) );
>>       if( printstat )
>>
>>
>> The shell would be called after the .nl file has been read. After the
>> shell is closed, SCIPwriteSolutionNl() is called. If you used the shell
>> to read a problem from a different file format in the meanwhile, things
>> may crash.
>> But I think we can bring back the -i option to switch between
>> SCIPsolve() and SCIPstartInteraction() at this point.
>>
>> Stefan
>>
>>>
>>> Yours, Vladimir.
>>>
>>> On Sun, Mar 13, 2022 at 10:36 PM Vladimir V. Voloshinov <
>>> vladimir.voloshinov at gmail.com> wrote:
>>>
>>>> Hi,
>>>> I tried SCIP-application (v8) with some AMPL NL-file as input problem
>>>> data. It was accepted, the problem has been solved.
>>>> But the command "write/solution" wrote the solution in CIP-format !
>>>> Is it possible to get the solution in AMPL SOL-format ? (We use Python
>>>> Pyomo package to write NL-files and read solutions in AMPL SOL-formats)
>>>> I can not find the "write/amplsol" command in SCIP v8 (as it was in
>>>> SCIPAMPL application in previous versions)...
>>>>
>>>> Sincerely yours,
>>>> Vladimir
>>>>
>>>
>>>
>>> _______________________________________________
>>> Scip mailing list
>>> Scip at zib.de
>>> https://listserv.zib.de/mailman/listinfo/scip
>>
>>
> 



More information about the Scip mailing list