mathematical-optimization

constrained nonlinear optimization in Microsoft Solver foundation vs Matlab fmincon

烂漫一生 提交于 2019-12-02 21:00:51
can anyone show me examples or reviews for constrained nonlinear optimization in Microsoft Solver foundation 3.0? How's it compared to Matlab's fmincon? Or is there any better .net library for constrained nonlinear optimization? thanks, Yin Zhu IMPORTANT UPDATE on Feb 25, 2012: MSF 3.1 now supports nonlinear optimization with bounded variables via its NelderMeadSolver solver: http://msdn.microsoft.com/en-us/library/hh404037(v=vs.93).aspx For general linear constraints, Microsoft solver foundation only support linear programming and quadratic programming via its interior point solver. For this

How is a conditional summation possible in Cplex? like sumifs in Excel?

扶醉桌前 提交于 2019-12-02 18:01:38
问题 I want to sum all used resources among times in my model (it's rcpsp model) how can I do it in CPLEX? at first I wrote this: forall(k in K) forall(t in 1..f[nAct]) sum(i in I:f[i]-d[i]<=t-1 && t<=f[i]) r[i,k] <= aR[k]; (note: K is a range for resources, nAct is number of activities, f[i] is an array dvar and indicates finishing time of activity i, d[i] is duration of i,r[i,k] is required resource of k for activity i and aR[k] is available resources of k.) The problem is that the cplex doesn't

What is the logic of this process

為{幸葍}努か 提交于 2019-12-02 13:03:09
问题 I was working on a problem in Project Euler; and I found a question in SO. The question and accepted answer says; n = 600851475143 i = 2 while i * i < n: while n%i == 0: n = n / i i = i + 1 print (n) It's just awesome. I still can't understand how this process is so fast and can find the largest prime factor of 600billion in 0.00001 seconds. I tried tons of methods and codes for that, processes took over than 1 hour.. Could anyone explain me the logic of this codes and why it's super-fast? is

Constant term in objective for quadratic program with CPLEX?

爷,独闯天下 提交于 2019-12-02 08:41:20
问题 I'm using CPLEX 12.5.0.0 via the C# API. Until now, I've never had a situation with an objective with a constant term - only constraints. With constraints, I have always been able to re-arrange the equation so the constant is always on one side, meaning each ILinearNumExpr has no constant term on its own. Now I have a quadratic programming problem, with an objective of the following type: MAX Z = c[1,2] * a[1] * a[2] - c[1,2] * (1 - a[1] * a[2]) + c[1,3] * a[1] * a[3] - c[1,2] * (1 - a[1] * a

Pass Pandas DataFrame to Scipy.optimize.curve_fit

♀尐吖头ヾ 提交于 2019-12-02 07:20:35
问题 I'd like to know the best way to use Scipy to fit Pandas DataFrame columns. If I have a data table (Pandas DataFrame) with columns ( A , B , C , D and Z_real ) where Z depends on A, B, C and D, I want to fit a function of each DataFrame row (Series) which makes a prediction for Z ( Z_pred ). The signature of each function to fit is func(series, param_1, param_2...) where series is the Pandas Series corresponding to each row of the DataFrame. I use the Pandas Series so that different functions

data fitting an ellipse in 3D space

倾然丶 夕夏残阳落幕 提交于 2019-12-02 05:24:55
Forum I've got a set of data that apparently forms an ellipse in 3D space (not an ellipsoid, but a curve in 3D). Being inspired by following thread http://au.mathworks.com/matlabcentral/newsreader/view_thread/65773 and with the help from someone ,I manage to get the optimization code running and outputs a set of best parameters x (vector). However, when I try to use this x to replicate the ellipse,the outcomes is a strange straight line in the space. I have been stacked on this for days., still don't know what went wrong....pretty much devastated... I hope someone can shed some light on this.

Pass Pandas DataFrame to Scipy.optimize.curve_fit

六眼飞鱼酱① 提交于 2019-12-02 04:52:21
I'd like to know the best way to use Scipy to fit Pandas DataFrame columns. If I have a data table (Pandas DataFrame) with columns ( A , B , C , D and Z_real ) where Z depends on A, B, C and D, I want to fit a function of each DataFrame row (Series) which makes a prediction for Z ( Z_pred ). The signature of each function to fit is func(series, param_1, param_2...) where series is the Pandas Series corresponding to each row of the DataFrame. I use the Pandas Series so that different functions can use different combinations of columns. I've tried passing the DataFrame to scipy.optimize.curve

Maximizing linear objective subject to quadratic constraints

社会主义新天地 提交于 2019-12-02 04:27:41
I have a programming formulation from a paper and want to give it a tool for solving specific problems. The authors stated it as an linear programming (LP) instance, however I am not sure. Formulation is somewhat like as follows: max x1+x2+x3... s.t. x1.x3+x4.x5 <= 10 x2.x5+x3.x7+x1.x9 <=10 ... I tried to program it through cplexqcp function (due to quadratic constraints, however constraints do not include any x_i^2 variable). However I receive CPLEX Error 5002: Q in %s is not positive semi-definite error . Is this an instance of non-linear programming with non-convex constraints? Can I solve

Method for finding strictly greater-than-zero solution for Python's Scipy Linear Programing

两盒软妹~` 提交于 2019-12-02 00:06:28
Scipy NNLS perform this: Solve argmin_x || Ax - b ||_2 for x>=0. What's the alternative way to do it if I seek strictly non-zero solution (i.e. x > 0 ) ? Here is my LP code using Scipy's NNLS: import numpy as np from numpy import array from scipy.optimize import nnls def by_nnls(A=None, B=None): """ Linear programming by NNLS """ #print "NOF row = ", A.shape[0] A = np.nan_to_num(A) B = np.nan_to_num(B) x, rnorm = nnls(A,B) x = x / x.sum() # print repr(x) return x B1 = array([ 22.133, 197.087, 84.344, 1.466, 3.974, 0.435, 8.291, 45.059, 5.755, 0.519, 0. , 30.272, 24.92 , 10.095]) A1 = array([[

Python scipy.optimize.fmin_l_bfgs_b error occurs

六眼飞鱼酱① 提交于 2019-12-02 00:02:13
My code is to implement an active learning algorithm, using L-BFGS optimization. I want to optimize four parameters: alpha , beta , w and gamma . However, when I run the code below, I got an error: optimLogitLBFGS = sp.optimize.fmin_l_bfgs_b(func, x0 = x0, args = (X,Y,Z), fprime = func_grad) File "C:\Python27\lib\site-packages\scipy\optimize\lbfgsb.py", line 188, in fmin_l_bfgs_b **opts) File "C:\Python27\lib\site-packages\scipy\optimize\lbfgsb.py", line 311, in _minimize_lbfgsb isave, dsave) _lbfgsb.error: failed in converting 7th argument ``g' of _lbfgsb.setulb to C/Fortran array 0-th