Questions tagged [mathematical-optimization]

Questions on the optimization functions of Mathematica such as FindMinimum/FindMaximum, Minimize/Maximize, NMinimize/NMaximize, etc.

Filter by
Sorted by
Tagged with
94 votes
2 answers
8k views

Shaving the last 50 ms off NMinimize

The epilogue: A paper where the below answer is used was published. The answer below is cited among the references:) The background: I have to fit an objective function for ~10 000 datasets in near ...
user avatar
  • 13.4k
77 votes
5 answers
27k views

How to find all the local minima/maxima in a range

I want to find : all local maxima in range all local minima in range From those points I can interpolate and combine functions upper and lower boundary. What I am really interested in, is the mean ...
user avatar
  • 1,977
44 votes
3 answers
5k views

Identifying critical points/lines of 2/3D image/cubes

Upshot I am interested in identifying critical points of a 3D field/cubes (maxima, minima, tube-like and wall-like saddle points) and 2D field/image (maxima, minima, saddle points). I.e. the ...
user avatar
  • 21.7k
43 votes
2 answers
2k views

How to work with Experimental`NumericalFunction?

This question is intimately connected with previous one: "How to create internally optimized expression for computing with high WorkingPrecision?" Oleksandr R. correctly states in the comment: A ...
user avatar
40 votes
5 answers
21k views

Finding Local Minima / Maxima in Noisy Data

I'm trying to find local minima / maxima in noisy data, consisting of data values taken at certain time intervals. Ideally, the function should take a pair of lists (one containing time values and one ...
user avatar
35 votes
1 answer
2k views

Convex optimization

I am playing with some Compressed Sensing (think single pixel camera) applications and would like to have a Mathematica equivalent of a Matlab package call Convex Optimization (CVX). Specifically, I ...
user avatar
  • 359
33 votes
3 answers
7k views

Optimization of a portfolio of stocks

I would like to use Mathematica to perform an optimization of a portfolio composed by 10 stocks. I did the first part to compute yields and expected yields, but I don't know how to finish the ...
user avatar
  • 399
31 votes
1 answer
582 views

FindMinimum doesn't increase step size when necessary

Behavior remains unchanged through Mathematica version 13.0.0 (Cross-posted on Wolfram Community.) I've spent much time finding a minimal example demonstrating this problem with ...
user avatar
30 votes
2 answers
2k views

Numerical optimal control

I was hoping to tackle optimal control using Mathematica in order to learn how I can use Mathematica's built in numerical integration and optimization functions together in order to solve an optimal ...
user avatar
27 votes
1 answer
736 views

Efficient multidimensional optimization while constraining some coordinates

I have a function f[x] with a high-dimensional vector input and a scalar output. I am looking to minimize this function while constraining some of the components of ...
user avatar
  • 225k
26 votes
2 answers
998 views

Possible bug in NMaximize function?

Bug introduced in 12.0 In 12.0.0 for Microsoft Windows (64-bit) (April 6, 2019) writing: ...
user avatar
  • 4,281
26 votes
2 answers
2k views

Schedule programing problem with integer linear programming

I know how to model this question on paper, but I don't know how doing it in Mathematica. Imagine , there is a university student who want to choose courses for this semester and he got the ...
user avatar
  • 1,153
25 votes
12 answers
7k views

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

We can get $n$ equidistributed points in the unit circle using CirclePoints. But how do you get $n$ equidistributed points on the unit sphere(surface of a ball)? ...
user avatar
  • 23.7k
25 votes
2 answers
1k views

Obtain approximate Hessian using FindMinimum

According to the documentation, when FindMinimum is told to use the method "QuasiNewton" on a unconstrained problem, it uses the ...
user avatar
  • 1,255
25 votes
3 answers
981 views

Exponential fitting - isn't actually a BUG there?

There are many questions on this site about wrong exponential fitting in Mathematica but no one considers this well-known problem as a potential bug. Usually people suggest well-known workarounds ...
user avatar
21 votes
3 answers
10k views

How can I implement the method of Lagrange multipliers to find constrained extrema?

I want to form the function $h=f-\lambda_{1}g_{1}-\lambda_{2}g_{2}$ where $f$ is the function to optimize subject to the constraints $g_{1}=0$ and $g_{2}=0$ so that I can solve the first partial ...
user avatar
  • 517
21 votes
2 answers
3k views

Differentiating functions of vectors/matrices?

I'm dealing with derivatives of scalar functions of matrices and wondering if Mathematica can help me here. The standard approach of expanding it in terms of components is cumbersome. As an ...
user avatar
21 votes
2 answers
3k views

Optimization with assumptions

I have the following problem, when I am trying to optimize function with pre-defined assumptions. I am using Mathematica 8 and I wrote the following simple code ...
user avatar
  • 211
20 votes
2 answers
9k views

Find maximum value of interpolation function - obviously wrong result

Minimizing and maximizing interpolation function has already been asked and answered, see here for example. Yet, I observe a strange behaviour. Well, I can understand that the wrong guess of ...
user avatar
  • 13.8k
20 votes
2 answers
2k views

Expressing a polynomial as a sum of squares

I encountered a degree 4 polynomial in 8 variables f(a1,a2,a3,a4,b1,b2,b3,b4) that I suspect can be written as a sum of squares. While sostools in MATLAB would find ...
user avatar
  • 301
20 votes
2 answers
600 views

Maximize[Cos[x - 1], x] is not evaluated

No explanation needed: Maximize[Cos[x + 1], x] Maximize[Cos[x - 1], x] producing ...
user avatar
19 votes
1 answer
3k views

Multi-objective genetic algorithm in Mathematica?

Is there any implementation of a multi-objective genetic algorithm for Mathematica?
user avatar
18 votes
4 answers
963 views

Optimization of function taking a permutation

I have a function $f$ which takes a permutation $P$ of the integers 1-100 in order to give a numerical value $f(x)$. The function is given by a black box, but is relatively "smooth", so should be ...
user avatar
  • 5,448
18 votes
3 answers
2k views

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

I have written my code in Mathematica, final aim of this code is to find the minimum of a function. I found that FindMinimum and ...
user avatar
18 votes
2 answers
1k views

Determining the default Method used in optimization and root-finding algorithms

Is it possible to extract the Method which is used in functions like NMinimize, FindRoot, <...
user avatar
  • 111k
18 votes
2 answers
1k views

How can I speed up the classic GA for graph coloring?

I'm trying to compute the chromatic number of this graph (which is 28): g = Import@"http://www.info.univ-angers.fr/pub/porumbel/graphs/dsjc250.5.col"; My genetic ...
user avatar
  • 30.4k
18 votes
1 answer
909 views

PenaltyFunction Option in NMinimize

I am curious if anybody has some experience in using the built-in Option "PenaltyFunction" in any of the numerical optimization functions like ...
user avatar
17 votes
4 answers
6k views

NMinimize usage

I would like to minimize functions including the following. NMinimize[{1 - (1 - 1/n)^x - x/n, n > x, x > 1}, {n, x}] However Mathematica complains about ...
user avatar
  • 1,079
17 votes
4 answers
989 views

Find the equidistance curve between two curves

I have three function $f(x)=x^x$, $g(x)=\ln(x)^{\ln(x)}$, $h(x)=\ln(x)^2$ and I want to find (numerically) $C$ the center of the circle tangent to the three curves. I think that one way is to find ...
user avatar
17 votes
1 answer
3k views

Combined numerical minimization and maximization

I want to numerically calculate the maximum of a function defined by the minimization of another function, like the following: ...
user avatar
  • 18.8k
16 votes
2 answers
474 views

Scheduling Optimization

I asked this question here 2 years ago. I didn't know this website at that time. I just realized I could ask it here. Here is the problem statement. Assume I have 20 trucks, $t_j$, $j=1...20$ and ...
user avatar
16 votes
1 answer
936 views

Efficiently filling area with disks located at certain points

Starting from a set of points, I want to fill an area using disks. Each disk's center should be one of the points and the disks should not overlap. I've managed to write a function that, given a list ...
user avatar
  • 3,974
16 votes
1 answer
553 views

Bug in plotting function using FindMinimum?

Bug introduced in 10.0 and persisting through 11.0.1 or later While working on an answer to RegionPlot from NDSolve, I came across this strange behavior of ...
user avatar
  • 216k
15 votes
3 answers
7k views

Finding all maxima and minima of a function

To find all (global and local) extrema of a function in $\mathbb R^3$, I have written the following. Example function: ...
user avatar
  • 34.5k
15 votes
1 answer
3k views

Which methods are available for NMinimize?

I can't find in the documentation the list of methods available to NMinimize[]. Is there a way to get this? The NMinimize page in Documentation Center mentions only ...
user avatar
  • 7,757
15 votes
4 answers
721 views

FindShortestTour for charity (or: How can I optimize meal delivery with FindShortestTour?)

I've been wondering about this for a while - but never got around to asking - until I saw faleichik's incredible answer to Mathematica Minecraft. I did some work at a not-for-profit a little while ...
user avatar
15 votes
4 answers
7k views

Minimizing a function of many coordinates

I'm trying to obtain a series of points on the unit sphere with a somewhat homogeneous distribution, by minimizing a function depending on distances (I took $\exp(-d)$). My points are represented by ...
user avatar
  • 10.6k
15 votes
1 answer
2k views

ParallelEvaluate for function minimization

Is there a parallelized version of a minimization routine available in Mathematica? The objective function is non-linear and the gradients have to be numerically computed. Every function evaluation ...
user avatar
15 votes
2 answers
2k views

Is it possible to use the LevenbergMarquardt algorithm for fitting a black-box residual function?

I have a black-box multiargument multiparametric function of the type SRD[dataPoint_List,params_List] which accepts experimental data along with the parameters of ...
user avatar
14 votes
3 answers
2k views

Strategies to avoid LessEqual::nord in NMinimize?

When using NMinimize on functions with complex intermediate expressions (but a real end result), quite often one gets the error ...
user avatar
  • 18.8k
14 votes
1 answer
7k views

Methods for NonlinearModelFit

I am using NonlinearModelFit for a thesis project. I get quite different results if I change the Method to LevenbergMarquardt or QuasiNewton or ConjugateGradient ...
user avatar
  • 1,163
14 votes
1 answer
758 views

Minimizing with differential evolution

A differential evolution algorithm is given here. I would like to get this kind of animation. I thought I could use NMinimize, given ...
user avatar
14 votes
1 answer
2k views

How to speed up Minimum Spanning Tree algorithm?

How to speed up MST algorithm? I work with graphs and I have adopted Prim's algorithm for my needs, from here. The graphs which I use are very dense (number of vertexes: $V=500$ and every vertex is ...
user avatar
  • 433
14 votes
1 answer
339 views

Advanced usage of BayesianMaximization?

There’s an example in the docs for BayesianMaximization for optimizing two suboptions of a classifier with a fixed method. I would like to optimize over multiple options for Method and their various ...
user avatar
  • 3,731
13 votes
9 answers
5k views

Finding maximum or minimum of implicit functions

is there any built in function that can be used to find maximum or minimum of implicit functions? For example, if we have the equation $$x^2 + y^2 = (2 x^2 + 2 y^2 - x)^2,$$ then we can visualize the ...
user avatar
13 votes
1 answer
1k views

How trustworthy is NMaximize?

Suppose I solve a constrained optimisation problem using NMaximize. How confident can I be of the accuracy of the result? For concreteness, suppose that F,G are (...
user avatar
13 votes
1 answer
3k views

Lagrange Multiplier

We are asked to maximize and minimize $f(x,y)=4xy$, given the constraint $4x^2+y^2=8$, using the Lagrange Multiplier method. First, I enter the functions f and g. ...
user avatar
  • 14.5k
13 votes
1 answer
1k views

Fitting Vogel's formula for phyllotaxis to the image of a flower

After having read this question I was inspired to investigate how we could take an image of a plant displaying phyllotaxis and fit Vogel's model of phyllotaxis to the image. The theory is very simple. ...
user avatar
  • 68.8k
13 votes
4 answers
536 views

How can I efficiently check if a graph is unit distance?

A unit distance graph is a graph that is embeddable in the plane so that every edge has length 1. ...
user avatar
  • 30.4k
12 votes
10 answers
2k views

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

Given a list of integers, find the largest sum of a contiguous sub-sequence. {1, 2, 3, 4, 5, -1, 7, -4, -2} (* 21 *) And print the sub-array which is ...
user avatar

1
2 3 4 5
39