I am actually running a MILP on Python using DOcplex and it is my very first time using it. It is saying that my model which I ran on Lindo is infeasible. Therefore, I am guessing that I erroneously entered my constraints, but I cannot view them. I used "mdl.print_information()", but it is not helping much. Does anyone know how I can solve my problem?
Thanks in advance.
You can export the model to LP format (a human readable LP format), by Model.export_as_lp(). You can also export the model to a string in LP format with Model.lp_string, to get a complete view of the model.
In addition, this notebook: https://github.com/IBMDecisionOptimization/docplex-examples/blob/master/examples/mp/jupyter/infeasible.ipynb
gives hints on how to investigate infeasible models, in particular with the Relaxer class.
Knowing which constraint is infeasible (and by how much slack) may lead you to the root cause of the infeasibility.
Related
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.
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.
I want to add indicator constraints (e.g. if z=0, then x=0 with x>=0 and z being a binary variable) to my problem written in PuLP. Obviously, I could make use of the big-M method as suggested here and here.
However, I cannot use the big-M workaround since my term is unbounded within the MILP. I found this post from 2016 stating that PuLP cannot handle indicator constraints.
Does anyone know if that is still the case or any other solution?
Thanks in advance.
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.
I have a problem of predicting solutions to problems faced by users.
The problem setting is like this:
We have a database of problems and solutions. For each problem we have three parameters to represent it.
JobName (String - Name of the Job)
JobId (Integer - Id of the Job)
RootCause (String - Cause of that problem).
Each problem has a corresponding solution added by that user who faced that problem. That solutions parameter is
Solution (String - Solution entered by user for that problem)
So we wanted to make use of that database and predict the solutions for new problems (a problem is a set of jobname, jobid, rootcause - all are strings)
We initially came up with this solution.
We just want to identify problems(set of jobname, jobid, rootcause) similar to our query problem and give the solution to the closest problem.
But in this case we don't have any way to measure the training error like we have in the house price prediction problems.
In general, how to we approach this problem, and what kind of machine learning models do we need to use ?
Seems, you want to build kind of the recommendation system. According to the cause of the problem, suggest list of the recommended solutions. One of the possible solution - use word2vec for vectorisation RootCause and then try to find similar problems using, vectors similarity.