Mixed Integer Linear Programming Using Python with Multiple Objectives Support - python

I am very new to this field. I am working on MILP type of problem, and I am using Python with Pyomo.
Pyomo is very easy to use when you are having Single Objective Model. but in my case.
it is solving a very complicated type of Model that requires multiple objectives. I have seen some ppl suggesting to add a weight an implement it as (10*objective1 + objective2) as now objective1 will have bigger weight that objective2, but that wont solve my problem, as I am trying to do is to Maximize objective 1 and Minimize Objective 2
I am not strict to use only Pyomo, but i would like to use something easy as Pyomo with the support of Multiple Objectives.
What should i Use.
Thanks

You can check out PolySCIP for multi-criteria optimization. Another easy way to use multiple objectives is the Python interface of Gurobi.
I cannot give you a detailed answer because is quite broad and generic.

Related

Can I include continuous variable when optimising with CPMpy?

I need to run a model, where I optimise a diet within a set of constraints and call all integer solutions in the end. I have found a diet example matching almost what I need here: hakank.org. However, in my case, my variables take continuous values, so in the examples this would be all the nutritional values and the cost, while only x take integer. However, it seems like I can only define either 'intvar' or 'boolvar' when defining by variables with this model. Is there a way to overcome this? Other would there be other more suitable models with examples that I can read online?
I'm new to constraint programming, so any help would be appreaciated!
Thanks.
Most Constraint Programming tools and solvers only work with integers. That is where their strength is. If you have a mixture of continuous and discrete variables, it is a good idea to have a look at Mixed Integer Programming. MIP tools and solvers are widely available.
The diet model is a classic example of an LP (Linear Programming) Model. When adding integer restrictions, you end up with a MIP model.
To answer your question: CPMpy does not support float variables (and I'm not sure that it's in the pipeline for future extensions).
Another take - than using MIP solvers as Erwin suggest - would be to write a MiniZinc (https://www.minizinc.org/) model of the problem and use some of its solvers. See my MiniZinc version of the diet problem: http://hakank.org/minizinc/diet1.mzn. And see the MiniZinc version of Stigler's Diet problem though it's float vars only: http://hakank.org/minizinc/stigler.mzn.
There are some MiniZinc CP solvers that also supports float variables, e.g. Gecode, JaCoP, and OptimathSAT. However, depending on the exact constraints - such as the relation with the float vars and the integer vars - they might struggle to find solutions fast. In contrast to some MIP solvers, generating all solutions is one of the general features of CP solvers.
Perhaps all these diverse suggestions more confuse than help you. Sorry about that. It might help if you give some more details about your problem.

Particle swarm optimization with both continuous and discrete variables

So I want to try to solve my optimization problem using particle swarm optimiztion algorithm. As I comoratable with python I was looking into PySwarms toolkit. The issue is I am not really experienced in this field and don't really know how to account for integrality constraints of my problem. I was looking for advice on what are some approches to dealing with integral variables in PSO. And maybe some examples with PySwarms or any good alternative packages?
You can try pymoo module, which is an excellent multi-objective optimization tool. It can also solve mixed variable problems. Despite pymoo is first of all designed to solve such problems using genetic algorithms, there is an implementation of PSO (single-objective with continuous variables). Maybe you'll find it useful to try to solve your mixed variable problem using genetic algorithm or one of its modifications (e.g. NSGAII).

How to use complex variables in a Gurobi problem

I currently solve optimization problems with complex variables using CVX + Mosek, on MATLAB. I'm now considering switching to Gurobi + Python for some applications.
Is there a way to declare complex values (both inside constraints and as optimization variables) directly into Gurobi's Python interface?
If not, which are good modeling languages, with Python interface, that automates the reduction of the problem to real variables before calling the solver?
I know, for instance, that YALMIP does this reduction (though no Python interface), and newer versions of CVXPY also (but I haven't used it extensively, and don't know if it already has good performance, is stable, and reasonably complete). Any thoughts on these issues and recommendations of other interfaces are thus welcome.
The only possible variables in Gurobi are:
Integer;
Binary;
Continuous;
Semi-Continuous and;
Semi-Integer.
Also, I don't know the problem you're trying to solve, but complex number are quite strange for linear optimization.
The complex plane isn't a ordered field, so that is not possible to say that a given complex number z1 > z2
You'll probably have to model your problem in such way that you can decompose the constraints with real and imaginary parts, so that you can work only with real numbers.

PWL constraint in cplex Python API v12.8

When I tried to use piecewise linear (PWL) function in Python, after I set the problem type to cplex.Cplex.problem_type.LP, the PWL cpnstraint (or function) disappear when I write out the model to the file. However if I specified the problem type is cplex.Cplex.problem_type.MILP, it said that no solution, although there exist solution in LP. So I want to ask if someone face this problem before and how to solve it
The behavior you describe is expected. PWL constraints are considered MILP modeling objects. When you change the problem type to an LP, the MILP modeling objects are removed. Given that the LP is feasible, it sounds like your PWL constraint has introduced a conflict or there is something wrong with the definition of the PWL.
What exactly is the solution status code that you are getting when solving the MILP? That is, what is the value of Cplex.solution.get_status()? What does the engine log contain? These will likely give you some useful information.
In case you haven't found it, the CPLEX User's Manual contains a section on piecewise linear constraints here. See also the transport.py example that is included when you install CPLEX.

Which model to use when mixed-effects, random-effects added regression is needed

So mixed-effects regression model is used when I believe that there is dependency with a particular group of a feature. I've attached the Wiki link because it explains better than me. (https://en.wikipedia.org/wiki/Mixed_model)
Although I believe that there are many occasions in which we need to consider the mixed-effects, there aren't too many modules that support this.
R has lme4 and Python seems to have a similar module, but they are both statistic driven; they do not use the cost function algorithm such as gradient boosting.
In Machine Learning setting, how would you handle the situation that you need to consider mixed-effects? Are there any other models that can handle longitudinal data with mixed-effects(random-effects)?
(R seems to have a package that supports mixed-effects: https://rd.springer.com/article/10.1007%2Fs10994-011-5258-3
But I am looking for a Python solution.
There are, at least, two ways to handle longitudinal data with mixed-effects in Python:
StatsModel for linear mixed effects;
MERF for mixed effects random forest.
If you go for StatsModel, I'd recommend you to do some of the examples provided here. If you go for MERF, I'd say that the best starting point is here.
I hope it helps!

Categories

Resources