quadratic-programming

TypeError: 'float' object cannot be interpreted as an integer with solve_qp in python

ε祈祈猫儿з 提交于 2021-01-29 08:28:14
问题 I am new to optimization using python and I have a problem with using the predefined function solve_qp from qpsolvers to find the optimize solution of my problems here is my code: import numpy as np X = np.array([1., 2., 4., 6., 9.]).reshape(5, 1) y = 0.5 + (0.3*X) + np.random.randn(5,1) from qpsolvers import solve_qp P = np.dot(X.T,X) q = np.transpose(-2*np.dot(X.T,y))[0] G = None h = None A = None b = None sol = solve_qp(P, q, G, h, A, b) I got error with the predefined function TypeError:

Best linearization for p-dispersion (maxmin) problem?

元气小坏坏 提交于 2020-01-06 03:53:05
问题 Partially related to my other question here. In my case the 'original' aim was to choose n=50 objects out of N=292, such that the sum of all pairwise distances between the chosen objects is maximized (maxsum or p-dispersion sum). Thanks to the users who provided advice, I did some further reading, and now I understand that the problem is indeed quadratic in its simplest form, and a solver like CPLEX may be able to solve it. However, this article by Kuby points out that the maxsum results does

How to convert quadratic to linear program?

醉酒当歌 提交于 2019-12-18 02:46:40
问题 I have an optimization problem that has in the objective function 2 multiplied variables, making the model quadratic. I am currently using zimpl, to parse the model, and glpk to solve it. As they don't support quadratic programming, I would need to convert this to an MILP. . The first variable is real, in range [0, 1], the second one is real, from range 0 to inf. This one could without a problem be integer. The critical part in the objective function looks like this: max ... + var1 * var2 + .

Minimizing quadratic function subject to norm inequality constraint

杀马特。学长 韩版系。学妹 提交于 2019-12-12 07:24:00
问题 I am trying to solve the following inequality constraint: Given time-series data for N stocks, I am trying to construct a portfolio weight vector to minimize the variance of the returns. the objective function: min w^{T}\sum w s.t. e_{n}^{T}w=1 \left \| w \right \|\leq C where w is the vector of weights, \sum is the covariance matrix, e_{n}^{T} is a vector of ones, C is a constant. Where the second constraint ( \left \| w \right \| ) is an inequality constraint (2-norm of the weights). I

scipy.optimize.minimize (COBYLA and SLSQP) ignores constraints initiated within for loop

大城市里の小女人 提交于 2019-12-07 12:46:14
问题 I'm using scipy.optimize.minimize to solve a complex reservoir optimization model (SQSLP and COBYLA as the problem is constrained by both bounds and constraint equations). There is one decision variable per day (storage), and releases from the reservoir are calculated as a function of change in storage, within the objective function. Penalties based on releases and storage penalties are then applied with the goal of minimizing penalties (the objective function is a summation of all penalties)

How to use R package Quadprog to solve SVM?

耗尽温柔 提交于 2019-12-07 11:08:48
问题 I was wondering what's the proper way to implement Quadprog to solve quadratic programming. I have the following question(ripped from the internet)and also was looking at the following http://cbio.ensmp.fr/~thocking/mines-course/2011-04-01-svm/svm-qp.pdf What would be the proper way to solve this issue? Would this tutorial be useful to solve if i was given a question like above? http://www.r-bloggers.com/solving-quadratic-progams-with-rs-quadprog-package/ 回答1: Here is an implementation, for

Optimisation in swi prolog

荒凉一梦 提交于 2019-12-07 06:22:42
问题 Say I want to find argmax(x,y,z) -1/2(20x^2+32xy +16y^2)+2x+2y. subject to: x>=0, y>=0,z>=0 and -x-y+z =0. I know the partial derivatives being set to 0 is : -20x-16y+2=0 and -16x-16y+2 =0 so we could have x= 0 and y =1/8 and z=1/8. How would I do this in Swi-prolog? I see that there is library simplex for linear solving, but this is a quadratic problem but the partial derivatives are not. (I am a bit confused!) This is what I have: :- use_module(library(simplex)). my_constraints(S):- gen

scipy.optimize.minimize (COBYLA and SLSQP) ignores constraints initiated within for loop

给你一囗甜甜゛ 提交于 2019-12-06 03:43:53
I'm using scipy.optimize.minimize to solve a complex reservoir optimization model (SQSLP and COBYLA as the problem is constrained by both bounds and constraint equations). There is one decision variable per day (storage), and releases from the reservoir are calculated as a function of change in storage, within the objective function. Penalties based on releases and storage penalties are then applied with the goal of minimizing penalties (the objective function is a summation of all penalties). I've added some constraints within this model to limit the change in storage to the physical system

Minimize quadratic function subject to linear equality constraints with SciPy

混江龙づ霸主 提交于 2019-12-05 21:54:39
问题 I have a reasonably simple constrained optimization problem but get different answers depending on how I do it. Let's get the import and a pretty print function out of the way first: import numpy as np from scipy.optimize import minimize, LinearConstraint, NonlinearConstraint, SR1 def print_res( res, label ): print("\n\n ***** ", label, " ***** \n") print(res.message) print("obj func value at solution", obj_func(res.x)) print("starting values: ", x0) print("ending values: ", res.x.astype(int)

How to use R package Quadprog to solve SVM?

坚强是说给别人听的谎言 提交于 2019-12-05 17:35:53
I was wondering what's the proper way to implement Quadprog to solve quadratic programming. I have the following question(ripped from the internet)and also was looking at the following http://cbio.ensmp.fr/~thocking/mines-course/2011-04-01-svm/svm-qp.pdf What would be the proper way to solve this issue? Would this tutorial be useful to solve if i was given a question like above? http://www.r-bloggers.com/solving-quadratic-progams-with-rs-quadprog-package/ Here is an implementation, for linear C-SVM, which is based on the primal optimization problem: min_{beta_0, beta, zeta} 1/2 w^T w + C sum_