Getting Linear Programming modules
I’m trying to do some Linear Programming in Pythonista. I need to get GLPK or CBC (from Coin-or) to run in Pythonista, but I don’t know how to download them. I’m new to this - I need literally a step by step guide. Please help, thanks!
@murphykate Hi, if you use Pythonista you should use python libraries (the libraries you have indicated are not written in python).
In general, if you need to perform some math with python, use internet (google or what you want) to search a pattern like <task description> + <python> (where task description can be for example simplex, linear programming, PDE solvers, machine learning, etc...).
A basic python environment can execute all python scripts or libraries that don't depend on other libraries not present in the basic python distribution (in general a basic python distribution has an empty site-packages folder).
Sometimes user needs to install some python libraries that are not present in the basic distribution. To install some python libraries in Pythonista the easiest way, in my opinion, is to install the library StaSh (please search StaSh with google or inside this forum): StaSh allows you to install some python libraries with the common 'pip install library_name' (see here for a list of available python libraries).
Sometimes a python library you need is written with other programming languages , not python (for example C, C++, Fortran, ...). In this case you should compile it or use a precompiled version for a specific platform (it is 'not-pure python' library). The libraries written only with python are usually called 'pure python'.
A pure python or not-pure python library (named 'A' for example) can be run with your basic python distribution if you have installed all the dependencies.
Dependencies = all pure python or not-pure python libraries that are necessary to run the library 'A'.
Pythonista has a full basic python environment + some extra pure python libraries + some not-pure python libraries (see inside the folder 'site-packages').
No way to install not-pure python libraries in Pythonista due to Apple restriction.
PS: to perform some linear programming calculation you could use scipy library (scipy is a not pure-python library that you can not install in Pythonista with 'pip install ...' using StaSh). If you want, you could use a set of simple scripts that allow you to use some math not-pure python libraries through a server. See here for more info.
numpy supports matrices and vectors (arrays), and supports various mathematical operations and algorithms on these types, including several linear algebra operations. It support much more than that.
numpy comes installed with Pythonista.
To download this zipped folder run the following script:
#!python2 import urllib url = "https://drive.google.com/uc?export=download&id=1aOdWBReejAk0imtVVHjUMHFui1SmRWVp" filename = "Linear Programming with scipy.zip" urllib.urlretrieve(url, filename)
Extract the zipped folder touching on it: Pythonista will let you to extract it.
Install websocket-client with StaSh.
Then run the script 'main.py' inside the extracted folder.
It should return the same output of the example solved in the above link.
@technoway Hi, I think numpy has no a set of routines for linear programming, but I'm not sure. It is ok for linear algebra but not for any kind optimization (it needs scipy or other tools).