brian bovril

889 Reputation

16 Badges

18 years, 299 days

MaplePrimes Activity


These are replies submitted by brian bovril

@Kitonum I can't say I follow your coding Yuri, but it works fine.

@Kitonum thx. From your solutions, how can the above output be displayed?

@Kitonum Although the question is answered I am hopeful you can fix this code (allocation of sports):

restart;
>  Names:={Alex, Betty, Carol, Dan, Earl, Fay, George, Harry}:
>  A:=combinat[choose](Names, 3):
>  L:=[]:
>  for i in A do
>  B:=combinat[choose](Names minus i, 3);
>  for j in B do
>  L:=[op(L), [i, j, (Names minus i) minus j]];
>  od: od:

> Organization:={seq(op(combinat[permute](L[k])), k=1..nops(L))}:

> Terms:=[not(Dan in Football), not(Dan in Cricket),Alex in Table_Tennis, Carol in Hockey,  not(George in Cricket), not(George in Badminton), not(Harry in Cricket)]:

> Sports:=[]:
>  for variant in Organization do
>  Football:=variant[1]: Cricket:=variant[2]: Table_Tennis:=variant[3]: #Dunno how to account for the other five sports
>  if convert(Terms, `and`) then Sport:=[op(Sports), variant]; fi;
> od:

> op(Sports);

who_works_where.mws

@Carl Love 

i'm trying to use your package to solve this problem, but i didn't really know how to construct the logical arguments properly (constaints).

http://www.mathsisfun.com/puzzles/who-works-where-solution.html

in case the file doesn't upload:

> Vars := [EN, Dept, Sport]

> EN := [alex, betty, carol, dan, earl, fay, george, harry];     

> Dept:= [person,admin,market];                  

> Sport:= [football,cricket,volleyball,badminton,tennis,basketball,hockey,table];

> Satisfy([dan = admin, dan <> football, dan <> cricket, fay = person,

        alex = person, alex = table, earl <> dan, harry <> dan,

        carol = hockey, carol <> market, george <> admin,

        george <> cricket, george <> badminton, harry <> cricket])

D&C_odd.mw

@Joe Riel sorry to bug you. Consider a 5 groups of 4 members. n=5,e=4, no. of partitions >2.5E9. [as a side question, how does that convert to computer time]?

.."split into m and m-1 sets of 4".....anyway I had a go with some sledghammer code but it not right

@Joe Riel for a set of 28, how should I spit them into (ultimately) 7x4?

@Joe Riel thankyou very much.

Is it possible to alter your code so that the partitions are output :

[{1236.0, 1277.0, 1576.0, 1644.0}, {1249.0, 1292.0, 1392.0, 1829.0},{1297.0, 1404.0, 1477.00, 1520.0}, {1313.0, 1325.0, 1477.0, 1594.0}] 

along with their names

[{A14, A16, A2, A4}, {A1, A13, A15, A9}, {A12, A5, A7, A8}, {A10, A11,A3, A6}]?

@Carl Love thanks heaps. It appears I don't have a Maple compiler. Is this how I get it?http://www.maplesoft.com/support/install/maple17_install.html#MapleInstallGuide_CPPCompiler

it looks complicated

@Carl Love thanks for your effort here.

 Sorry to keep bugging you, How does one choose an initial variance?

I ran your code for Var(P)>0.01 (any lower and the kernel crashed).

I got these results:

Var(P);

0.89246398631e-2

P; [{1236.0, 1292.0, 1404.0, 1829.0}, {1249.0, 1392.0, 1477.0, 1594.0}, {1277.0,1325.0, 1477.00, 1644.0}, {1297.0, 1313.0, 1520.0, 1576.0}]

add(abs(convert(P[j], `*`)-convert(P[j+1], `*`)),j=1..nops(P)-1)+abs(convert(P[nops(P)], `*`)-convert(P[1], `*`));

73085876073.82

 In constrast, Evolver got these results [after a couple of minutes running]....

P:=[{1829,1404,1292,1236},{1644,1477,1325,1277},{1576,1520,1313,1297},{1594,1477,1392,1249}];

add(abs(convert(P[j], `*`)-convert(P[j+1], `*`)),j=1..nops(P)-1)+abs(convert(P[nops(P)], `*`)-convert(P[1], `*`));

58155331960

(smaller)

@Carl Love ran this code:

restart:
S := [1829.0, 1644.0, 1594.0, 1576.0, 1520.0, 1477.0, 1477.0001,1404.0, 1392.0, 1325.0, 1313.0, 1297.0, 1292.0, 1277.0, 1249.0, 1236.0]:
SL:=[seq(A||i,i=1..16)]:
assign(Labels ~ (S) =~ SL); #Create remember table.
nops(%%);

ts := time():  AllP:= [seq(P, P= Iterator:-SetPartitions({op(S)},[[4,4]],compile= false))]:
lnp:= evalf(ln(`*`(S[])^(1/3))):
Var:= proc(P::list(set))
local r:= evalf(`+`(map(b-> abs(ln(`*`(b[]))-lnp), P)[]));
end proc:
ans:=sort(AllP, (x,y)-> Var(x) < Var(y))[1];
 time()-ts;

subsindets(ans, realcons, Labels);  

@Carl Love silly me, I meant 10^20

@Joe Riel thanks Joe and Acer, thats just what I wanted

@Carl Love 

When I try to order the set [1829.0, 1644.0, 1594.0, 1576.0, 1520.0, 1477.0, 1477.0, 1404.0, 1392.0,

   1325.0, 1313.0, 1297.0, 1292.0, 1277.0, 1249.0, 1236.0] into 4 groups of 4, the program takes (understandably) a long time. Rather than minimizing the variance, is it possible to reduce the time by setting the variance<= a predetermined value (like 0.021).

 

real_labels.mw
@Kitonum Could you kindly correct attached worksheet so it works out the 3 groups and attributes labels correctly, thanks.

[It needs to work with lists instead of sets, and real numbers instead of integers].

>

 

S := [1829.0, 1644.0, 1594.0, 1576.0, 1520.0, 1477.0, 1477.0, 1404.0, 1392.0]: SL := ["tom", "Wayne", "Chris", "Tim", "Andrew", "Murray", "Rebecca", "Arron", "Mark"]: Var := infinity:

 

assign(Labels ~ (S) =~ SL); #Create remember table.

 

T := combinat[choose](S, 3):

 

for t in T do

 

S1 := `minus`(S, t):

 

U := combinat[choose](S1, 3):

 

for u in U do

 

S2 := `minus`(S1, u):

 

Var1 := abs(convert(t, `*`)-convert(u, `*`))+abs(convert(u, `*`)-convert(S2, `*`))+abs(convert(t, `*`)-convert(S2, `*`));

 

if Var1 < Var then Var := Var1:

 

L := {Var, {S2, t, u}} end if

 

end do end do:

 

L;

 

Error, invalid input: `minus` received [1829.0, 1644.0, 1594.0, 1576.0, 1520.0, 1477.1, 1477.0, 1404.0, 1392.0], which is not valid for its 1st argument, s1

 

L

(1)

ans:= %[2];

 

L[2]

(2)

subsindets(ans, realcons, Labels);

L[2]

(3)
First 14 15 16 17 18 19 20 Last Page 16 of 26