# Tag Info

49

Regardless of what completes the phrase "Python vs ...", the answer is always going to be Python. Very few people who are serious about using optimisation in production use MATLAB, and the ones who do can't wait to move away from it. As to why, there are plenty of reasons. MATLAB is: licensed closed source not object-oriented friendly, so it's a very bad ...

39

Despite being a great fan of Julia (and JuMP) I must admit that Python is most widely adopted in industry. I won't recommend PuLP however, which tends to be too slow. As alternatives, I would consider Pyomo is a great package, with various interesting extensions (for stochastic programming, MPEC, bilevel optimization, ...). Cvxpy is a game changer if you ...

19

The feed back we get from our customers at Mosek is Python is used extensively in the financial industry for doing portfolio optimization and lot of other operations. Those customers like to use Cvxpy or Mosek Fusion to interface the optimizer. You can see some Python notebooks at our Github tutorial page. This portfolio construction framework also provides ...

19

We use Julia in production for optimization at Invenia. We use Convex.jl, and JuMP.jl, and have found them to be excellent.

18

I agree with everything Nikos said and I add some colors to some of the reasons: Python is free and open-source but Matlab is not. Anyone can write codes in Python and share it with others who can easily run that code (as it's free software) but your Matlab codes can be run only by those who have a license. Just because Python is open-source and free, it ...

16

Nikos Kazazakis and EhsanK have given you great reasons for using Python. I will focus on the point from you about needing to use an additional package/library in Python for matrix and vector operations. In industry projects you will encounter many challenges and things you want to do, but you don't want to (and shouldn't) implement. Currently I work on a ...

14

Staffjoy was an early user of Julia and JuMP for their start up providing workforce scheduling. They also release all of their internal software as open-source after they shut-down. See for example the autoscheduler based on JuMP.

14

I work for a company that offers a commercial optimization solver. The solver offers interfaces to both MATLAB and Python for solving problems defined in those languages. We only get one or two queries about MATLAB interfacing with our product per year, but we get many times that amount of questions on interfacing Python with our product. Many bluechip and ...

13

I personnaly use Python for optimizing industrial problems every day. I know Polymathian also use Python for their Tropofy platform. GUROBI has a python API, which I think is quite popular (although I cannot prove it). I think that since Python is one of the most popular languages out there, mechanically it is used for optimization. However, I think it ...

13

My answer will be focused on teaching, and I'll give you my perspective from Georgia Tech ISyE. Yes, you should teach your students optimization using Python. For simple models, one simple open-source platform you could introduce is PuLP. It is solver-agnostic, and will work both with commercial solvers as well as open source (including COIN-OR stuff). For ...

12

Here is the complete implementation for the above-mentioned model. from gurobipy import * import numpy as np # Parameters needed are: # (1) the total number of jobs (n). Here I denote it by "NumofJobs" # (2) the total number of machines (m). Here I denote it by "NumofMachines" # (3) the processing times. Here I use a numpy matrix: "...

12

To get the value of the decision variable, you need to use the varValue property of the LpVariable, so: print(x.varValue) You can also use: print(x.value()) The explanation is that the Python variable x is not the decision variable itself, it is a PuLP object of type LpVariable: In[5]: type(x) Out[5]: pulp.pulp.LpVariable Therefore, just using print(x) ...

12

I don't know much about Python-mip but looking at the code, maximize expects a LinExpr, so I tried: model.objective = maximize(1*x) which gives the expected output. Edit: I also opened a PR to allow maximize(var) and minimize(var). Edit: The PR has been merged, this shouldn't be a problem in >1.7.2.

12

I can't address the specifics of Python, Pyomo, Gurobi or GAMS, but I can address the general question of using a modeling language (such as GAMS) versus building the model directly in a general programming language (such as Python) via a solver API. Models written in a modeling language (say GAMS) tend to be easier to read and easier to relate to a problem ...

11

Although I personally think Julia is glorious, nearly no-one outside academia uses it for numerous reasons, including: Missing out on all the Python packages Julia programmers being much harder to find than Python programmers, and Julia being much harder than Python to integrate to other things. JuMP can offer performance benefits, but for commercial use ...

11

Our, KLM, current optimizer products' codebases are all in python. The main reason for this is python is extremely powerful for fast prototyping. However, when it comes to the necessity of implementing more advanced techniques such as column generation and own branch-and-price algorithm, then python start lacking the performance you're looking for. In that ...

