Is there any implementation of linear optimization model in python which allows explicitly define the types of my variables. For example I want my variable to be only integers. I can define this when using lpSolve in R like:
set.type(model, 1:18,type = "integer")
but I need to build linear optimization model in python.
There is a scipy's linprog implementation but it doesn't allow to define the type of my variables.
Since IP (Integer Programming) and LP (Linear Programming) are solved with very different algorithms it's legitimate that some solvers don't allow to mix both (IMO): IP has an exponential complexity and LP a polynomial complexity. Your problem is a MILP (Mixed Integer Linear Programming) which has thus an exponential complexity, so you need a MILP solver for Python. But be aware that if you introduce many integer variables even small problem instances might become very hard to solve. Scipy's linprog is just a LP solver according to the documentation.
And by the way it looks like there is also a python interface to lpsolve, and another interface pylpsolve that looks more up to date. I gave pylpsolve a try, and was able to clone from the github repo and install it, you might take a look at this function (according to what I told earlier, you will notice that the names are confusing...)
>>> from pylpsolve import LP
>>> help(LP.setInteger)