I'm currently solving a shift assignment problem in OR-tools in Python, using a MIP solver, one employee at a time. For each seperate problem there is one employee and around 100 shifts. There are a lot of variables and constraints (few 1000's per employee). I've already looked in detail on how to improve each constraint, but no luck. Since the performance is really important, I wanted to further investigate the possibilities to adjust the search strategies, but no luck either. It seems that the documentation is sparse.
Can anyone help me by giving me some options to look into?
This is the solver I'm using:
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING
Thank you in advance. Let me know if there is any information I need to add here.
You are out of luck. There are no customisation available for the search through the linear solver wrapper.
I would suggest using the CP-SAT for this.
You can have a look at:
https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py
Related
I am currently trying to solve a difficult integer linear program using CPLEX with PuLP on Python.
I actually put a relative gap to the solver so that I get a solution in a shorter time. Here is the code line for the solving of my model :
solver = pulp.CPLEX_CMD(path=path_to_cplex, gapRel=0.003)
model.solve(solver)
model is my puLP.lpProblem
My problem is that in certain case, the solver returns an unfeasible error when I put a gap, so the solution is None. In this case, is there a way to get the last relaxed solution found by PuLP, so that I can at least use a "partially feasible" solution ?
Thanks by advance
I checked on the documentation of CPLEX_CMD with PuLP to see if there was an option to do what I want, but I did not find anything matching.
I am novice in Gurobi Language. I am trying to solve some LPs and MIPs using GurobiPy, so the approach I thought I would take was to look at some examples how to add constraints and all. But in the examples provided by Gurobi website, the actual documentation on how to add mathematical constraints to the model was like finding a needle in haystack. From my fellow seniors I would like to know how can I approach to learn to add constraints actually. Thank you. I already found some understanding, but there are things like sum( * , 1) etc which I don't really understand.
These tutorials can be a starting point:
https://www.gurobi.com/resource/abremod-getting-started-intro/
To get more help here on StackOverflow, please consider phrasing your question less broad and try to ask a specific question.
I was wondering if someone could give me some guidance in setting up my objective.
I am trying to minimise variance in python with some cardinality constraints on the number of assets in my portfolio. I am not sure what package would help me do this. And if there was a working example for the above.
Below is a MIQP model that illustrates how we can model a portfolio problem with the number assets limited to be between minAssets and maxAssets. If an asset is in the portfolio, furthermore its fraction is limited to be between fmin and fmax.
In this link you can also see how you can try to solve this problem with just a series of linear MIP problems.
MIQP solvers are readily available: CVXPY/ECOS_BB, Cplex, and Gurobi are a few examples. These are all callable from Python. A simple portfolio QP model would be a good starting point (no doubt such a model is available in the examples for any of these solvers).
You may have a look at some links, which are about python package CVXOPT:
https://cvxopt.org/examples/book/portfolio.html
https://scaron.info/blog/quadratic-programming-in-python.html
I apply optimization tool to solve pratical production planning problem.
My current problem is doing planning for a factory with various items in a unique production flow stage. In each stage, there are few parallel machines as graph below.
I have done maths MILP model, and try to solve by CPLEX but it too hard to handle the big scale model by itself.
Currently, I prepare to use Genetic Algorithm to solve it, but don't know where to start.
I have some knowdlege in Python Language. My friends, please advise how I start to deal with this problem?
Do someone have a similar solved problem with code, that I can have a reference?
Before you start writing code(or using someone else's) you must understand the theory behind the scene.
What are the main entities of your Production System?
You need to formulate optimization objectives,optimal schedule but defined in terms of optimization problem.
One example that comes to my mind
https://github.com/jpuigcerver/jsp-ga
Take a look at this thesis
http://lancet.mit.edu/~mbwall/phd/thesis/thesis.pdf
I have ran into a shape matching problem and one term which I read about is deterministic annealing. I want to use this method to convert discrete problems, e.g. travelling salesman problem to continuous problems which could assist of sticking in the local minima. I don't know whether there is already an implementation of this statistical method and also implementation of it seems a bit challenging for me because I couldn't completely understand what this method does and couldn't find enough documentations. Can somebody explain it more or introduce a library especially in python that got already implemented?
You can see explication on Simulated annealing. Also, take a look to scipy.optimize.anneal.