emendes

355 Reputation

6 Badges

5 years, 150 days

MaplePrimes Activity


These are replies submitted by emendes

@Carl Love Many thanks.   I will follow your suggestion but my earlier trials with tasksize defined by Maple did not go well.  Perhaps if I set the tasksize myself as you said,  I will get the better results.  

@Carl Love Thank you ever so much.  

Answers to your answers:

  1. Re: Re: Why op rather than `?[]`  I see.  Many thanks for the explanation.  I didn't know about gc.   
  2. Re: Re: Condition 3 and tuple length.  Great!  It seems that my explanations are somehow improving. 
  3. Re: Re: Maximum orbit length: Now I understand what you meant by Orbit. No, this cannot happen with the sets in this example.  

Questions:

  1. I run the code for tuple_size = 7 and it was pretty fast.   Code:-Usage sent out "memory used=36.06GiB, alloc change=160.00MiB, cpu time=9.76m, real time=5.23m, gc time=6.33m".   Since my mac only has 16 GB of ram, does it mean that there was swapping to the disk?   Would it be possible to run the code for tuple_size=15?
  2. options remember and cache.  Could you give details on why you used them? 

 

@Carl Love Many thanks.  The discussion is helping me to better understand the main problem that I need to solve (thanks a lot).

 

Your Questions:

  1. I can't be sure a 100% but I think that the answer is "No, it does not".  
  2. I don't know if I understand your question.  What do you mean by length 2?  T1 and T2 are particular to this set of parameters (parms).  If parms changes by adding more "alphas", then T1 and T2 will be different.  

Your Answers (to my questions):

  1. But the following set is valid
[alpha[1, 0], alpha[1, 1], alpha[1, 2], alpha[1, 3], alpha[1, 4], alpha[1, 5], alpha[1, 6], alpha[1, 7], alpha[1, 8], alpha[2, 0], alpha[2, 1], alpha[2, 2], alpha[2, 3], alpha[3, 0], alpha[3, 1], alpha[3, 2], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]]

         I am not sure if I understand your answer. 

       2. Why should op replace `?[]`?  

@Carl Love  Many many thanks.  As I said your solution is way out of my league.  I will have to break it down to see if I can understand it.  

"Your 3rd condition cannot ... tuple sizes".  Why not?  Example (24 terms)

[alpha[1, 0], alpha[1, 1], alpha[1, 2], alpha[1, 3], alpha[1, 4], alpha[1, 5], alpha[1, 6], alpha[1, 7], alpha[1, 8], alpha[1, 9], alpha[2, 0], alpha[2, 1], alpha[2, 2], alpha[2, 3], alpha[3, 0], alpha[3, 1], alpha[3, 2], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]]

for i=1 and i=3, the elements are the same and therefore the tuple is not valid (It covers 1,2,3 and there are elements with j>=4). 

When comparing results, my routine returns 153 sets instead of 358.  I need to understand your solution in order to see if I got it right.

Edit 1: My bad!  I forgot to add another condition:  i=1, if j is a subset or equal to {0,1,4} or for i=2,  if j is  a subset or equal to  {0,2,7} or for i=3, if j is a subset or equal to {0,3,9}, the set is not valid and should be removed (as well as its counterpart).  

Although I could add this new condition to your code, I very much doubt that my coding is as efficient and concise as yours.   Here it is (for my shame):

 

test3d := proc(listparms::set)
description "This function returns the indices of the list of parameters that won't lead to a full 3D form";
# It only works for quadratic models 
local i,j,L1,L2,L3,ndim,inds,t:={seq(i,i=0..9)},T:=[{0,1,4},{0,2,7},{0,3,9}],CT,res,auxparms;
#
auxparms:=convert(listparms,list):
#
CT:=[seq(t minus T[i],i=1..nops(T))]: # At least one of these terms and the system is okay
L1:=map(`?[]`, auxparms, [1]):  # list of the first subscript
L2:=map(`?[]`, auxparms, [2]):  # list of the second subscript
ndim:=max(L1):  #  Dimension
inds:=[seq([seq(i,i=min([ListTools:-SearchAll(j,L1)])..max([ListTools:-SearchAll(j,L1)]))],j=1..ndim)]:
L3:=[seq(L2[inds[i]],i=1..ndim)]:  # Second subscript in groups
#
res:=`and`(seq(`or`(seq(evalb(nops(select(x->x=CT[i,j],L3[i]))>0),j=1..nops(CT[i]))),i=1..nops(CT))):
#
return(res):
end proc:

The number of sets is now down to 123 (30 less than the result in my routines). 

 

Edit 2: Question:  Could you explain what  `?[]` does?  Is there a command (something like op) that does the same?  (I have it above but I am not sure if I grasped the full meaning of it).

@Carl Love Many many thanks. I will need time to understand what is going on (the code is way out of my league). I also need to add three more conditions:  

  1. [i,j] - a set to be valid needs that i should always cover 1,2 and 3.  Example: {alpha[1, 0], alpha[1, 1], alpha[1, 2]} is not valid and should be removed.   {alpha[1, 4], alpha[2, 1], alpha[3, 2]} is valid.
  2. On top of that, at least one "j" should be higher or equal to 4.   {alpha[1, 4], alpha[2, 1], alpha[3, 2]} is valid but  {alpha[1, 2], alpha[2, 1], alpha[3, 2]} is not valid.
  3. If the elements of two "i"s are equal, the set is not valid.  Example:  {alpha[1, 4],alpha[1,5],alpha[2, 1], alpha[3, 4],alpha[3,5]}.   Elements for i=1 and i=3 are the same and then set is not valid.

I have implemented tests for all of those conditions but I really don't know where to add them in your solution.  I did try but they didn't make any difference.  

