Re: [eclipse-clp-users] On stating a strange constraint

From: Hakan Kjellerstrand <hakank_at_...6...>
Date: Mon, 27 Mar 2023 12:08:28 +0200
There is a global constraint called value_precede_chain (
https://sofdem.github.io/gccat/gccat/Cint_value_precede_chain.html) which
seems to be what you want. It ensures that the first occurrence of the
value I must be placed in the array before any values > I.

I don't have any ECLiPSe CLP code for this, but there's an MiniZinc code
here:
https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/fzn_value_precede_chain_int.mzn
. And I've ported the MiniZinc code to Picat:
http://hakank.org/picat/value_precede_chain.pi .

Hope this helps.

Best,

Hakan

On Mon, Mar 27, 2023 at 11:59 AM Panagiotis Stamatopoulos <takis_at_...263....90...>
wrote:

> Hi Marco,
>
> Yes, you are right. The ultimate purpose of this constraint is
> symmetry breaking. I 'll try what you suggest. Thanks!
>
> Regards,
> Panagiotis
>
> On 27-Mar-23 12:51 PM, Marco Gavanelli wrote:
> > Hi Panagiotis,
> >
> > this constraint reminds me of a symmetry breaking labeling proposed by
> > Pedro Meseguer.
> >
> > Anyway, what about:
> >
> > L[0] = 1
> >
> > forall i>0
> >      L[i] <= maxlist(L[0..(i-1)]) + 1
> > ?
> >
> > I hope the intuition is clear, with L[0..(1-i)] I mean the sublist of
> > the first i elements of the list L.
> >
> > Best,
> > Marco
> >
> >
> > On 27/03/2023 11:34, Panagiotis Stamatopoulos wrote:
> >> Hello Everybody,
> >>
> >> I am seeking ideas on how to implement in ECLiPSe a specific
> >> constraint in a simple, if possible, and efficient way.
> >>
> >> Let L be a list of length N with domain variables ranging
> >> in 1..M. Acceptable lists are the ones that ...
> >> 1. ... contain values from 1 up to K (K =< M), but not any
> >> values from K+1 up to M (K is not given).
> >> 2. ... satisfy the condition that the first occurrences of
> >> the values from 1 to K appear in this order in the list.
> >>
> >> For example, let N = 8 and M = 5. The lists [1,1,2,1,2,3,2,1]
> >> and [1,2,1,3,2,4,3,1] are valid. The first one has K = 3 (only
> >> items 1, 2, 3 appear in the list) and the second one has K = 4
> >> (just 5 is missing from the list). In the first list, the first
> >> occurrences of 1, 2, 3 are in positions 1, 3, 6 and in the second
> >> list, the first occurrences of 1, 2, 3, 4 are in positions 1, 2,
> >> 4, 6 in the lists. All fine!
> >>
> >> I believe that the requirement 1 above could be implemented
> >> easily with the occurrences constraint (one for each number in
> >> 1..M) and a set of implication (=>) constraints, stating that
> >> if the number of occurrences of x in 1..M is 0, then the numbers
> >> of occurrences of x+1, x+2, ... in the list should also be 0.
> >> I cannot predict the propagation level of this approach, but
> >> it seems that, at least, declaratively can be stated.
> >>
> >> I don't have any good ideas for the requirement 2. I tried
> >> something that exploits again the occurrences constraint (for
> >> every number in 1..M and every prefix list of the given list)
> >> and then the lex_le constraint. It worked, but if N is around
> >> 50 or more, the efficiency is unacceptable.
> >>
> >> Any ideas on the above would be more than welcome.
> >>
> >> Best Regards,
> >> Panagiotis
> >>
> >>
> >> _______________________________________________
> >> ECLiPSe-CLP-Users mailing list
> >> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
> >
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>


-- 
Hakan Kjellerstrand
http://www.hakank.org/
http://www.hakank.org/webblogg/
http://www.hakank.org/constraint_programming_blog/
http://twitter.com/hakankj
https://www.facebook.com/hakankj
Received on Mon Mar 27 2023 - 10:08:50 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST