mathematical-optimization

how to sample/group rows of dataframe to fix specific distributions within a group?

how to sample/group rows of dataframe to fix specific distributions within a group? Question: I have a DataFrame c containing a columns a. import numpy as np a = np.random.randint(0,10, size=(100)) c = pd.DataFrame(a, columns=[‘a’]) I want to make random grouping of the rows of c such that there are 5 rows within each group …

Total answers: 1

Can scipy.optimize minimize functions of complex variables at all and how?

Can scipy.optimize minimize functions of complex variables at all and how? Question: I am trying to minimize a function of a complex (vector) variable using scipy.optimize. My results so far indicate that it may not be possible. To investigate the problem, I have implemented a simple example – minimize the 2-norm of a complex vector …

Total answers: 2

Fastest way to compute e^x?

Fastest way to compute e^x? Question: What is the fastest way to compute e^x, given x can be a floating point value. Right now I have used the python’s math library to compute this, below is the complete code where in result = -0.490631 + 0.774275 * math.exp(0.474907 * sum) is the main logic, rest …

Total answers: 1

PuLP not printing output on IPython cell

PuLP not printing output on IPython cell Question: I am using PuLP and IPython/Jupyter Notebook for a project. I have the following cell of code: import pulp model = pulp.LpProblem(‘Example’, pulp.LpMinimize) x1 = pulp.LpVariable(‘x1′, lowBound=0, cat=’Integer’) x2 = pulp.LpVariable(‘x2′, lowBound=0, cat=’Integer’) model += -2*x1 – 3*x2 model += x1 + 2*x2 <= 7 model += …

Total answers: 2

Optimize a function in scipy without explicitly defining the gradient

Optimize a function in scipy without explicitly defining the gradient Question: I’m currently trying to optimize a function using scipy. I have some constraints on the variables, and from this link: http://docs.scipy.org/doc/scipy-0.14.0/reference/tutorial/optimize.html, it looks like SLSQP is exactly what I want. In their example, they have a well defined explicit formula for the result in …

Total answers: 2

Python constrained non-linear optimization

Python constrained non-linear optimization Question: What’s the recommended package for constrained non-linear optimization in python ? The specific problem I’m trying to solve is this: I have an unknown X (Nx1), I have M (Nx1) u vectors and M (NxN) s matrices. max [5th percentile of (ui_T*X), i in 1 to M] st 0<=X<=1 and …

Total answers: 4

Quadratic Program (QP) Solver that only depends on NumPy/SciPy?

Quadratic Program (QP) Solver that only depends on NumPy/SciPy? Question: I would like students to solve a quadratic program in an assignment without them having to install extra software like cvxopt etc. Is there a python implementation available that only depends on NumPy/SciPy? Asked By: flxb || Source Answers: I’m not very familiar with quadratic …

Total answers: 5