Hi John,

Are you able to compile GLPK from source?  I'll aim to provide an updated
source code and some more details/examples over the weekend.

On Thu, 5 Oct 2017 at 2:17 am, john tass <[email protected]> wrote:

> Hi Lyndon, again.
> Please do not forget to include in the example that you possibly will send
> to me, the way of how to refer to your extension and how I can have access
> to the solution.
> Thanks.
>
> 2017-10-04 18:11 GMT+03:00 john tass <[email protected]>:
>
>> Hi Lyndon,
>> Yes, it is exactly what I was looking for. I assume that by the way you
>> suggest I shall be able to write pure MathProg code. I make this comment
>> because I do not want simply to use just 2 or three variables (as the
>> example you sent, x1 and x2) but hundreds of them.  So, I need the
>> flexibility that MathProg provides. The same holds for the constraints
>> that refer to those variables, which are many, too.
>> Is it possible to send me an example which contains say 50 variables (x1,
>> x2, x3, ..., x50) without having to hard-code them? In other words, the
>> example should declare the variables by the use of indices. In addition,
>> please make an effort to mention how I get back to C function the optimal
>> objective value and the values of the variables concerning the optimal
>> solution.
>> Thank you a lot.
>>
>> 2017-10-04 15:44 GMT+03:00 Lyndon D'Arcy <[email protected]>:
>>
>>> John, the reason I ask is, I wrote a small extension to allow reading a
>>> MathProg model from memory instead of an external file.  I'm not sure if
>>> this is what you are looking for exactly.  But it would allow you to
>>> generate the MathProg code in-memory, and then read the resulting program
>>> into GLPK.  I think I would need to add another function to allow you to
>>> process the solution in memory as well.  Then you would be able to do
>>> everything without ever needing to leave the C environment, or read/write
>>> text files, or maintain a model file that had been generated separately.
>>> Is that what you're looking for?
>>>
>>> Below is some example code for reading MathProg using my extension:
>>>
>>>   int status;
>>>   char *buf = "var x1;\
>>>   var x2;\
>>>   maximize obj: 0.6 * x1 + 0.5 * x2;\
>>>   s.t. c1: x1 + 2 * x2 <= 1;\
>>>   s.t. c2: 3 * x1 + x2 <= 2;\
>>>   end;";
>>>   glp_prob *lp;
>>>   glp_tran *tran = glp_mpl_alloc_wksp();
>>>   status = glp_mpl_read_buffer_into_model(tran, buf, strlen(buf), 0);
>>>   ck_assert_int_eq(status, 0);
>>>     if (!status) {
>>>       status = glp_mpl_generate(tran, NULL);
>>>       if (!status) {
>>>           lp = glp_create_prob();
>>>           glp_mpl_build_prob(tran, lp);
>>>       }
>>>   }
>>>   glp_mpl_free_wksp(tran);
>>>   glp_delete_prob(lp);
>>>   glp_free_env();
>>>
>>> On 4 October 2017 at 22:49, Andrew Makhorin <[email protected]> wrote:
>>>
>>>>
>>>> > 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.
>>>>
>>>> Please see Section 3.2 "Routines for processing MathProg models" in the
>>>> glpk reference manual (file glpk.pdf can be found in the subdirectory
>>>> 'doc' in every glpk distribution tarball).
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Help-glpk mailing list
>>>> [email protected]
>>>> https://lists.gnu.org/mailman/listinfo/help-glpk
>>>>
>>>
>>>
>>
>>
>> --
>> Dr. Ioannis X. Tassopoulos, MSc., Ph.D.
>>
>>
>
>
> --
> Dr. Ioannis X. Tassopoulos, MSc., Ph.D.
>
>
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to