brian bovril

889 Reputation

16 Badges

18 years, 298 days

MaplePrimes Activity


These are questions asked by brian bovril

Hi

How can I remove a subset containing a number from a partition?

eg S := [seq(2..5)]

P:=combinat:-setpartition(S, 2);

[[[2, 3], [4, 5]], [[2, 4], [3, 5]], [[2, 5], [3, 4]]]

I want to remove any partition involving 5

leaving

[[[2, 3]], [[2, 4]], [[3, 4]]]

i tried

remove(has,P,5)

 

 

Given

Tour2:=[[[1, 2, 3, 4]], [[1, 2], [1, 3, 4]], [[1, 3], [1, 2, 4]], [[1, 4], [1, 2, 3]], [[1, 2], [1, 3], [1, 4]]]:

Kitonums code

seq(max(seq(add(d[s[i]]*x[s[i],s[i+1]], i=1..nops(s)-1) , s=t))<=K, t=Tour2); produces

18*x[1, 2]+26*x[2, 3]+11*x[3, 4] <= K, max(18*x[1, 2], 26*x[1, 3]+11*x[3, 4]) <= K, max(26*x[1, 3], 18*x[1, 2]+11*x[2, 4]) <= K, max(11*x[1, 4], 18*x[1, 2]+26*x[2, 3]) <= K, max(18*x[1, 2], 26*x[1, 3], 11*x[1, 4]) <= K

correctly. The problem is I want to pass this through LPSolve and it doesn't like it. So what I need is to convert it to a constraint it will accept. I found a method on stackexchange,

http://stackoverflow.com/questions/10792139/using-min-max-within-an-integer-linear-program

i'm not sure it even works.i would be great if a procedure could could convert the max's in the above expression, or change the code in bold.

max(6*x[1, 4],4*x[1, 2]+3*x[2, 3]), where x[i,j] are binary vars.
x4 >= 6*x[1, 4];
x4 >= 4*x[1, 2]+3*x[2, 3];
Objective:= x4;

 

Sirs.

Probably a brain fade, but I cant seem to code what i want.

constraints.mw
 

Tour2:=[[[1, 2, 3, 4]], [[1, 2], [1, 3, 4]], [[1, 3], [1, 2, 4]], [[1, 4], [1, 2, 3]], [[1, 2], [1, 3], [1, 4]]];M:=nops(Tour2):

[[[1, 2, 3, 4]], [[1, 2], [1, 3, 4]], [[1, 3], [1, 2, 4]], [[1, 4], [1, 2, 3]], [[1, 2], [1, 3], [1, 4]]]

(1)

interface(rtablesize=M):
  maxEnt:=max([seq(nops(Tour2[i]),i=1..M)]):
  Tours_Distances := Matrix
                     ( maxEnt,
                       M,
                       [ seq
                         ( [ seq
                             ( `if`( numelems(Tour2[i])>=j,
                                     d[i]*x[op(Tour2[i,j])]<=K,
                                    0
                                   ),
                               i=1..M
                             )
                           ],
                           j=1..maxEnt
                         )
                       ]
                     );

Tours_Distances := Matrix(3, 5, {(1, 1) = d[1]*x[1, 2, 3, 4] <= K, (1, 2) = d[2]*x[1, 2] <= K, (1, 3) = d[3]*x[1, 3] <= K, (1, 4) = d[4]*x[1, 4] <= K, (1, 5) = d[5]*x[1, 2] <= K, (2, 1) = 0, (2, 2) = d[2]*x[1, 3, 4] <= K, (2, 3) = d[3]*x[1, 2, 4] <= K, (2, 4) = d[4]*x[1, 2, 3] <= K, (2, 5) = d[5]*x[1, 3] <= K, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = d[5]*x[1, 4] <= K})

(2)

convert( (2), 'list', 'nested' );

[[d[1]*x[1, 2, 3, 4] <= K, d[2]*x[1, 2] <= K, d[3]*x[1, 3] <= K, d[4]*x[1, 4] <= K, d[5]*x[1, 2] <= K], [0, d[2]*x[1, 3, 4] <= K, d[3]*x[1, 2, 4] <= K, d[4]*x[1, 2, 3] <= K, d[5]*x[1, 3] <= K], [0, 0, 0, 0, d[5]*x[1, 4] <= K]]

(3)

 

But what I want is:

d[1]*x[1,2]+d[2]*x[2,3]+d[3]*x[3,4]<=K,d[1]*x[1,2]<=K,d[1]*x[1,3]+d[3]*x[3,4]<=K;      #.....etc.

 

 

 

 

 

d[1]*x[1, 2]+d[2]*x[2, 3]+d[3]*x[3, 4] <= K, d[1]*x[1, 2] <= K, d[1]*x[1, 3]+d[3]*x[3, 4] <= K

(4)

NULL


 

Download constraints.mw

 

Hello again. 3 questions today, a record for me.

I'm looking for a procedure to do this

Combinatorial_explosion.mw

thankyou.

 

 

Salutations.

for L:=[5,0,10,3]

What command do I require to find minimum of L which excludes 0? [ 3]

FindMinimalElement?

First 11 12 13 14 15 16 17 Last Page 13 of 34