help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Embedded Python in GLPK


From: vijay patil
Subject: Re: [Help-glpk] Embedded Python in GLPK
Date: Thu, 13 Mar 2008 23:30:07 +0530



On Sun, Mar 9, 2008 at 4:46 AM, Xypron <address@hidden> wrote:
Using GLPK I missed the possibility to use a scripting language to
calculate values used for filling parameters and sets.

Example:
I was working on a problem combining lot sizing and safety stock
calculation. I needed to calculate the inverse incomplete Gamma
distribution function depending on service level and time until next
production. I has to use quadratic approximations for the required
safety stock in GLPK. In ILOG OPL I was able to use _javascript_ to make
an exact calculation.

To overcome this problem I have added embedded Python scripting into
GLPK 4.27. My first tentative implementation can be downloaded from
ftp://glpk.dyndns.org/glpk/glpk-4.27-py_r161.tar.gz

Installation of Python 2.5 developer files is presumed.

Compiling has only be tested under Linux and MinGW. I have not updated
the make files in the W32 directory.

Python scripts can be enclosed in a MPL file with
<?python
?>

functions are declared with
function name ['alias'] python {numeric, symbolic, set} [variant] [dimen
n] ([{numeric, symbolic, set} name,] ...);
[] being optional arguments.
variant describes a function where the result depends not only on the
arguments. Hence the result may not be buffered for future use. An
example are random number generators.

Sets are passed to python and returned form python as lists of tuples.

Where do I want to go to: I would like to use embedding Python scripting
to control the solution process: adding new constraints, changing
variables from float to binary, ...  But that is future. Currently
Python can only used to calculate numbers, symbols and sets.

I am looking forward for Your comments.


I will try out this just for fun. As far as know, in real life mathematical programming languages (like MathProg, OPL etc.) are used only for prototype purpose (correct me if I am wrong), just to quickly and easily try out different model formulations. The final model is usually coded using C API provided by the solver. In other words, final application is likely to be a C/C++/Java program.

Real life applications involve lot of data processing and many types of constraints. Adding these constraints require suitable data structures and functions. Also sometimes customized branch and bound algorithm might be needed to solve specific mixed integer program and interaction with GUI. Writing the whole application in C/C++ gives tremendous flexibility.

I am really interested in knowing (and learning) what other people's experience are with usage of mathematical programming language vs using solver's C API.


--
Vijay Patil
reply via email to

[Prev in Thread] Current Thread [Next in Thread]