[Cmpl] Time-out and objective questions

Michel Iwaniec michel.iwaniec at gmail.com
Thu Jun 17 18:33:16 EDT 2021


Hi,

I have a few questions regarding CMPL, which are sort-of-related, as they
both relate to trying to stop CMPL / CBC solving sooner using either a
time-out value or tweaking the objective.

First a bit of background: My GPL project that uses CMPL + CBC is an
image-to -background+sprites converter for the 8-bit NES / Famicom console:
https://github.com/michel-iwaniec/OverlayPal

At the moment I've just been invoking CMPL as a sub-process from my own
program, although I do plan to build CMPL from source to integrate it more
properly at some point in the future.

I've been really impressed with CMPL's neat mathematical language, and
especially the support for variable products.
I previously used PuLP in Python where I kept introducing "big-M-logic",
and my code got very difficult to maintain as the model grew in complexity.
CMPL's variable-product-feature really got things cleaned up again.

Anyway, on to the questions/issues I'm having:

*** Question#1 ***

My program has a need for a variable timeout that can be set from the GUI.
However, while the CMPL language file allows setting a fixed timeout using
a parameter "%opt cbc seconds 123" I have not found any way to set this
from the command-line when executing cmpl(.exe). Nor have I been able to
specify it in my data file included using the "%data" directive.

So my current work-around is to just create another copy of my .cmpl
program file that has the "%opt cbc seconds 123" parameter line prepended
to it, and run this program instead. It works but is an extra step I'd
rather avoid if I could.

So is setting the timeout using command-line parameters / data files not
supported, or have I just missed something obvious here?

*** Question#2 ***

Secondly, I'd also like to support a mode where *any* valid solution is
accepted by CMPL, to avoid spending too much time on refining a valid
solution. i.e., this mode should accept the first valid solution and only
use the timeout where finding a solution / deciding the problem is
unsolvable takes too long to be acceptable.

When I used PuLP + CBC, this was easy enough to do by just leaving out the
objective of the optimization problem entirely.

But the same trick didn't seem to work with CMPL. If I try to remove the
"objective" section I get an error from cmpl(.exe) saying "Error
(interfaces): No objective function found.".

Is there some existing way to achieve this which I haven't thought of?

*** Question#3 ***

Kind of a follow-up to Q#2. Another "mode" that might be useful in my case
is to combine both of these features, by having the ability to set a
timeout that is ignored until at least one valid solution is found.
i.e., the intended behavior is that my program should at least keep running
until a valid solution has been found, in order to produce a valid result
for the user... but it should not spend any more time finding a better
solution if the provided time budget has already been exhausted.

I'm already assuming this sort of configurability is probably a bit too
specific to support using either the existing command-line parameters or
language directives. But I was wondering if there might be some relatively
easy way to do it using CMPL's internal C++ API?

Thanks again for making such a useful open-source tool! :)

// Michel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20210617/61247dd5/attachment.html>


More information about the Cmpl mailing list