@Carl Love Many thanks.  Can you explain why it does not keep the original set but conds(set)?  Why is {alpha[1, 0], alpha[1, 1], alpha[1, 3]} saved instead of {alpha[1, 0], alpha[1, 1], alpha[1, 2]}?    

@Carl Love Many many thanks.   You were right. For larger tuples the difference in time improvement is unbelievable.  Pushing my luck,  can your solution be adapted to use Iterator?   combinat:-choose will be a problem for 9-tuples ... 20-tuples. 

I thought I had understood what I did but it seems that I didn't.  First element of newabc is {alpha[1, 0], alpha[1, 1], alpha[1, 3]} which is the result of conds(abc[1]) (abc[1]={alpha[1, 0], alpha[1, 1], alpha[1, 2]}).  Instead of saving {alpha[1, 0], alpha[1, 1], alpha[1, 3]} to newabc, I would rather have {alpha[1, 0], alpha[1, 1], alpha[1, 2]}.   To do that I made the following change:

if assigned(tab[conds(i)]) then 
        unassign('tab[i]');
        tab[conds(i)]=()
    fi

which results in something completely different.  What am I missing?  

@acer I see your point.  Perhaps I should not have said "remove" but "left out" or "changed to the counterpart".  Please check "something like" above.  There the counterpart (the result of conds(element))  is swapped by element. At the end of the solution, I used set to shrink abc to the sets I need.  In summary, the procedure in "something like" works but I can't believe that it is the fastest and cleanest way of achieving the result.   The swapping was only possible because I made a copy of abc to array.  Maple won't allow abc[I]:=abc[j]; it sends out an error message.   

@acer many thanks.  What parts are you confused by?   Unfortunately, your solution results in an empty set since evalb(conds~(abc)=abc) is true.  That is the reason I said "variable size" in the title.  Once a counterpart element (conds(abc)) is found it must be removed.

@Carl Love  What is being removed is the counterpart (it is not actually a copy).   Example:  3-tuple {alpha[1, 0], alpha[1, 4], alpha[2, 2]} has 3-tuple {alpha[1, 0], alpha[1, 4], alpha[3, 3]}  as a counterpart.  The counterpart should be removed and the other 3-tuple is kept in the list.  

abc[89];
evalb(conds(abc[89])=abc[100])

Since the result of evalb is true, abc[100] must be removed from abc. 

@Carl Love Many thanks.

Four things:

  1. I will try to answer point by point.
  2. I won't use technical terms.
  3. I will try.
  4. Okay.

Your questions:

  1. Yes, it is for now. Once this example is sorted out, abc will be a copy of 4-tuple, 5-tuple and so on.
  2. Yes, it does.  It applies a certain criterion over an element of abc and returns another element of the same size.
  3. I don't understand the question.  You were right, it is just one copy. Please forget about multiple copies.  

 

I forgot to use Grid:-Set for all subprocedures called by the main procedure.  To check that I had to copy them to a new worksheet and then issue Grid:-Set for all subprocedures.  By doing this, Grid:-Set worked as expected.

Question:  What should I do if I want to stick to using the module?  Use grid inside of the module and issue the command there?  Many thanks.

@Carl Love I am the one who should apologize and say thank you for all the help in the past and now. 

  • The list starts with three and goes up to 12 or 13 (that is the reason for my other question in the lid: Iterator).
  • Yes, there is always one element in the list that matches the search or two elements (due to the symmetry - I don't think there are more than two when the order goes up to 4 .. 13, but I can't prove that).  

Sets and lists - I normally use list to maintain the order.  By the way, if I change my last code to sets, the final number of elements goes down quite a lot (This makes me think that I am mistaken that there are only two symmetric copies). 

Only one element (copy) should remain.  The other copies are symmetrical systems that have the same dynamics. 

I will answer yes for the last question but I am not sure.  I need the indexes of the elements to use in another list. 

My questions:

a) Can the search (and remove copies) be made when I will need to use Iterator? 

b) If the answer for your last questions is no can you show me how to sure selectremove (I tried but surely I did something wrong). 

Many many thanks.

@Carl Love  My attempt to solve the problem is as follows.  

parms:={seq(seq(alpha[i,j],j=0..9),i=1..3)};
abc:=combinat:-choose(parms,3):
tab:=Array(1..nops(abc),1):
for i from 1 to nops(abc) by 1 do
tab[i]:=abc[i]:
end do:

conds:= proc(varCoef::set,vars::name:=alpha)
local T1,T2,res;
#
T1 := table([2=3,3=2,5=6,6=5,7=9,9=7]):
T2 := table([2=3,3=2]):
#
res:=map(u->vars[`if`(assigned(T2[op(1,u)]),T2[op(1,u)],op(1,u)),
         `if`(assigned(T1[op(2,u)]),T1[op(2,u)],op(2,u))],
    varCoef);
return(res):
end proc:

for i from 1 to nops(abc) by 1 do
k:=ListTools:-Search(conds(tab[i]),tab);
k:=ifelse(k<>0,k,i);
tab[k]:=tab[i]:
end do:

newabc:=convert(tab,set):

 

@Carl Love Many thanks.   I run your code and found that the first element of abc is not in the resulting list (or set).  The way I see thte search is:  get the first element and find (or not) the one in the list that fits conds and then remove it (if you don't remove it when the search reaches that element, the first one is removed and it ends up without any representative of that set of coefficients).  I have the impression that the result in your code is the list (set) of the elements that don't fit conds at all). Please correct me if I am wrong.  

As for the question set-list, the order will matter later. Would set be a better choice?  

Conds is the y-z symmetry.  

   

5 6 7 8 9 10 11 Last Page 7 of 16