sursumCorda

1279 Reputation

15 Badges

3 years, 50 days

MaplePrimes Activity


These are replies submitted by sursumCorda

In this question@Carl Love posted an example of finding one shortest possible tour through several 3D points. His code only took he around four minutes, and just took @dharr about six minutes. Unexpectedly, executing it takes me nigh on 9 min! Well, these may be determined by one's computer. But how about Steam Deck's performance?
 

restart;

pts := [[1, 1, 0], [3, 2, 0], [2, 3, 1], [1, 3, 1], [1, 4, 2], [1, 5, 0], [2, 5, 1], [3, 5, 3], [4, 5, 3], [3, 4, 5], [4, 3, 2], [5, 3, 2], [5, 4, 1], [5, 2, 1], [5, 1, 0], [4, 1, 2], [3, 1, 2], [2, 1, 2], [1, 2, 1]]

Matrix(`$`(numelems('pts'), 2), proc (i, j) options operator, arrow; linalg['norm'](pts[i]-pts[j], 1) end proc, shape = symmetric, datatype = integer[1])g := GraphTheory:-Graph(%)

_rtable[36893490071532186668]

g := `Graph 1: an undirected weighted graph with 19 vertices and 171 edge(s)`

(1)

cost, route := CodeTools:-Usage(GraphTheory:-TravelingSalesman(g))

memory used=19.08GiB, alloc change=54.00MiB, cpu time=9.44m, real time=8.71m, gc time=75.19s

costd, route := 42, [1, 19, 4, 3, 7, 6, 5, 10, 8, 9, 11, 12, 13, 14, 15, 2, 16, 17, 18, 1]

(2)

perm := pts[route]

perm := [[1, 1, 0], [1, 2, 1], [1, 3, 1], [2, 3, 1], [2, 5, 1], [1, 5, 0], [1, 4, 2], [3, 4, 5], [3, 5, 3], [4, 5, 3], [4, 3, 2], [5, 3, 2], [5, 4, 1], [5, 2, 1], [5, 1, 0], [3, 2, 0], [4, 1, 2], [3, 1, 2], [2, 1, 2], [1, 1, 0]]

(3)

kernelopts(version);

`Maple 2022.2, X86 64 WINDOWS, Oct 23 2022, Build ID 1657361`

(4)


 

Download testTSP.mws (Sorry for a typo in it.) 

The selection works for sets as well.

@mmcdara For a small problem, minimizing the unsquared sum of actual distances (something like perpendicular offsets) remains possible in practice.

\begin{figure}\begin{center}\BoxedEPSF{LeastSquaresOffsets.epsf}\end{center}\end{figure}

But it seems that Maple haven't collected this method yet, so one has to implement these by hand!

@lcz Replace "\n" and/or "\t" between term and datum with " ". For example, 

fontName	"Dialog"

is replaced by 

fontName "Dialog"

and 

LabelGraphics
		[

is replaced by 

LabelGraphics [

 

@acer Thanks again. It's what I want.

@sand15 Cheers. I believe the "smooth" means "antialiased", but I'm unfamiliar with these technical terms, and don't know how to define them.

@lcz Thanks. Maybe Maple is more geared towards graph computations rather than graph representations. I'm not familiar with Gephi, but it looks superb. At present, if I really wanna plot a graph emphasizing layered structure in Maple, I have to specify the co-ordinates of the vertices manually only after obtaining vertex placement in Mathematica (using GraphEmbedding). This vexed matter is very irritating.

@sand15 I think that the third line is with(ComputationalGeometry):. Also, the boundary is less smooth, but this is a constructive approach indeed. Thanks!

@acer This time the boundary is very rough (in contrast to Mathematica's default output). However, these approaches are not so easy-to-use. (What about other possible ways?) It is often alleged that there exists an inverse relationship between the power of the tool and how easy it is to use. Still, I wish there to be a more intelligent Maple functionality in this respect.

@mmcdara Thanks as well. It seems that if we hope to transform a complicated plot, this approach may fail. Am I correct in saying this?

@acer Thanks very much. I never knew these before. But I wonder why plottools[transform] works in the first example instead. Any distinctions?

Are your codes correct? An error is issued at last:  By the way, running these on my computer takes about 32 minutes!

@C_R Thanks. It's very strange indeed—It appears that using the standard plot is always recommended.

@mmcdara Incidentally, an alternative method of the given problem is using certain CAD-based algorithms: 

try
    unwith(Logic):
catch:
    ;
finally
    RegularChains:-SemiAlgebraicSetTools:-QuantifierElimination(&E [x, y, a], ((x^3 + y^2 - x = a) &and (a^2 = 4/27) &and (a < 0)) &and ((x^2 + y^2 = R^2) &and (R >= 0)), 'output' = 'rootof');
end try;
               /    1  (1/2)\     /2  (1/2)     \
               |R = - 3     | &or |- 3      <= R|
               \    3       /     \3            /

Nonetheless, this is really beyond layman's ken (despite its correct result).

Unfortunately, extrema just returns (constrained) relative extrema of n algebraic expression; the "extreme values" must be checked later. In addition, in this problem, x, y, and z are all positive real numbers, so you need at least

extrema(x^2*y^2*z^2, x^2 + y^2 + z^2 = 6, {x, y, z}, 'S');

or 

Student[MultivariateCalculus][LagrangeMultipliers](x*y*z, [x + y + z - 6, -sx^2 + x, -sy^2 + y, -sz^2 + z], [x, y, z, sx, sy, sz], output = detailed);

for exact solutions.

First 19 20 21 22 23 Page 21 of 23