Random labeling options for CLPFD

From: <lausgans_at_gmail.com>
Date: Tue, 3 Nov 2015 17:54:05 +0300

Hello, Michael.

SWI-Prolog has random_variable(Seed) option which labels variables with random integer values. Unfortunately it is undocumented, but is present in swipl code: https://github.com/SWI-Prolog/swipl-devel/blob/master/library/clp/clpfd.pl and it was also mentioned in some places, for example: https://groups.google.com/forum/#!topic/swi-prolog/BS4EuWwsYpk

I've quickly modified PAKCS like this:

--- curry2prolog/lib_src/prim_clpfd.pl.orig 2015-11-03 17:15:01.000000000 +0300
+++ curry2prolog/lib_src/prim_clpfd.pl 2015-11-03 17:15:22.000000000 +0300
_at_@ -63,6 +63,7 @@ translateLabelingOption('CLPFD.All',all)
 translateLabelingOption('CLPFD.Minimize'(DomVar),minimize(DomVar)) :- sicsLabel.
 translateLabelingOption('CLPFD.Maximize'(DomVar),maximize(DomVar)) :- sicsLabel.
 translateLabelingOption('CLPFD.Assumptions'(Var),assumptions(Var)) :- sicsLabel.
+translateLabelingOption('CLPFD.RandomVariable'(Seed),random_variable(Seed)).

 sicsLabel :- checkSICStusAndWarn('CLPFD.labeling: labeling options').
--- lib/CLPFD.curry.orig 2015-11-03 17:16:46.000000000 +0300
+++ lib/CLPFD.curry 2015-11-03 17:17:10.000000000 +0300
_at_@ -314,6 +314,7 @@ data LabelingOption = LeftMost
                     | Minimize Int
                     | Maximize Int
                     | Assumptions Int
+ | RandomVariable Int

Seems to work correctly in simple test program. (Not yet tried a new CLP.FD library)
Any chance to see it added to PAKCS? Don't know whether SICStus provides something like this, an error should be generated in case if not.

BTW, same for random_value(Seed) labeling option which defines random domain exploration.

Thank you!
Alex
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry

Received on Mi Nov 04 2015 - 16:48:55 CET

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:13 CEST