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
2
votes
0answers
67 views

Approximate integer factorization

Suppose we would like to compute an approximate prime factorization of a large integer x in the sense that the difference between ...
0
votes
1answer
48 views

Maximization under constraints / find maxima

I am trying to code the following maximization program that I am not able to solve algebraically (Of course I manage to get the first derivative, but struggle finding its root): $\begin{equation} Max_{...
7
votes
1answer
110 views

Kronecker Square Roots

I'm interested in computing the 'Kronecker Square Root' $\mathbf{A}_{n\times n}$ of a matrix $\mathbf{M}_{n^2\times n^2}=\mathbf{A}\otimes\mathbf{A}$. In case it doesn't exist, I'd like to find the ...
0
votes
1answer
45 views

Minimizing a function over a bounded domain with binary variables

I want to minimize the following function: $$ f(m,n)= \sum_{i=1}^N\Big\{ \alpha_i(x_i-m)^T(x_i-m) \Big\} + \sum_{i=1}^N\Big\{\beta_i (x_i-n)^T(x_i-n) \Big\} $$ where $m,n$ are all 2-d vectors: $$ m:= ...
1
vote
1answer
64 views

Maximization of piecewise function

I'm trying to maximize piecewise functions with parameters but haven't been able to do so. Here is a minimum example: ...
0
votes
0answers
21 views

General::munfl - Precision lost in LinearModelFit

I am new to mathematica so I am confused regarding the loss of precision in LinearModelFit. In building a linear model with uora (1 or 2) and encodeSeverity (1,2 or 3) ...
0
votes
2answers
69 views

NMinimize over a list of integers

I'd like to minimize some function (of 3-4 variables) over a big list of integers, but not consecutive. Like arr = {5, 10, 7, 101,...} I did not understand this ...
0
votes
1answer
37 views

Trouble using NMinimize [closed]

I am trying to minimize five function at the same time. I am running in some trouble minimizing this function, as since I am not that familiar with Mathematica I really do not know what I am doing ...
0
votes
1answer
100 views

FindMaximum not working with ParametricNDSolve

I have the following code (ignore the manipulate parameters, assume them constant in this context). For background, what I'm trying to do is take the results of a 2D differential equation, find where ...
0
votes
0answers
39 views

Low Tolerance making wrong behavior of LinearProgramming?

I was working on a code that needs to check feasibility of LP problems. I visited Checking linear program feasibility? and used the code. With this code, since there is 1 at the last position at every ...
8
votes
1answer
155 views

Optimize a network topology?

I'd like to know if one can use optimization function like Maximize[] or BayesianMaximize[] to optimize the hyper-parameters of ...
0
votes
2answers
102 views

How to solve a nonlinear system of equations with exponential terms

I want to solve this parametric nonlinear system of equations in Mathematica: $$x−1−(e^{a−x}+e^{b−y})/(c+e^{b−y})=0$$ $$y−1−(e^{b−y})/(c+e^{a−x})=0$$ and I used this code: ...
12
votes
1answer
325 views

Bug in NMaximize in 12.2?

Bug introduced in 12.2, Fixed in 12.3 Something changed in NMaximze in v12.2: ...
2
votes
1answer
46 views

Stop Minimization after condition

I want to interrupt the optimization of a function when a particular condition is satisfied. Here I provide a test function. ...
1
vote
2answers
131 views

Is there a way to do this more efficiently?

I'm trying to write this Mathematica function to find the optimal price for a model, given some model parameters. This is a stylized example of what I'm trying to do, and I'm wondering what's a better ...
0
votes
2answers
174 views

Is it possible to calculate the desired area analytically?

I have the three two-variable curves $f,g,h$ with $0\leq x\leq \frac {\pi}{2} $ and $0 \leq y \leq \pi$ I use ContourPlot as ...
0
votes
1answer
79 views

What has Maximize been thinking about for so long?

The command Maximize[{Sqrt[2 x + 13] + (3 y + 5)^(1/3) + (8 z + 12)^(1/4), x + y + z == 3&&{x,y,z} >= 0}, {x, y, z}] is running without any response on ...
0
votes
1answer
23 views

NMaximize giving error when trying to find global maximum [closed]

I've been trying to use mathematica to find the maximum of 1/(1 + e^(-(x - 9))) + 1/(1 + e^(-(y - 9)) where x>0,y>0 and x+y=100. This is the code I've been using: ...
0
votes
1answer
49 views

How to force NMinimize to find the correct global minimum for equation with many local minima?

I have a function that I am unable to recover a solution for. Here, 0.533... and 0.428... are the exact solutions for Rs[399] and ...
1
vote
1answer
110 views

RegionPlot of the Maximum of a function

For the function fun[a_, b_, x_, y_] = Sin[a x] Cos[b y] (a x + b y);corresponding to $x$ and $y$, I need a RegionPlot showing the maximum of function $fun[a, b, x, ...
0
votes
0answers
19 views

NArgMin “function value is not a number” error

The "function value is not a number" type error seems fairly common. Forgive me, but I can't seem to fix my issue using some of the other posts on this site. I'm working on a problem where I ...
0
votes
0answers
28 views

Evaluating function of two variables inside NMinimize with respect to second argument

Consider three functions: f[t_, 1] := {Cos[t], 1, 0} f[t_, 2] := {Sin[2 t], 1, 0} f[t_, 3] := {Cos[t - 2], 1, 0} For each $k=1,2,3$, let $g(\cdot,k)$ be the ...
0
votes
1answer
75 views

How to derive all KKT points of a parametric optimization problem

Suppose we have a symbolic optimization problem where all parameters and decision variables are nonnegative like the following problem. I would be thankful to know if there is any method to find all (...
0
votes
0answers
59 views

Calculating my code for higher values of `k`?

How do I calculate the mean of A for higher values of k ...
4
votes
1answer
126 views

MaxCut SDP primal in mathematica

How could one formulate the primal SDP for MaxCut in Mathematica. I am aware of this tutorial using the dual: https://www.wolfram.com/language/12/convex-optimization/max-cut-problem.html?product=...
7
votes
3answers
359 views

Speed up minimization of a high-degree polynomial

For fixed $s$ and $n$, I need to find $\alpha$ which minimizes the following expression $$h (I-2\alpha H + 2\alpha^2 H + \alpha^2 \mathcal{H})^s x0$$ where $$ \begin{array}{lll} h&=&(1,\frac{1}...
18
votes
2answers
1k 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 ...
1
vote
0answers
30 views

Why do I get the (NMinimize::nrnum) error and how to fix it?

I have an energy function which depends on the angles of the electrons({x} symbol for theta) and phase of electrons({y} symbol for phi). I am using NMinimize to minimize the energy with respect to {x}...
5
votes
4answers
147 views

Are there any alternatives for NIntegrate to calculate the area for which $f(x,y)<0$?

I have this two-variable function $$f(x,y)= (8 \cos (x+y)+7)\cos \left(\frac{x}{2}\right)+\cos \frac{x-2 y}{2}+2 \cos \left(\frac{3 x}{2}\right) $$ where $0<x,y<\pi$. I want to calculate ...
18
votes
3answers
1k 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 ...
10
votes
2answers
175 views

Low Rank Matrix Completion

Matrix completion is the task of filling in the values of a partially observed matrix. The mathematical jargon is a bit heavy, but the code is relatively straightforward, and the result is well worth ...
0
votes
1answer
51 views

Integral with exponential function

Could you please help me in solving the following integration. Thank you in advance. Integrate[((Sqrt[g*(x + h)/y])^V) * Exp[-u * Sqrt[g*(x + h)/y]/n] * Exp[-L*x], {x, 0, Infinity}]
0
votes
1answer
63 views

Portfolio optimization

Mathematica provides codes for a portfolio optimization https://www.wolframcloud.com/objects/summerschool/pages/2017/AndresLopezMartinez_TE that do not work anymore. Any reason why? I have been trying ...
0
votes
0answers
16 views

Using FindArgMax in NSolve with dependant variables

I have a function for a current through a series circuit containing a capacitor(c) and a resistor(r) and a battery(Ebatt) when the capacity increases from c0 to c. ...
0
votes
0answers
63 views

Simplify a heavy calculation

I'm aware that this may be regarded as too non-specific and with too little information, but I hope that someone will be able to help me nonetheless or to request information which would be imperative ...
2
votes
2answers
66 views

Can't find parameter with findFit NMinimize

I have a data list and a function being to be fitted to the data to get parameters of the function as below. I can't find the parameters a, b, c, d with different below methods. Can you help me to ...
0
votes
1answer
41 views

ArgMax : Variable Domain Error [closed]

I'm attempting to utilize the ArgMax function, but am receiving the error "ArgMax::vdom: Variable domain ... should be either Reals or Integers." ...
1
vote
1answer
58 views

LinearOptimization duality

I'm solving a linear program using LinearOptimization. I'm curious why "DualityGap" does not return zero (as described in the docs). Here's the code: ...
1
vote
1answer
112 views

Tuning the optimal control synthesized according to the Pontryagin maximum/minimum principle and choosing the cost function

I continue to study the topic I started here: Problem with optimal control and Pontryagin's maximum principle A simple ODE system $(1)$ is given: $F=\begin{cases} \dot{x}=g \\ \dot{g}=-g+\frac{df}{...
1
vote
1answer
76 views

Plot “Findroot” with very complex variables

I ran into an extremely complex "zero problem" and don't know how to solve and plot it. Can anyone help with this, please? [Pi]s and [Pi]r are objective functions, pd, po, qd, qo, and [Phi] (...
0
votes
0answers
71 views

NMinimize for searching global minimum

I have been trying to find global minimum for this equation for some time now. The equation is quite easy to understand. It is made with sumation of stress equations of points on the border where $σ_{...
0
votes
1answer
57 views
0
votes
2answers
107 views

How to get mathematica to give an exact answer rather than a numerical approx

I tried // Rationalize but it just gave the same answer Please help
2
votes
1answer
49 views

How to use parts of expression as variables in Minimize (NMinimize )?

I want to solve some optimization problem involving matrices. A toy example related to the problem looks as follows ...
2
votes
1answer
60 views

Finding the maximum value from the roots of a solution when there is an ambiguity

I have a variable x = l*Cos[t]*Cos[a] - Sin[t]*Sin[a] and I want to find the maximum value of x with respect to a, as well as access the roots. I have tried ...
1
vote
1answer
43 views

Nominal variables in LinearModelFit must be specified before continuous variables

I am applying the LinearModelFit to a 90 x 5 matrix, in which the 4th variable is a nominal variable (i.e., x4 is a categorical ...
5
votes
1answer
102 views

Is there a better way to simulate quadratic cost MPC problems?

Question I would like to know if there is a more straightforward or a better way to simulate MPC problems in terms of code length and accuracy as compared to what I am doing. I am looking to know if ...
2
votes
0answers
53 views

How to find the regions for which the derivative of my function changes sign?

I have an energy function of the angles of the electrons' spins. th1 is vector with (2l+2) elements and each element represents the angle of an individual electron spin. I need to eventually find the ...

1
2 3 4 5
35