ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 06 Jan 2021 02:54:45 +0100Not getting correct output while computing posets with some conditions.https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/I want to compute finite posets on 6 elements. Also, I want the following conditions on the posets: 2 covers 0, 4 covers 2, 3 covers 1, 5 covers 3. Also, 0, 1 are incomparable and 4, 5 are incomparable. For that I am giving the following commands:
A=[]
P = Posets(6)
for p in P:
if p.covers(0, 2) and p.covers(2, 4) and p.covers(1, 3) and p.covers(3, 5) and p.compare_elements(1, 0) is None and p.compare_elements(4, 5) is None:
A.append(p);
print(A)
The output I am getting is not correct. There is only one element in sage output but that is not true. Is there any issue with my code?
Thu, 26 Nov 2020 06:42:33 +0100https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/Comment by fidbc for <p>I want to compute finite posets on 6 elements. Also, I want the following conditions on the posets: 2 covers 0, 4 covers 2, 3 covers 1, 5 covers 3. Also, 0, 1 are incomparable and 4, 5 are incomparable. For that I am giving the following commands: </p>
<pre><code>A=[]
P = Posets(6)
for p in P:
if p.covers(0, 2) and p.covers(2, 4) and p.covers(1, 3) and p.covers(3, 5) and p.compare_elements(1, 0) is None and p.compare_elements(4, 5) is None:
A.append(p);
print(A)
</code></pre>
<p>The output I am getting is not correct. There is only one element in sage output but that is not true. Is there any issue with my code?</p>
https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/?comment=54397#post-id-54397My impression is that the assumption on the element labels may be causing the unexpected result. That is, `P` is a list of non-isomorphic posets on 6 elements. So for each poset it contains only one possible labeling.
Perhaps iterating over all possible element labelings for each poset helps?Thu, 26 Nov 2020 17:28:23 +0100https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/?comment=54397#post-id-54397Comment by Dharm for <p>I want to compute finite posets on 6 elements. Also, I want the following conditions on the posets: 2 covers 0, 4 covers 2, 3 covers 1, 5 covers 3. Also, 0, 1 are incomparable and 4, 5 are incomparable. For that I am giving the following commands: </p>
<pre><code>A=[]
P = Posets(6)
for p in P:
if p.covers(0, 2) and p.covers(2, 4) and p.covers(1, 3) and p.covers(3, 5) and p.compare_elements(1, 0) is None and p.compare_elements(4, 5) is None:
A.append(p);
print(A)
</code></pre>
<p>The output I am getting is not correct. There is only one element in sage output but that is not true. Is there any issue with my code?</p>
https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/?comment=54410#post-id-54410All posets in **P** are naturally labelled. That is, for $x, y \in P$ if $x \leq y$ in $P$ then $x \leq y$ in Natural numbers. In this labelling the number of posets that satisfy the given conditions are more then one. So, I don't think that labelling is an issue here.Fri, 27 Nov 2020 05:35:49 +0100https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/?comment=54410#post-id-54410Answer by dan_fulea for <p>I want to compute finite posets on 6 elements. Also, I want the following conditions on the posets: 2 covers 0, 4 covers 2, 3 covers 1, 5 covers 3. Also, 0, 1 are incomparable and 4, 5 are incomparable. For that I am giving the following commands: </p>
<pre><code>A=[]
P = Posets(6)
for p in P:
if p.covers(0, 2) and p.covers(2, 4) and p.covers(1, 3) and p.covers(3, 5) and p.compare_elements(1, 0) is None and p.compare_elements(4, 5) is None:
A.append(p);
print(A)
</code></pre>
<p>The output I am getting is not correct. There is only one element in sage output but that is not true. Is there any issue with my code?</p>
https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/?answer=55135#post-id-55135Note that `?Posets` gives the following information on the functionality of this constructor, among other lines:
The enumerated set of all posets on 3 elements, up to an
isomorphism:
sage: Posets(3)
Posets containing 3 elements
The accent is put on *up to isomorphism*.
For instance, we may miss the following poset from the list:
sage: pp = Poset(([0..5], [[0,2],[2,4],[3,5],[1,3]]))
sage: pp.show()
![screenshot of some poset](/upfiles/16098973557930179.png)
Well, this poset is not exactly in this shape in `P`, instead we have:
sage: p0, = [p for p in P if p.is_isomorphic(pp)]
sage: p0.relations()
[[3, 3],
[3, 4],
[3, 5],
[4, 4],
[4, 5],
[5, 5],
[0, 0],
[0, 1],
[0, 2],
[1, 1],
[1, 2],
[2, 2]]
sage: p0.minimal_elements()
[3, 0]
sage: pp.minimal_elements()
[1, 0]
(`P` has only $318$ elements, we would have more than $6!$ if the totally ordered posets would have been individually in there, instead as one representative for this isomorphism class.)
Some possibility to restrict to "interesting posets" (that may match or not the purpose) is as follows:
sage: A0 = [p for p in P if max([len(chain) for chain in p.chains()]) == 3 and len(p.minimal_elements()) == 2 and len(p.maximal_elements()) == 2]
sage: len(A0)
35
and now write some code that searches for two disjoint chains of maximal length $3$ in each $p\in A_0$...Wed, 06 Jan 2021 02:54:45 +0100https://ask.sagemath.org/question/54386/not-getting-correct-output-while-computing-posets-with-some-conditions/?answer=55135#post-id-55135