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.Sat, 27 Jul 2024 17:14:28 +0200Tiling solver: finite limits for reusable pieceshttps://ask.sagemath.org/question/78500/tiling-solver-finite-limits-for-reusable-pieces/I am hoping someone can explain to me how to get the Tiling Solver to work sensibly with finitely limited piece constraints. I tried adding multiple copies of given polyominos into the pieces list and setting reusable = False, but this was not handled sensibly by the iterator as it seemed to be viewing permutations of identical pieces as distinct solutions, and therefore finding absurdly many solutions.
If there is no way to do this currently, it seems like a worthy feature to implement.
Thank you!J.staffSat, 27 Jul 2024 17:14:28 +0200https://ask.sagemath.org/question/78500/Iteration over a Combinations(alist, 5).list()https://ask.sagemath.org/question/53220/iteration-over-a-combinationsalist-5list/ Dear all,
I have a big set built as : Combinations([1,2,3,4,5,6,7], 5).list() through which I need to iterate. In real life, the list [1,2,3,4,5,6,7] has 72 components. I don't need this set of combinations, only to iterate through it.
I did not find the proper way to do that with the combinat package, but I have the feeling I overlooked something.
Many thanks if you have infos on this issue!
Best, O. Olivier R.Sun, 30 Aug 2020 15:52:38 +0200https://ask.sagemath.org/question/53220/Error with rational input in IntegerVectorshttps://ask.sagemath.org/question/50814/error-with-rational-input-in-integervectors/ I discovered the following unexpected behavior of `IntegerVectors`:
sage: IntegerVectors(2,3).list()
[[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]]
sage: IntegerVectors(2,3/1).list()
[[2, 0, 0], [1, 1, 0]]
The relevant code block in the implementation of `IntegerVectors` seems to be the following:
try:
return IntegerVectors_nnondescents(n, tuple(k))
except TypeError:
pass
return IntegerVectors_nk(n, k)
For `k=3/1` one has that `tuple(k)` does not give a `TypeError` (as opposed to `tuple(3)`) and thus the code never tries to interpret `k` as an integer.Johannes SchmittFri, 17 Apr 2020 18:26:59 +0200https://ask.sagemath.org/question/50814/Can't find packages combinat and clusterhttps://ask.sagemath.org/question/43777/cant-find-packages-combinat-and-cluster/ I just installed SageMath-8.1.app on MacBook Touchbar OSX 10.12.6. I wanted the ClusterAlgebra/Quiver package. The 2011 manual ("Compendium") says to first install the combinatorics package "combinat " by entering "./sage -combinat install". I did that on the terminal command line in various subdirectories of SageMath-8.1.app but got only error messages. I then tried "./sage -i combinat" which produced much output with the upshot that it couldn't find combinat. "./sage package list" showed neither combinat nor anything sounding like "cluster". I will appreciate suggestions.
---If this is not the right forum for this question, please advise where to go. Thanks.HannesFelbertThu, 27 Sep 2018 07:08:30 +0200https://ask.sagemath.org/question/43777/How to get a list of the combinations such that the elements are equal to some $n$https://ask.sagemath.org/question/43570/how-to-get-a-list-of-the-combinations-such-that-the-elements-are-equal-to-some-n/ I want a generalization of this kind
`[(r1, ..., rk) for r1 in range(n+1) ... for rk in range(n+1) if r1 + ... + rk = n]`
For a general number of $r$'s and any $n$MarioMTue, 04 Sep 2018 03:45:31 +0200https://ask.sagemath.org/question/43570/Generating a unique file name for each graphhttps://ask.sagemath.org/question/10040/generating-a-unique-file-name-for-each-graph/I am writing a function whose input is a graph and some other data. I would like to store the computations that this program does each time it is run in a file with one file for each graph, so that, the next time it is run, it need not recalculate the calculations it has already done. In order to do this, I would like to assign a unique file name to each graph. I was thinking of using the hash function of the combinatorial object constructed from the graph to generate file names: `CombinatorialObject(G).__hash__()`
I have two questions:
1. Will this always work (the function taking a graph to this hash is well-defined and injective)?
2. Is there a better way to do this?
AmriFri, 19 Apr 2013 05:52:38 +0200https://ask.sagemath.org/question/10040/Recursive backtracking function: how to clear variables on new function call?https://ask.sagemath.org/question/9688/recursive-backtracking-function-how-to-clear-variables-on-new-function-call/I've been trying to write a simple function to make lists of all the Young diagrams/partitions between a starting partition ('top') and an ending partition ('bot'), with each step in the list a covering relation (exactly one box difference in each step).
For instance, I would like to input [2,1] for top and [1] for bot and get
[[2,1],[2],[1]]
[[2,1],[1,1],[1]]
as my outputs. (I want to do this because it's useful for some computations with Littlewood-Richardson coefficients; having the lists that give each partition in a path between top and bot will be useful for other computations.)
My code at present has an echo, and worse, I can't figure out where to initialize path_list. Where do I put path_list = [] -- or create other lists -- to make sure that:
1. I get a separate list for each path, and
2. Calling the function again clears path_list?
(2) is worst: right now, since path_list is an internally-defined variable, I get the following bad behavior:
sage: load "makepartitionlist.sage"
sage: get_path([1],[1])
[[1]]
[[1]]
sage: get_path([1],[1])
[[1], [1]]
[[1], [1]]
sage: get_path([1],[1])
[[1], [1], [1]]
[[1], [1], [1]]
because path_list is not cleared when I call get_path again (which I'd hoped putting path_list = [] in the arguments would accomplish).
The code:
def get_path(top, bot, path_list = []):
path_list.append(top)
if top == bot:
print path_list
return path_list
if not Partition(top).contains(Partition(bot)):
return None
for i in range(0,len(Partition(top).down_list())):
p = Partition(top).down_list()[i]
if Partition(p).contains(bot):
path_list.append(p)
get_path(p, bot, path_list)
I'm using Sage 5.0.1 with Sage-combinat providing the Partition function and others.kaisatFri, 04 Jan 2013 18:50:38 +0100https://ask.sagemath.org/question/9688/combinat installhttps://ask.sagemath.org/question/9527/combinat-install/I was running sage 5.3 on a lubuntu 12.04 machine. Everything was fine.
Then I tried
> ./sage -combinat install
Now when I try to use sage, it says
> `<ERROR: name 'sage_prompt' is not defined>`
Is this a known issue? I am currently reinstalling sage 5.4 and hoping that it will work this time. Please advise. Thanks!
UPDATE: I tried it again in 5.4 and got the following error:
> `Creating sage-combinat branch:
/home/oliver/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/sage -b main`
> `----------------------------------------------------------
sage: Building and installing modified Sage library files.`
> `Installing c_lib
g++ -o libcsage.so -shared src/convert.os src/interrupt.os src/memory.os src/mpn_pylong.os src/mpz_pylong.os src/mpz_longlong.os src/stdsage.os src/gmp_globals.os src/ZZ_pylong.os src/ntl_wrap.os -L/home/oliver/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib -L/home/oliver/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/config -lntl -lpari -lgmp -lpython2.7
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: ld returned 1 exit status
scons: *** [libcsage.so] Error 1
Error building c_lib.
Abort`OliverPMon, 12 Nov 2012 12:29:52 +0100https://ask.sagemath.org/question/9527/