11

If you use packages like PyOMO, PuLP or pyOpt, you'd have to implement all the operations for multiobjective optimization - e.g. to find nondominated solutions or the different mutation operators - that could take some time. An alternative is using DEAP for that, it's a Python framework for evolutionary algorithm and they have NSGA-II implemented. It's quite ...

11

I like Stuart Mitchell's (maintainer of Pulp) tips, especially tip number 2 : use a profiler to track your bottlenecks. Quoting him: I can't tell you the number of times I have assumed the slow code was for one reason and then found it was another. I agree with him and use line_profiler to optimize the code (for Python). I have been able to drastically ...

11

Excel remains extensively used in industry for non-OR applications. That means that if you are doing an OR application that does not require access to a database, there's a good chance the data for the application will come to you in either an XLSX or CSV file. On the flip side, when it comes time to convey the solution provided by your application, it is ...

10

According to this link on Pyomo forum from 2016 about LP files, and this one from 2018 about MPS file, this functionality doesn't exist yet. To quote from the first link: LP files are “flat” representations of a model, and there really hasn’t been a strong motivation to import that into a structured system like Pyomo. It’s not impossible to write an LP ...

10

I'm not sure there is any "best way", but I can speak to personal practice (using Java, which is inherently object oriented). I will typically have one class that represents the "problem" (including data). If the data for the problem instance is drawn from an XML file, a text file, a database connection or whatever, I'll use a separate class for the data ...

10

As determined in the comment exchange to the question, because the matrix P has minimum eigenvalue which is negative, it is not positive semidefinite, and therefore it is a non-convex problem. Therefore, Mosek won't accept it, and as you have seen, provided an error message explaining why. Apparently, despite billing itself as a "software package for ...

10

The problem of enumerating all vertices of a polytope has been studied, see for example Generating All Vertices of a Polyhedron Is Hard by Khachiyan, Boros, Borys, Elbassioni & Gurvich (available free online at Springer's website) and A Survey and Comparison of Methods for Finding All Vertices of Convex Polyhedral Sets by T. H. Matheiss and D. S. Rubin. ...

9

It seems there are multiple problems, here... Python will not automatically find the script setup.py. You need to either specify the path to that script, or be in the directory where that script exists. Assuming that you installed CPLEX Optimization Studio in the default location, the following would work: python "c:\Program Files\IBM\ILOG\...

9

If the model in PuLP is: from pulp import LpProblem, LpVariable, LpMaximize, lpSum m = LpProblem(name='example', sense = LpMaximize) x = LpVariable.dicts(name='x',indexs=[1,2,3]) m += lpSum(x) <= 3, 'c1' m += lpSum(i*x[i] for i in [1,2,3]), 'obj' We can access the coefficient of $x_1$ in 'C1' with: m.constraints['c1'][x[1]] # This the coefficient => ...

9

Why quadratic? just use a larger (linear) weight for tasks assigned to worker 1.

9

Thanks to @Laurent Perron for their answer - I've tried modifying the code as follows, and it appears to work fine: from __future__ import print_function from ortools.constraint_solver import routing_enums_pb2 from ortools.constraint_solver import pywrapcp def create_data_model(): """Stores the data for the problem.""" data = {} data['...

9

Yes, Python is used in the industry is the simple answer. We are Optimeering Aqua and our sister company Optimeering use Python and the (Fico) Xpress Python- API. We were alpha and beta users. For us this has been working well. We very early on used Fico's Mosel language, but found moving to a general programming language to have lots of advantages, with ...

9

You could try changing the parameter mipfocus to 2 or 3 (https://www.gurobi.com/documentation/9.0/refman/mipfocus.html) in order to let Gurobi focus more on improving the bound or proving optimality. You can also try to set Cuts (https://www.gurobi.com/documentation/9.0/refman/cuts.html) to 2 in order to let Gurobi be more aggressive with the Cuts. But ...

9

If you have a recent enough version of Gurobi, there is a tuning tool that tries to find better parameter sets than the default settings. For best results, run it for a while (at least overnight) and run it with a few different instances of your problem. Here is some example code you can use to run it. def tune(model, time_limit=-1, trials_per_setting=3): ...

Only top voted, non community-wiki answers of a minimum length are eligible