Minimization is a subclass of mathematical optimization where given a cost or objective function, the goal is to choose the best set of parameters that will minimize the value given by this function.
Questions tagged [minimization]
457 questions
3
votes
1 answer
Minimum cost of swapping chars in string so no 3 same are consecutive
I have a string containing only two char values: 'a' or 'b'. A char can be swapped in for the other char value. Each char in the string has an associated cost with swapping it. I need to find the minimum cost of swaps such that there are no 3…
![](../../users/profiles/5393006.webp)
Tom Finet
- 405
- 1
- 5
- 14
3
votes
0 answers
How to create callable jacobian function for scipy minimize routine?
I can use scipy to perform minimization without using a callable jacobian. I would like to use the callable jacobian, but cannot figure out the correct structure of the output of such a function. I have checked online for examples; the similar…
user10121139
3
votes
2 answers
Use Tensorflow/PyTorch to speed up minimisation of a custom function
I do a lot of simulations, for which I often need to minimise complicated user-defined functions, for which I generally use numpy and scipy.optimize.minimize(). However, the problem with this is that I need to explicitly write down a gradient…
![](../../users/profiles/7250309.webp)
ap21
- 1,490
- 1
- 10
- 22
3
votes
1 answer
how to store the output of Minimization
I minimize a multivariable function in Mathematica using Minimization. It works fine. I want to pass the output of the Minimization to variables in order to use them ahead. But I am missing something. Let's see it (the Etet function is defined…
![](../../users/profiles/11274776.webp)
geom
- 169
- 7
3
votes
1 answer
Scheduling optimization to minimize the number of timeslots (with constraints)
I'm working on a scheduling optimization problem where we have a set of tasks that need to be completed within a certain timeframe.
Each task has a schedule that specifies a list of time slots when it can be performed. The schedule for each task can…
![](../../users/profiles/1831004.webp)
user1831004
- 47
- 6
3
votes
1 answer
Scipy minimize ignores constraint
I have the following code:
def constraint(params):
if abs(params[0] - 15) < 2 and abs(params[1] + 10) < 2:
return -1
else:
return 0
def f(params):
x, z = params
if abs(x - 15) < 2 and abs(z + 10) < 2:
return…
![](../../users/profiles/497132.webp)
artem
- 13,833
- 33
- 102
- 170
3
votes
1 answer
Dynamically fixing some variables when using fmincon
I have a MINLP objective function and I want to fix some variables value into constant as an example described below:
A = [1 1 1];
b = 30;
x1 = zeros(1,3);
y=1;
x = fmincon(@(x)objfun(x,y),x1,A,b);
function f = objfun(x,y)
x(y) = 1;
f = x(1)^2 +…
![](../../users/profiles/2290560.webp)
bnbfreak
- 343
- 3
- 12
3
votes
1 answer
fmincon with lower bound fails, even though solution is at initial point
I'm trying to minimize a non-linear objective function (my actual function is much more complicated than that, but I found that even this simple function illustrates the point), where I know that minimum is obtained at the initial point x0:
fun =…
![](../../users/profiles/666795.webp)
bonifaz
- 578
- 3
- 14
3
votes
1 answer
Matlab Curve Fitting via Optimization
I have tried to follow this tutorial to fit a curve to my dataset. The equation for the curve should be
f(t) = log10((wpmcoeff./(t.^2)) +
((1.038+3.*log(2.*pi.*1e6.*t)).*fpmcoeff./(t.^2))+(wfmcoeff./t) +
…
![](../../users/profiles/9369530.webp)
Bethany Baxter
- 31
- 4
3
votes
0 answers
Utilizing scipy.optimize.minimize with multiple variables of different shapes
I am curious is there is a straightforward method for utilizing scipy.optimize.minimize with multiple variables that take different shapes. For example, let's take a look at a matrix decomposition problem.
I apologize, but I will be using latex here…
![](../../users/profiles/5061557.webp)
Grr
- 13,093
- 6
- 53
- 71
3
votes
1 answer
Minimize error in homography matrix
I have a homgraphy matrix
[h1 h2 h3
h4 h5 h6
h7 h8 h9]
I have transformed a point
p1 to P1 using above homography matrix.
Similarly
p2 to P2
p3 to P3
p4 to P4
I know the diffence between
P1-P2 = D1
P2-P3 = D2
P3-P4 = D3
Due to…
![](../../users/profiles/3423045.webp)
Deepak
- 978
- 4
- 16
- 39
3
votes
0 answers
Equivalent of MATLAB's patternsearch in Python/SciPy?
I am looking for a Python equivalent of MATLAB's patternsearch optimization algorithm. I ran through the SCiPy documentation but did not find something similiar.
Do you know whether there is some patternsearch algorithm available in Python/SciPy? Do…
![](../../users/profiles/6654469.webp)
Sven Rüberg
- 131
- 3
3
votes
0 answers
scipy.optimize show all iteration input and output values
I am using scipy.optimize.minimize to find the optimum value from a function. Here is the simplest example, using the built-in Rosenbrock function:
>>> from scipy.optimize import minimize, rosen
>>> x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
>>> # Minimize…
![](../../users/profiles/1403604.webp)
feedMe
- 2,552
- 1
- 29
- 56
3
votes
2 answers
fminbnd doesn't give the minimum value
I'm trying some built-in functions in MATLAB. I declared a function like this:
function y = myFunction(x)
y = cos(4*x) .* sin(10*x) .* exp(-abs(x));
end
Then I use fminbnd to find the minimum value:
fminbnd(@myFunction,-pi,pi)
This gives me…
![](../../users/profiles/2241766.webp)
lenhhoxung
- 2,118
- 2
- 23
- 49
3
votes
1 answer
Loops to minimize function of arrays in python
I have some large arrays each with i elements, call them X, Y, Z, for which I need to find some values a, b--where a and b are real numbers between 0 and 1--such that, for the following functions,
r = X - a*Y - b*Z
r_av = Sum(r)/i
rms = Sum((r -…
![](../../users/profiles/3059201.webp)
user3059201
- 675
- 2
- 7
- 11