SAT parameter spec

328 views
Skip to first unread message

Michael Powell

unread,
Oct 27, 2018, 12:53:46 PM10/27/18
to or-tools...@googlegroups.com
Hello,

Is there a spec for the parameters? Their names, how to specify one (or more)?

i.e. the C# example:

// Adds a time limit. Parameters are stored as strings in the solver.
solver.StringParameters = "max_time_in_seconds:10.0";

Thanks!

Michael Powell

Laurent Perron

unread,
Oct 28, 2018, 1:33:16 AM10/28/18
to or-tools...@googlegroups.com
They are protobufs. See sat_parameters.proto


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Powell

unread,
Oct 29, 2018, 8:38:45 AM10/29/18
to or-tools-discuss


On Sunday, October 28, 2018 at 1:33:16 AM UTC-4, Laurent Perron wrote:
They are protobufs. See sat_parameters.proto

I'm not finding much of a reference to that. Would you be more specific please?


I found this code:


What there seems to be currently is a StringParameters C# property with get/set capability. What I'm looking for is either the API or the string format.

Thank you!

Michael

Frederic Didier

unread,
Oct 29, 2018, 9:02:48 AM10/29/18
to or-tools...@googlegroups.com
On Mon, Oct 29, 2018 at 1:38 PM Michael Powell <mwpow...@gmail.com> wrote:


On Sunday, October 28, 2018 at 1:33:16 AM UTC-4, Laurent Perron wrote:
They are protobufs. See sat_parameters.proto

I'm not finding much of a reference to that. Would you be more specific please?


I found this code:


Yes, this is the reference:


The string format is the normal protocol buffer text format (https://developers.google.com/protocol-buffers/docs/overview) and is like JSON.
You can either create a protocol buffer object in C# (https://developers.google.com/protocol-buffers/docs/csharptutorial) and then call ToString() or create the string directly.

The format is like JSON:
ex: "max_time_in_seconds:10.0,cp_model_presolve:true" etc...
The name/type are in the sat_parameters file.

Michael Powell

unread,
Oct 29, 2018, 9:23:09 AM10/29/18
to or-tools...@googlegroups.com
On Mon, Oct 29, 2018 at 9:02 AM 'Frederic Didier' via or-tools-discuss
<or-tools...@googlegroups.com> wrote:
>
>
>
> On Mon, Oct 29, 2018 at 1:38 PM Michael Powell <mwpow...@gmail.com> wrote:
>>
>>
>>
>> On Sunday, October 28, 2018 at 1:33:16 AM UTC-4, Laurent Perron wrote:
>>>
>>> They are protobufs. See sat_parameters.proto
>>
>>
>> I'm not finding much of a reference to that. Would you be more specific please?
>>
>> http://developers.google.com/s/results/?q=sat_parameters
>>
>> I found this code:
>>
>> http://github.com/google/or-tools/blob/master/ortools/sat/sat_parameters.proto
>
>
> Yes, this is the reference:
>
> http://github.com/google/or-tools/blob/master/ortools/sat/sat_parameters.proto
>
> The string format is the normal protocol buffer text format (https://developers.google.com/protocol-buffers/docs/overview) and is like JSON.
> You can either create a protocol buffer object in C# (https://developers.google.com/protocol-buffers/docs/csharptutorial) and then call ToString() or create the string directly.
>
> The format is like JSON:
> ex: "max_time_in_seconds:10.0,cp_model_presolve:true" etc...
> The name/type are in the sat_parameters file.

I am seeing *Proto classes exposed in the C# Sat API. Would it make
sense to also expose the Sat Parameters Proto along the same lines?

Committing the condition "like JSON" to "JSON" would be good, too;
that would permit usage of assemblies such Newtonsoft.Json.

>> What there seems to be currently is a StringParameters C# property with get/set capability. What I'm looking for is either the API or the string format.
>>
>> Thank you!
>>
>> Michael
>>
>>> Le sam. 27 oct. 2018 à 19:53, Michael Powell <mwpow...@gmail.com> a écrit :
>>>>
>>>> Hello,
>>>>
>>>> Is there a spec for the parameters? Their names, how to specify one (or more)?
>>>>
>>>> i.e. the C# example:
>>>>
>>>> // Adds a time limit. Parameters are stored as strings in the solver.
>>>> solver.StringParameters = "max_time_in_seconds:10.0";
>>>>
>>>> Thanks!
>>>>
>>>> Michael Powell
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/9HcB0rHS8-U/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to or-tools-discu...@googlegroups.com.

Laurent Perron

unread,
Oct 31, 2018, 2:21:56 AM10/31/18
to or-tools...@googlegroups.com
No, sat parameters are proto 2, which are not supported in C#.

We stick to proto2 for the time being, as proto3 do not support default value, which are nice for parameters. 

Therefore we pass parameters by string in the C# CpSolver class.

Michael Powell

unread,
Oct 31, 2018, 4:05:21 PM10/31/18
to or-tools...@googlegroups.com
On Wed, Oct 31, 2018 at 2:21 AM 'Laurent Perron' via or-tools-discuss
<or-tools...@googlegroups.com> wrote:
>
> No, sat parameters are proto 2, which are not supported in C#.
>
> We stick to proto2 for the time being, as proto3 do not support default value, which are nice for parameters.

Re: default values, absolutely. I'm not that fluent with proto2/proto3
(yet), but that seems like a key feature. Not sure why it would have
been dropped?

At any rate, no worries.

> Therefore we pass parameters by string in the C# CpSolver class.

I'm looking at ways to parse the .proto and transform it into adapter
level boilerplate code generation to help make that a more language
friendly experience than naked "parameter strings".

Cheers,

Michael

Laurent Perron

unread,
Nov 5, 2018, 4:06:18 PM11/5/18
to or-tools...@googlegroups.com
Once again, 

MIP solvers checks solutions with an epsilon on each variable.

Thus

 value >= m - M * (1 - indicator)

is actually 

value >= 1 - 10000000(1 - indicator)

so imagine indicator is 1 - epsilon

this translate to value >= 1 - 10000000 * epsilon.

In practise, epsilon <= 1e-4 to 1e-6

This is perfectly valid.

Furthermore, we have additional code that checks all solutions against the constraint of the model with this epsilon tolerance.
So, even if I do not trust CBC, I do trust the checker code.

To conclude, this is working as intended w.r.t MIP solvers.

If you want exact arithmetic, you need to use only integer variables, and the CP-SAT solver.

--Laurent
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


Laurent Perron

unread,
Nov 5, 2018, 4:06:45 PM11/5/18
to or-tools...@googlegroups.com
Sorry, wrong thread :-)

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


Michael Powell

unread,
Nov 5, 2018, 4:30:15 PM11/5/18
to or-tools...@googlegroups.com
On Mon, Nov 5, 2018 at 4:06 PM 'Laurent Perron' via or-tools-discuss
<or-tools...@googlegroups.com> wrote:
>
> Sorry, wrong thread :-)

No worries. Actually, I was just going to wonder at the profundity of
the response... ;-)
Reply all
Reply to author
Forward
0 new messages