vv

13922 Reputation

20 Badges

10 years, 10 days

MaplePrimes Activity


These are replies submitted by vv

The code works in Maple 2015 and 2019. I don't see how it could fail in 2017. Just copy in 1D input at a Maple prompt.

@mmcdara 

I know what the packing problem is; I did myself such packings using global optimization programs. This one is a (simple) one because a given finite set of balls are "packed"/placed in a given cube. Is it so hard to see this?

I have used Maple 2019 new features. Here is a <2019 version.

restart;  # Versiune Maple < 2018
d:=2; R := [seq(rand(0.1 .. 0.15)(),i=1..20)]; timemax:=100;   # R := [0.1 $ 30]
#d:=3; R := [seq(rand(0.1 .. 0.15)(),i=1..60)]; timemax:=100;
S:=Array(1..1,{1 = [<0.2,0.3>, 0.6]});
#S:=Array(1..1,{1 = [<0.,0.,0>, 0.2]});
####################################
NS:=numelems(S):
Xrnd := r -> LinearAlgebra:-RandomVector(d, generator=-1.+r .. 1.-r): 
nor:=LinearAlgebra:-VectorNorm:
check:=proc(v::Vector, r::positive)
  local w;
  for w in S do
    if nor(w[1]-v,2) < r + w[2] then return false fi
  od;
true;
end:

timelimit(timemax,
proc() local r,v; global NS;
for r in R do v:=S[1][1];
  while not check(v,r) do v:=Xrnd(r) od;
  NS:=NS+1; S(NS) := [v, r];
od end ()
):

if   d=2 then plots:-display(seq( plottools:-disk([seq(s[1])],s[2], color=blue),s=S))  
elif d=3 then plots:-display(seq( plottools:-sphere([seq(s[1])],s[2], style=patchnogrid),s=S))
else "cannot plot" fi;

@sand15 

The radii of the balls must be given, as I did in my solution.
It is actually a sphere packing problem.

@acer 

I agree that it is probably a wise decision, but should be documented.

BTW, the result is hfloat only for a Vector/Matrix, but not Array; even if datatype=algebraic.

 

@acer 

Is it documented?

UseHardwareFloats;
                            deduced

Vector([5.,1]): lprint(%);
Vector[column](2,{1 = 5., 2 = 1},datatype = anything,storage = rectangular,
order = Fortran_order,shape = [])


1/3 * Array([5.,1]): lprint(%);
Array(1 .. 2,{1 = 1.666666667, 2 = 1/3})

1/3 * Vector([5.,1]): lprint(%);
Vector[column](2,{1 = HFloat(1.66666666666666652), 2 = HFloat(.333333333333333315)},datatype = float[8],storage = rectangular,order = Fortran_order,shape = [])

# I would not expect 1/3 * 1 --> hfloat

 

@Carl Love 

You are right, sorry. I think I've read (partly) the code of your first proc ;-)

@Carl Love 

UniformRandPrime can be far from uniform. E.g., if p,q are two consecutive primes, then  UniformRandPrime(p,q) is constant (q). Note that q-p can be chosen arbitrarily large.
A uniform generator seems to be hard do obtain without knowing all the primes in R.

@Carl Love 

You are right. Anyway, it should be trivial to fix.

@ThU 

Nice, vote up, but it could differ by a constant.

@Adam Ledger 

It's simply a syntax error and the message is clear.

@tomleslie 

Anyway, "Daylight Saving" switch will be eliminated in 2021 at least in EU.

@acer

I have used the term "arguments" because Perm is used as a regular function. A user could be even not aware that it's actually an object (constructor).

So, in such situation it's not possible (in general) to retrive the "arguments".

By the way, in the presented case,  convert(p, string)  gives "(1, 2, 3)(4, 5)".
Do you know whether this works in general? Or is it based on ModulePrint?

Edit. OK, I have read about ModuleDeconstruct and everything seems to be clear.
Thank you.

@mmcdara 

In https://en.wikipedia.org/wiki/Student%27s_t-distribution appears: Parameters  ν>0 degree of freedom (real).

But if it makes you feel better, you may call it  "ν" parameter instead of degree of freedom.

@Carl Love 

I don't see a difficulty in formulation as a mixed optimization problem. But it is purely theoretical and useless without a capable optimization procedure (which cannot exist).

A,B = dimensions of the sheets
a[i], b[i] = dimensions for the rectangles (including kerf), i=1..n.

The unknowns are
x[i], y[i], z[i], t[i] the coordinates of a rectangle (output), i=1..n
K[i]   (integer) is the sheet number k where the i-th rectangle goes.
(k=1..m; m is the number of needed sheets; m is estimated using areas, then increased if the problem is not feasible)

Constraints:
0 <= x[i],  z[i]  <= A,  0 <= y[i],  t[i] <= B
( ( z[i] - x[i] - a[i] )^2  + ( t[i] - y[i] - b[i] )^2 ) * ( ( z[i] - x[i] - b[i] )^2  + ( t[i] - y[i] - a[i] )^2 ) * delta(K[i],k) = 0

(  abs( x[i]+z[i]-x[j]-z[j] ) - abs( x[i]-z[i] ) - abs(x[j]-z[j])  ) * delta(K[i],K[j]) >= 0.   # disjoint rectangles
(  abs( y[i]+t[i]-y[j]-t[j] ) - abs( y[i]-t[i] ) - abs(y[j]-t[j])  ) * delta(K[i],K[j]) >= 0.


(Here delta(i,j) is Kronecker delta (0/1) )

 

 

First 56 57 58 59 60 61 62 Last Page 58 of 176