# Tag Info

Accepted

### Optimization of function taking a permutation

How about a Monte-Carlo-Metropolis search? I'll implement a simplistic version here. See complete universal code further down. Update: Cleaned-up code now available in the Wolfram Function Repository, ...
• 49.1k

### Efficient multidimensional optimization while constraining some coordinates

Phew, this became more complex than I thought because the objective is not quadratic (as I had first expected). Here some preparations for an efficient evaluation of the energy and its first two ...

### how to get $n$ equidistributed points on the unit sphere

If more ad hoc, inexact approaches are welcome, one way to generate relatively uniform density of points on a sphere is to use Monte Carlo Lloyd's algorithm (modified for the spherical case): ...
• 19.1k

### Expressing a polynomial as a sum of squares

Here is a somewhat heuristic approach, that relies in this case on the SOS having integer coefficients. I will indicate an alteration that gives a numerical approximation in the general case. Start ...
• 59.6k
Accepted

### Possible bug in NMaximize function?

This is an extended comment rather than an answer, but it would have been unwieldy in a comment box. I was able to reproduce the problem you describe on Windows 10 / MMA 12. I also noticed that ...
• 67.5k
Accepted

### Scheduling Optimization

Turning a comment into an answer. This is more or less a straight-forward adaptation of a solution in Efficient solution for a discrete assignment problem with pairwise costs to the problem. This ...
• 19.1k

### Possible bug in NMaximize function?

In V12, WRI introduced new convex optimization solvers. NMiminize was updated to automatically choose one when appropriate. But in this case, it seems to enter an ...
• 240k
Accepted

### Find the equidistance curve between two curves

f[x_] := x^x g[x_] := Log[x]^Log[x] h[x_] := Log[x]^2 plot = Plot[{f[x], g[x], h[x]}, {x, 0, E}, PlotRange -> {0, 1}] Extract the three lines from ...
• 399k

### Find the equidistance curve between two curves

Here we manual create the normal line of the three differentiable curves. ...
• 78.3k
Accepted

### How can I use Python's SciPy and NumPy functions in Mathematica to find the minimum of a function?

I believe you're not in the correct direction, optimizing your Mathematica code should be more practical and easier. (You've already learned the numeric capability of Mathematica under your previous ...
• 67.2k
Accepted

### Efficiently Mowing Grass with Mathematica

This is just starting ideas for arbitrary regions. Perhaps you can improve it. Version 1 Define concave region with holes, which can be generalizable to arbitrary complexity: ...
• 73.4k
Accepted

### Why can't I provide NMinimize with initial points when minimizing over two variables but not one?

Feed "InitialPoints" a list of 1D coordinate vectors: ...
• 240k
Accepted

Accepted

### Given a list of integers, find the largest sum of a contiguous subsequence

f[l_] := Module[{sl = Flatten@MaximalBy[Subsequences[l], Total]}, {Total[sl], sl}] f[{1, 2, 3, 4, 5, -1, 7, -4, -2}] (* {21, {1, 2, 3, 4, 5, -1, 7}} *)
• 61.8k
Accepted

### Finding an ellipse of minimum area that encloses a set of points

You are looking for BoundingRegion with the "MinEllipse" region specification: ...
• 67.5k
Accepted

### Minimizing with differential evolution

Here's a way: ...
• 240k
Accepted

### Packing arbitrary shapes

Perhaps a start: We can extract information from WordCloud in order to translate a collection of regions so they pack nicely. First I'll create some ...
• 36.4k
Accepted

### Why does NMaximize miss this global maximum?

This kind of problem — smooth, univariate function over a finite and relatively small domain — can be handled numerically by using NDSolve to locate the relative ...
• 240k
Accepted

### Genetic algorithm to maximize a function $\text{Sinc}(x)$

You could do so many different things for crossover and mutation, like toggling/interchanging bits in the binary representation of $x$ or whatever - but here I've just used an average for crossover, ...
• 25.6k
Accepted

### Using StepMonitor/EvaluationMonitor with DifferentialEvolution in NMinimize

EvaluationMonitor is going to be called whenever the objective function is being evaluated, that is much more often than ...
• 25.5k
Accepted

### Time constrained optimization?

This is how I usually deal with this kind of problem. Keywords to the solution are TimeConstrained, AbortProtect, ...
• 2,732

### Differentiating functions of vectors/matrices?

In this post I discuss a function MatrixD which attempts to take a matrix derivative following the guidelines given in the The Matrix Cookbook. I still want to ...
• 131k
Accepted

### FindMaximum of Interpolated data set

NMaximize is good for finding global maxima: NMaximize[{f[x], 26 < x < 6908}, x] (* {28.9179, {x -> 177.957}} *) For <...
• 5,424

### Minimum energy path of a potential energy surface

Interesting problem. Decided to treat it as a graph problem, rather than fitting an InterpolatingFunction to it and getting descent directions from there. If I knew ...
• 7,193
Accepted

### Minimizing expression over symmetric matrices

That's an eigenvalue problem! How to see that? Well, let's define some example data: ...
Accepted

### Maximizing over a 1D region

Update: Carl gave the best solution in a comment: Could use {y} ∈ Interval[{-1, 1}] instead. – Carl Woll If you use the region notation, the variable is ...
• 236k
Accepted

### Finding the largest disk within a convex region using Region primitives

poly = Polygon @ {{0, 1}, {0, 6}, {4, 10}, {8, 10}, {11, 7}, {11, 4}, {7, 0}, {1, 0}, {0, 1}}; dsk = Disk[{x, y}, r]; We can use ...
• 399k