help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] MathProg, glpk and C language


From: john tass
Subject: Re: [Help-glpk] MathProg, glpk and C language
Date: Wed, 4 Oct 2017 14:10:03 +0300

Hi Lyndon,
First of all I would like to thank you for your concern.
As a matter of fact, the case you mention is not my case. I have a C program with several functions (written in pure C) . But I want to write one function (I do not know the syntax of its programming code), which is intended to solve an MIP problem and return the results (solution of MIP) to the main C program which calls this function. I do not want to leave the C environment at all. 
One possible way I suppose that is to use the API's of Glpk inside that function, using #include "glpk.h". But this way has the following drawback: in order to declare a structural variable of my model, say X1, I have to write something like glp_set_col_name(lp, 1, "x1"); That means that I declare the X1 variable by a hard-code. But my model is quite large, having hundreds of variables. In addition, I do not know in advance the exact number of them since they should be created dynamically. As you understand it is impossible to repeat the above declaration for some hundreds of times, to say nothing about the writing of the constraints. Please bear in mind that I do not want to exit the C environment, nor to create the model by C in a text file, then read the mod file, solve the problem via glpk and write the results in a text file, from where the C would read them.
So it cross my mind the idea of using MathProg, since it is a modelling language which provides the user with an easy way to represent the models. I repeat: I do not want to create a .mod file in MathProg and feed it to glpsol. I want to use MathProg inside a C function.
I hope that I have been understood now. I apologize if I was previously  not clear enough.
Thanks for your help.

2017-10-04 11:25 GMT+03:00 Lyndon D'Arcy <address@hidden>:
Hi John,

If I understand correctly, you would like to programmatically generate some MathProg code inside of your C program, and then read that generated code with the GLPK API?

Cheers,
Lyndon

On Wed, 4 Oct 2017 at 4:23 am, john tass <address@hidden> wrote:
Good evening.
I am trying to write a function in ANCI C programming language. The aim of this function is to get some input arguments from the main C program, then solve a MIP problem and return the value of objective function along with the values of structural variables back to the C main program.
The issue is that the MIP problem I am about to solve via glpk has a quite large number of variables. So, I am not able to hard-code them. Hence, I came across the idea to use MathProg language, as it is very easy to code my model. 
The question is, how to do this? Is it possible to incorporate MathProg code inside a C language function? Please note that I am aware of how to write a C program that calls API routines of glpk in order to solve a simple model, but here I am not referring to this case.
Any suggestion of a site, pdf or relevant document will be very helpful.
Thanks in advance to any one who is willing to help me.

--
Dr. Ioannis X. Tassopoulos, MSc., Ph.D.

_______________________________________________
Help-glpk mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-glpk



--
Dr. Ioannis X. Tassopoulos, MSc., Ph.D.


reply via email to

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