Questions tagged [minimization]

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.

529 questions
106
votes
19 answers

Knight's Shortest Path on Chessboard

I've been practicing for an upcoming programming competition and I have stumbled across a question that I am just completely bewildered at. However, I feel as though it's a concept I should learn now rather than cross my fingers that it never comes…
Kyle Hughes
  • 1,369
  • 3
  • 14
  • 13
47
votes
11 answers

Algorithm for ordering data so that neighbor elements are as identical as possible

I have a (potentially large) list data of 3-tuples of small non-negative integers, like data = [ (1, 0, 5), (2, 4, 2), (3, 2, 1), (4, 3, 4), (3, 3, 1), (1, 2, 2), (4, 0, 3), (0, 3, 5), (1, 5, 1), (1, 5,…
jmd_dk
  • 12,125
  • 9
  • 63
  • 94
15
votes
10 answers

Dependency Algorithm - find a minimum set of packages to install

I'm working on an algorithm which goal is to find a minimum set of packages to install package "X". I'll explain better with an example: X depends on A and (E or C) A depends on E and (H or Y) E depends on B and (Z or Y) C depends on (A or K) H…
KLi
  • 308
  • 3
  • 9
14
votes
4 answers

R optimization with equality and inequality constraints

I am trying to find the local minimum of a function, and the parameters have a fixed sum. For example, Fx = 10 - 5x1 + 2x2 - x3 and the conditions are as follows, x1 + x2 + x3 = 15 (x1,x2,x3) >= 0 Where the sum of x1, x2, and x3 have a known value,…
Scott Worland
  • 1,352
  • 1
  • 12
  • 15
12
votes
2 answers

How to choose proper method for scipy.optimize.minimize?

I was wondering how I can choose the best minimization method for scipy.optimize.minimize and how different the results may be? I am trying to minimize the following expression (solve for g): |a1.g.x + a2.g.x^3 - K|
Shannon
  • 985
  • 3
  • 11
  • 25
12
votes
7 answers

How to find minimum of nonlinear, multivariate function using Newton's method (code not linear algebra)

I'm trying to do some parameter estimation and want to choose parameter estimates that minimize the square error in a predicted equation over about 30 variables. If the equation were linear, I would just compute the 30 partial derivatives, set them…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
10
votes
8 answers

Can a neural network be used to find a functions minimum(a)?

I had been interested in neural networks for a bit and thought about using one in python for a light project that compares various minimization techniques in a time domain (which is fastest). Then I realized I didn't even know if a NN is good for…
9
votes
1 answer

Find maximum/minimum of a 1d interpolated function

I have a set of data which I am interpolating with kind = 'cubic'. I would like to find the maximum of this cubic interpolation function. Currently what I am doing is just find the maximum value in the array of interpolated data, but I was…
SuperCiocia
  • 1,823
  • 6
  • 23
  • 40
8
votes
2 answers

Android, ProGuard, and keepclasseswithmembernames

A common pattern in ProGuard configs for Android applications is to preserve custom View classes, since they are probably referenced only from layout XML instead of application code. Upon project creation, the ADT therefore add these rules to a…
mxk
  • 43,056
  • 28
  • 105
  • 132
8
votes
2 answers

Faster/more efficient alternatives to Ruby's Marshal?

I'm looking for a drop-in replacement of Ruby's Marshal capability, which hopefully has one or more of the following advantages over Marshal: faster serialization/deserialization more concise (or simply smaller) object-graph Thanks!!
Joseph Weissman
  • 5,697
  • 5
  • 46
  • 75
8
votes
4 answers

Minimizing a multivariable function with scipy. Derivative not known

I have a function which is actually a call to another program (some Fortran code). When I call this function (run_moog) I can parse 4 variables, and it returns 6 values. These values should all be close to 0 (in order to minimize). However, I…
7
votes
1 answer

SciPy optimizer ignores one of the constraints

I am trying to solve an optimization problem where I need to create a portfolio that with a minimum tracking error from benchmark portfolio and it's subject to some constraints: import scipy.optimize as opt import numpy as np def…
7
votes
1 answer

Solving a bounded non-linear minimization with scipy in python

Trying to solve a simple non linear minimization problem with one variable. from scipy.optimize import minimize import math alpha = 0.05 waiting = 50 mean_period = 50 neighborhood_size = 5 def my_func(w): return -(2/(w+1) +…
George
  • 774
  • 2
  • 9
  • 18
7
votes
1 answer

PyMinuit vs IMinuit

I was looking for a minuit equivalent on Python 2.7 and I found this two variants: PyMinuit and iMinuit. My question is: what's the difference between them? Both uses Seal 1.7.9 Minuit and in a few 2D Gaussian fit tests that I had both brought the…
pekapa
  • 881
  • 1
  • 11
  • 25
6
votes
2 answers

scipy.optimize get's trapped in local minima. What can I do?

from numpy import *; from scipy.optimize import *; from math import * def f(X): x=X[0]; y=X[1] return x**4-3.5*x**3-2*x**2+12*x+y**2-2*y bnds = ((1,5), (0, 2)) min_test = minimize(f,[1,0.1], bounds = bnds); print(min_test.x) My…
Kim
  • 159
  • 3
  • 11
1
2 3
35 36