How to convert quadratic to linear program?

Models in this form are actually called bilinear optimization problems. The typical approach to linearizing bilinear terms is through something called the McCormick envelope. Consider variables x and y, where you want x*y in the objective of your maximization problem. If we assume x and y are bounded by xL <= x <= xU and … Read more

mathematical optimization library for Java — free or open source recommendations? [closed]

A good answer is dependent on what you mean by “convex” and “more general” If you are trying to solve large or challenging linear or convex-quadratic optimization problems (especially with a discrete component to them), then it’s hard to beat the main commercial solvers, gurobi, cplex and Dash unless money is a big issue for … Read more

pandas, melt, unmelt preserve index

You need preserve index values by reset_index and parameter id_vars: df2 = pd.melt(df.reset_index(), id_vars=”index”,value_vars=[‘asset1′,’asset2′]) print (df2) index variable value 0 coper1 asset1 1 1 coper2 asset1 3 2 coper3 asset1 5 3 coper1 asset2 2 4 coper2 asset2 4 5 coper3 asset2 6 Then pivot working nice: print(df2.pivot(index=’index’,columns=”variable”, values=”value”)) variable asset1 asset2 index coper1 1 … Read more

Python Mixed Integer Linear Programming

Pulp is a python modeling interface that hooks up to solvers like CBC(open source), CPLEX (commercial), Gurobi(commercial), XPRESS-MP(commercial) and YALMIP(open source). You can also use Pyomo to model the optimization problem and then call an external solver, namely CPLEX, Gurobi GLPK and the AMPL solver library. You can also call GLPK from GLPK/Python, PyGLPK or … Read more