Re: configure under windows

2023-06-07 Thread Heinrich Schuchardt

On 6/7/23 11:35, endre.rev wrote:

Can you help me in installing and configuring glpk under Windows?
I could not find any hint.
I have tried running the configure file from command prompt. For this
aim I had to rename the configure file to configure.bat.
It started but complained during the run.
Is there a way to do it under Windows?

Thanks
erev



Hello Erev,

please, have a look at https://winglpk.sf.net for prebuilt Windows
binaries and the build scripts used.

Best regards

Heinrih



Re: Requesting Repo access regd

2023-04-13 Thread Heinrich Schuchardt



Am 13. April 2023 09:25:54 MESZ schrieb PRANJAL PRAGYA VERMA 
:
>Dear GLPK
>
>Can someone please point me to the code repo for GLPK- like github where
>the code is currently being maintained.

There is none. Of course the survival chances of the project would increase 
with a more collaborative development process.

Only https://ftp.gnu.org/gnu/glpk for downloads.

Best regards

Heinrich

>
>Thanks
>Pranjal Verma



Re: GLPK CMake support

2021-11-11 Thread Heinrich Schuchardt

On 11/11/21 13:37, Kyle McLachlan wrote:

My apologies if this is not the correct forum;

GLPK 5.0 is currently being given CMake support at the following GitHub
repository: https://github.com/Mizux/GLPK 

This is being done to make it more compatible with other CMake builds,
specifically including Google's OR Tools. It would be great if this work
could be included in the official codebase, or if anyone could lend a
hand in testing and/or ironing out any potential bugs.

One of the benefits of this CMake effort is that there is no need to
maintain a separate build script for MSCV, as it builds and runs great
on MSVC using CMake - this may be of interest to the maintainers of GLPK.


According to https://github.com/Mizux/GLPK/blob/main/CMakeLists.txt#L50
you do not support building DLLs with your CMake files.

GLPK DLLs are essential to call the GLPK library from C, C++, JAVA, C#,
or any other language.

Best regards

Heinrich



Kind regards,
Kyle





Re: Output to GMPL data file

2021-07-27 Thread Heinrich Schuchardt
Am 27. Juli 2021 20:06:53 MESZ schrieb Philippe Jugla 
:
>Hello everyone,
>
>I am looping with a .bat file to run N simulations with glpsol.
>At the end of each simulation, I would like to use the value of a variable 
>which is calculated, as an input for the next simulation.
>What I have written in my .mod file doesn't work because it does not overwrite 
>my storage.dat file after each simulation...
>
>in the .mod file :
>TIME = 0..T-1;
>param initial_storage;
>var storage {t in TIME};
>/* I want to output the final storage value as initial storage for next 
>simulation*/
>printf ‘data; param initial_storage := ‘ & storage[T-1].val & ‘ ;’ >> 
>‘storage.dat’

Use a single > here.

>> is used to append.

Have a look at print format strings too.

Best regards

Heinrich

>printf ‘end ;’ >> ‘storage.dat’
>
>the .bat file :
>for /l %%k in (1,N,1) do (
>echo solving DAY %%k...
>"%GUSEKPATH%\glpsol.exe" --cuts -m "model.mod" -d "storage.dat" -d 
>"data_%%k.dat"
>)
>
>Is there a way of achieving this ?
>Thank you very much,
>
>Best regards,
>
>Philippe
>




Re: Constraint on a binary variable

2021-06-30 Thread Heinrich Schuchardt

On 6/30/21 5:24 PM, Philippe Jugla wrote:

Hi everyone,

In my model, I have a variable "p" which has an upper bound pmax := 2.5
and a lower bound pmin := -2.5.
I would simply like to add a binary variable "sign" which takes the values :

1 if variable p is positive
0 if variable p is negative (or vice-versa)

I thought of something like :

s.t c1 : sign >= p[t] / pmax;

So if p[t] is positive : sign >0 and <1, therefore sign will be forced to 1.
However, if p[t] is negative, "sign" is greater than a negative value so
the variable is no longer constrained, and can take values 0 or 1.

How can I work things out ?

Thanks for your help

Best regards,
Philippe


var sign, binary;
var p, >= -2.5, <= 2.5;
s.t. constraint: p <= 2.5 * sign;
#maximize obj: p;
minimize obj: p;
solve;
display p, sign;
end;

Best regards

Heinrich




Re: [Fwd: Include Examples in Documentation Showing Usage]

2021-06-09 Thread Heinrich Schuchardt

On 6/10/21 6:52 AM, Andrew Makhorin wrote:

 Forwarded Message 
From: Dario Strbenac 
To: help-glpk@gnu.org 
Subject: Include Examples in Documentation Showing Usage
Date: Wed, 9 Jun 2021 07:00:09 +

Good day,

The README and INSTALL files contain only details to compile the
software. Could there be a vignette provided showing how to use it on an
example data set?

Also, I was surprised that the result of running make was to put the
executable into the examples directory by default:

[ds6924@gadi-login-01 glpk-5.0]$ find ./* -name glpsol
./examples/glpsol
./examples/.libs/glpsol

It seems you missed to run:

sudo make install
sudo ldconfig

Thereafter the binary, library and includes are installed according to
the chosen prefix (/usr/local by default).

Best regards

Heinrich



It is not the first place I would have intuitively looked for it (that
being a bin directory).

--
Dario Strbenac
University of Sydney
Camperdown NSW 2050
Australia







Re: Scheduling problem - cost function

2021-04-01 Thread Heinrich Schuchardt
On 01.04.21 17:07, Philippe Jugla wrote:
> Hello everyone,
>
>  
>
> I have some difficulties to add a cost parameter that depends on 2
> variables to a scheduling model in GLPK. 
>
>  
>
> The problem is as follows : 
>
>  
>
> If the unit has started up and been active for less than k hours than
> the cost follows a certain cost function, if it has been more than k
> hours then the cost follows another function. 
>
>  
>
> I have tried the following example but doesn’t seem to work : 
>
>  
>
> #set

T has to be defined before defining the set.

>
> set TIME:=0...T
>
>
> #binary variables (already defined and working) 
>
> var start_up {TIME} binary; 
>
> var unit_on {TIME} binary; 
>
>
> #parameters
>
> param T:=10;
>
> param price {TIME};
>
> param k:=2;
>
>
> #this is what I’ve tried :
>
> param cost {t in TIME} := 
>
>   if sum { s in TIME : s = t - k and s >= 0 } start_up[s] +
> unit_on[s] < k+1 then 2.5*price[t] + 5 else 3.0*price[t] + 10;

You cannot define a parameter as a function of variables. You will have
to make cost a variable and use a constraint.

In a constraint you cannot use "if then else". But you might use
multiple constraints using the binaries.

Best regards

Heinrich

>
>  
>
> The following error is thrown : « operand preceding < has invalid
> type ». I guess it is because of the variables ? I tried to define cost
> as a variable but with no success as well..
>
>
> I am also trying to workaround things by defining another binary
> variable X {TIME} that I would constrain, and then define the cost with
> something like cost[t] = (1-X)*(cost_function_1) + X*cost_function_2 but
> it seems quite complicated for this type of problem.
>
>
> Does anyone know what is the issue ? How could I work things out ?
>
>
> Any help or advice would be greatly appreciated !
>
>
> Best regards 
>
>  
>
> Philippe 
>
>




Re: Constraint modelling on a subset

2021-03-23 Thread Heinrich Schuchardt
On 23.03.21 22:28, Philippe Jugla wrote:
> Hello, 
>
>  
>
> I am rather new to GLPK and I am seeking help regarding the modelling of
> a constraint in a unit commitment problem. 
>
> I hope someone will kindly help me on this one. 
>
>  
>
> I am trying to model a constraint which constrains a sum, but on a
> sequence of subsets of an initial set TIME. 
>
> A bit of context with a simple example below : 
>
>  
>
> *#sets *
>
> set TIME := 1..T; 
>
> set PLANTS :=P1, P2; 
>
> * *
>
> *#parameters *
>
> param T; 
>
> param max_startups_year {PLANTS}; 
>
> param max_startups_week {PLANTS}; 
>
> * *
>
> *#variable *
>
> var startup {p in PLANTS, t in TIME} binary; 
>
> * *
>
> *#constraint 1 *
>
> subject to C1 {p in PLANTS}: 
>
> sum {t in TIME} startup[p,t] <= max_startups_year[p]; 
>
> *_ _*
>
> *Now this is where I am struggling : I would like to constrain sum of
> startup[p,t] with parameter max_startups_week[p] but on subsets of the
> set TIME with step k (let’s say k=5). *
>
> * *
>
> *The following works but obviously is not flexible at all. *
>
> *It gives you the idea of what I would like to do : *
>
>  
>
> sum {t in 0..5} startup[p,t] <= max_startups_week[p]; 
>
> sum {t in 6..10} startup[p,t] <= max_startups_week[p];
>
> … 
>
> Etc… 
>
> … 
>
> sum {t in T-5..T} startup[p,t] <= max_startups_week[p]; 
>
>  
>
>
> I have tried to define another set TIME_2 but it’s not satisfying as it
> is hard-coded as well… 
>
>  
>
> *Set TIME_2 := (0..5 union 6..10.. union /[etc]/ union T-5..T)  *
>
> *subject to C2 {p in PLANTS}: *
>
> *sum {s in TIME_2} startup[p,s] <= max_startups_week[p]; *
>
>  
>
> How would you work this constraint out to be robust and flexible ? At
> the end, the number of steps k should be a parameter. 
>
> To simplify things, let’s say that k divides exactly set TIME. 
>
>  
>
> Thanks very much for your help, 
>
>  
>
> Philippe 
>
>

All you need is an indexed constraint like:

s.t. constraint{w in WEEKS}:
max_startups_week[w] >=
sum{d in DAYS_OF_WEEK} startup[d + days_per_week * w];

Best regards

Heinrich



Re: Solver delivers wrong answer when 2 constraints are close

2021-03-04 Thread Heinrich Schuchardt

On 3/4/21 4:44 PM, Antti Lehtila wrote:

Hi,

I think it works fully as documented, and so *per design*. Singleton
rows are treated as column bounds by the preprocessor. See documentation
for *npp_implied_lower*:
*---
*  Processing implied column lower bound l'[q] includes the following
*  cases:
*
*  1) if l'[q] < l[q] + eps, implied lower bound is redundant;
*
*  2) if l[q] + eps <= l[q] <= u[q] + eps, current column lower bound


In this line an apostrophe is missing.

  2) if l[q] + eps <= l'[q] <= u[q] + eps, current column lower bound


* l[q] can be strengthened by replacing it with l'[q]. If in this
* case new column lower bound becomes close to current column upper
* bound u[q], the column can be fixed on its upper bound;


It is this strengthening that fails:

src/npp/npp3.c:567
eps = (q->is_int ? 1e-3 : 1e-3 + 1e-8 * fabs(q->lb));

Set eps to 1E-5 and you are fine.

Or run with --nopresol.

@Andrew:
Shouldn't 1E-5 be good enough?
Why do we need eps > 0?

Best regards.

Heinrich


*
*  3) if l'[q] > u[q] + eps, implied lower bound violates current
* column upper bound u[q], in which case the problem has no primal
* feasible solution. */
*---
The lower bound can have only a single value, but if you define multiple
values for a column lower bound, they must of course be processed in
some order.  In this case, the lower bound is first defined l(q)=0, then
l'(q)=1, and finally l'(q)=1.0001. The third value for the bound is thus
considered *redundant*, as per design, and so the second value l(q)=1
remains in effect. This is because *eps* is defined as 1e-3 + 1e-6 *
fabs(q->lb)).

I guess it may be a considered a design flaw, but I think it should not
be called a bug, as it is working as designed and documented.  Besides,
I think one should use the Bounds section for bounds, instead of using
multiple constraints for defining a single lower bound.

Best,
Antti
___
On 04.03.2021 11:38, Domingo Alvarez Duarte wrote:


Testing this problem I discover that if we change the order of
constraint declarations it seems to give the expected answer as stated
by Thiago (what I think could be another bug).



/param min_bound default 0;/
/var x >= 0;

minimize y: x;/
*
*/*s.t. PART_MIN_X: x >= 1 + min_bound;*
/
/*s.t. LIM_INF_X: x >= 1;
*
/
/solve;
display min_bound;
display x; # EXPECTED RESULT: X ==  1.0001

data;
param min_bound := 1e-4;
end;/



Output:



x.val = 1.0001



On 3/3/21 19:19, Thiago Neves wrote:

Hi.
I've found a strange behaviour in glpk which I don't know how to fix
nor how to contour it. It seems like GLPK can't distinguish
constraints that differs from about 1e-4.

Follows simple examples that explain and reproduce the problem.**
*
*
*The first model gives the desired answer (x = 1.0001):*
/
param min_bound default 0;/
/var x >= 0;

minimize y: x;/
/*
s.t. PART_MIN_X: x >= 1 + min_bound;*

solve;
display min_bound;
display x; # EXPECTED RESULT: X ==  1.0001

data;
param min_bound := 1e-4;
end;
/
/_/
/OUTPUT:/
/x.val = 1.0001/
/_ /

*Now, if I add a second constraint "close" to the first one, the
solver will deliver an answer that is actually infeasible:*

/param min_bound default 0;/
/var x >= 0;

minimize y: x;/

*s.t. LIM_INF_X: x >= 1;

*/*s.t. PART_MIN_X: x >= 1 + min_bound;*

solve;
display min_bound;
display x; # EXPECTED RESULT: X ==  1.0001

data;
param min_bound := 1e-4;
end;/
/_/
/OUTPUT:/
x.val = 1
/_ /

*If I change the "min_bound" parameter to 1e-2, the second model
works as expected (x = 1.01):*

/param min_bound default 0;/
/
/
/var x >= 0;

minimize y: x;/
*
*
*s.t. LIM_INF_X: x >= 1;

*/*s.t. PART_MIN_X: x >= 1 + min_bound;*

solve;/
/
display x; # EXPECTED RESULT: X ==  1.01

data;
param min_bound := 1e-2;
end;/
/_/
/OUTPUT:/
x.val = 1.01
/_ /
/
/

Att,

*Thiago H. Neves*
(31) 98608-0666









Re: [Fwd: Question for infeasible LP problem]

2021-01-04 Thread Heinrich Schuchardt

Dear Jeanette,

Consider using library functions glp_get_unbnd_ray() and
glp_get_row_stat() to determine *one* of the rows leading to
infeasibility. See file doc/glpk.pdf of the GPLK source.

Best regards

Heinrich

On 1/5/21 2:44 AM, Mate Hegyhati wrote:

Hi!

Maybe I'm wrong, but I don't think that such an indicator is
programmable.  Consider this small example with 3 non-negative variables:

x + y <= 1
x + z <= 1
y + z <= 1
x + y + z >= 2

Remove any of the constraints, and it becomes feasible. You wouldn't be
able to tell, which one is wrong if I don't provide any semantics. And
from the solvers point of view, the model you provide has no semantics,
just "arbitrary" cutting planes.

Nevertheless, I know the feeling of having an infeasible implementation
of a model with many constraints, and scratching my head. In the
following I describe what I usually do in this situation. Hopefully,
someone will be outraged with the ugliness of it, and provide a much
simpler approach :-)

Most often I have an idea, where the bug might be, so if I have 2-3
suspicious constraints where I probably mistyped something, I usually
comment them out one-by-one, and if the model becomes feasible only in
one case, I triple-check that constraint character by character.

If that is not the case, or doesn't help, nor does a general
double-check, rubber-duck method, etc.,  I try the following:

1) I find the smallest dataset I can where the model is
infeasible/results in a suboptimal solution.
2) Hopefully, either a feasible solution is already known for that
dataset, or easy to find. (not necessarily optimal, just feasible is
enough)
3) I enforce the variables (if necessary all of them, maybe just a few
key ones, in my case typically binaries) to have these values, and then
either comment the constraints out one-by-one to test, or add an "error"
variable to all the right hand sides, and minimize that.

A simple way to do this is to change the variable to param and have a
separate data file with the values of the variables in the feasible
solution. (You can use more data files at the same time.)

The disadvantage of this is that you have to change it back to var after
you are done. If you need to repeat this step couple of times, another
option could be something like this:

param bigM = 1024;
param NOTFIXED=-1; # or something irrelevant

param foo_value{SET}, default NOTFIXED;
var foo{element in SET} # >=0, integer, etc
  <= (if foo_value[element]==NOTFIXED then bigM else foo_value[element]),
  >= (if foo_value[element]==NOTFIXED then -bigM else foo_value[element])
  ;

then, if you don't provide the data file with a solution, you get the
"original" model. If you do, you get these variables fixed.

Of course this can be tedious if you have a lot of different variables.

The error part is simpler:

param max_error default 0;
var error >=0, <= max_error;

s.t. suspicious_constraint{...}:
   LHS <= RHS + error;


minimize objective:
   # original objective
   + bigM * error
   ;

Again, if you provide param max_error:=; in a data file, error would
be allowed but minimized. otherwise it is removed by the preprocessor.


I strongly hope, that someone has a much more elegant way of doing this.

All the best!

Mate



On 1/5/21 12:52 AM, Andrew Makhorin wrote:

 Forwarded Message 

*Date*: Mon, 4 Jan 2021 23:23:17 +
*Subject*: Question for infeasible LP problem
*To*: help-glpk@gnu.org mailto:%22help-g...@gnu.org%22%20%3chelp-g...@gnu.org%3e>>
*From*: "Du, Jeanette" mailto:%22Du,%20jeanette%22%20%3cjeanette...@freddiemac.com%3e>>


Hello,

I am relatively new to GLPK LP solver. Is there a way to find out the
constraint(s) that cause infeasibility of a problem in the .out file?

Thanks,

Jeanette(Yuqian) Du

Investments and Capital Markets

Freddie Macv





Re: HELP: Reading table from CSV

2020-12-05 Thread Heinrich Schuchardt

On 12/5/20 2:11 PM, Manuel Castro wrote:

Hi all,

First, I would like to thank you for the constant support as you have
always addressed my questions very promptly.
Second, I would like to ask you a question as I am really stuck on this one.

I have defined the following in the code:
set LoadsCount;
set PeriodsCount;
param LoadPowerProfile{i in LoadsCount, j in PeriodsCount};

For the sake of discussion let's assume that "LoadsCount" is 1..100 and
"PeriodsCount" is 1..8760 (i.e. hourly values through the year).
I now want to fill in my array "LoadPowerProfile" with values. For that
I have the following table in CSV (of course this is a stylized table
just for you to understand what I am up to).


With the GLPK you cannot read cross-tabulated CSV files.

You should create a table where you have separate columns for load,
hour, value.

Load,Hour,Value
1,0,3.4
1,1,5.7
...
100,8760,6.7

Best regards

Heinrich



Load
1
2
(…)
8760
Load1
11.98
62.51

99.69
Load2
86.39
59.50

25.89
(...)




Load100
67.98
98.71

31.19


How do I read the yellow shaded area into my "LoadPowerProfile" array? I
would be thankful if you could give me an example of the statement i
should use to read this into "LoadPowerProfile" array.

Many thanks in advance for all your support.

Kind regards,
Manuel.






Re: Help: “current directory” function

2020-12-03 Thread Heinrich Schuchardt
On 12/3/20 2:48 PM, Manuel Castro wrote:
> Hi glpk wizards,
>
> I wonder if there a kind of function or workaround that returns the
> directory path of where the ‘.mod’ file is??
>
> Basically in the folder where the ‘.mod’ file is, I have created another
> folder called “data” where I have all my input and output CSV data
> files. I can insert this directory path as a string in the GLPK reading
> CSV file statement. But of course if I change the directory of the
> project then, I have to go to the ‘.mod’ file and rewrite the directory
> path which is very inconvenient.

Just use relative paths (e.g. "data/foo.data"). These will be evaluated
relative to your current working directory.

Bet regards

Heinrich

>
> So, is there a function/workaround that can return the directory path of
> the ‘mod’ file?
>
> Many thanks for your help.
>
> Kind regards,
> Manuel.
>
>




Re: Help: read single value from CSV

2020-11-28 Thread Heinrich Schuchardt
Am 28. November 2020 18:08:01 MEZ schrieb Manuel Castro :
>Hi there,
>
>
>
>What does the syntax statement look like to read a single value from
>the CSV file?
>
>My CSV has the following:
>
>RowIndex   Capacity
>
>   1                   33
>
>
>
>I read it as follows:
>
>param Z {i in I};
>
>table tab_stream IN "CSV" "stream.csv" : [RowIndex], Z ~ Capacity;
>
>

You should use 

[I  ~ RowIndex]

to fill I.

The table statement is meant to rraf multiple lines.

Just define a parameter that is the sum of the capacity array Z.

Best regards

Heinrich


>
>I am only interested in the column 'Capacity', i.e. in the value 33.
>
>More importantly, I don't need Z to be an array. I want Z to be a
>scalar i.e. param Z;
>
>
>How do I represent this in the read statement of the CSV?
>
>
>
>Many thanks.
>
>
>
>Kind regards,
>
>Manuel. 




Re: Help: Switching between different objective function

2020-11-26 Thread Heinrich Schuchardt

On 11/26/20 7:55 PM, Manuel Castro wrote:

Hi there,

I am wondering how I can use an if statement to switch between different
objective functions.
For example, how do I represent the following:


If (StatusFlag_X == 1 && StatusFlag_Y == 0) then
   minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
end if

If (StatusFlag_X == 0 && StatusFlag_Y == 1) then
   minimize cost: sum{i in I, j in J} c[i,j] * x[i,j] + d[i,j] * Y[i,j];


The line above cannot be valid as the indices for d and Y are not
defined. You forgot the parentheses.


end if



I am assuming StatusFlag_X and StatusFlag_Y are parameters.

The following can be used as template if you have a lot of different
objective functions with complex selection criteria:

minimize cost:
sum{i in {1} : StatusFlag_X == 1 && StatusFlag_Y == 0} 1 *
  (sum{i in I, j in J} c[i,j] * x[i,j]) +
sum{i in {1} : StatusFlag_X == 0 && StatusFlag_Y == 1} 1 *
  (sum{i in I, j in J} c[i,j] * x[i,j] + d[i,j] * Y[i,j])

In your case this simplifies to:

minimize cost:
sum{i in I, j in J} c[i,j] * x[i,j] +
StatusFlag_Y * sum{i in I, j in J} d[i,j] * Y[i,j]

Best regards

Heinrich



Both are mutually exclusive, i.e. either you do one or the other, i.e.
both objective functions will never be activate at the same time

This is what I used to do in "mosel" language from FICO Xpress (I don't
have a license anymore so I am discovering GLPK[Smile] ). How can I do
this in GLPK language? What's the workaround that we can use for this?

Many thanks in advance for your help. It's really appreciated.

Kind regards,
Manuel.






Re: Help: read from txt files

2020-11-26 Thread Heinrich Schuchardt

On 11/26/20 7:48 PM, Manuel Castro wrote:

Hi there,

Is it possible to get GLPK to read/write data from/to text files?

If yes:

  * what is the syntax statement one should use for that purpose?
  * what is the format the input data in the text file should be in?


Many thanks in advance for your help. It's really appreciated.

Kind regards,
Manuel.




Have a look at the table statement in doc/gmpl.pdf.

The table statement can be used to read and write CSV files or SQL
databases.

Best regards

Heinrich





Re: Help: Switch constraints on or off

2020-11-24 Thread Heinrich Schuchardt

On 11/24/20 9:30 PM, Heinrich Schuchardt wrote:

On 11/24/20 8:42 PM, Andrew Makhorin wrote:

On Tue, 2020-11-24 at 18:59 +, Manuel Castro wrote:

Hi there,

I am wondering how I can use an if statement to turn a constraint on
or off.
For example in my problem I have the following constraint:

subject to linctr14 {i in PeriodsCount: i == 1}: StorageEnergy[i] =
(StorageStateCharge * StorageEnergyRating + ((StorageEfficiencyCharge
* (StoragePowerCharge[i])) - ((StoragePowerDischarge[i]) /
StorageEfficiencyDischarge)));

Now, I only want to consider storage in my problem if an object
storage actually exists.
For that, I would have a StorageStatusFlag which if equal to "1" then
I would consider the constraint in my problem.
For example:

If (StorageStatusFlag == 1) then
     subject to linctr14 {i in PeriodsCount: i == 1}: StorageEnergy[i]
= (StorageStateCharge * StorageEnergyRating +
((StorageEfficiencyCharge * (StoragePowerCharge[i])) -
((StoragePowerDischarge[i]) / StorageEfficiencyDischarge)));
end if


Just add the condition to the constraint iterator:

subject to
linctr14{i in PeriodsCount: i == 1 && StorageStatusFlag == 1}: 


I have updated our wikibook

https://en.wikibooks.org/wiki/GLPK/Conditional_Constraints

Best regards

Heinrich





This is what I used to do in "mosel" language from FICO Xpress (I
don't have a license anymore so I am discovering GLPK ). How can I do
this in GLPK language? What's the workaround that we can use for this?



You could use the C preprocessor.




Many thanks in advance for your help. It's really appreciated.

Kind regards,
Manuel.











Re: Help: Switch constraints on or off

2020-11-24 Thread Heinrich Schuchardt

On 11/24/20 8:42 PM, Andrew Makhorin wrote:

On Tue, 2020-11-24 at 18:59 +, Manuel Castro wrote:

Hi there,

I am wondering how I can use an if statement to turn a constraint on
or off.
For example in my problem I have the following constraint:

subject to linctr14 {i in PeriodsCount: i == 1}: StorageEnergy[i] =
(StorageStateCharge * StorageEnergyRating + ((StorageEfficiencyCharge
* (StoragePowerCharge[i])) - ((StoragePowerDischarge[i]) /
StorageEfficiencyDischarge)));

Now, I only want to consider storage in my problem if an object
storage actually exists.
For that, I would have a StorageStatusFlag which if equal to "1" then
I would consider the constraint in my problem.
For example:

If (StorageStatusFlag == 1) then
     subject to linctr14 {i in PeriodsCount: i == 1}: StorageEnergy[i]
= (StorageStateCharge * StorageEnergyRating +
((StorageEfficiencyCharge * (StoragePowerCharge[i])) -
((StoragePowerDischarge[i]) / StorageEfficiencyDischarge)));
end if


Just add the condition to the constraint iterator:

subject to
linctr14{i in PeriodsCount: i == 1 && StorageStatusFlag == 1}: 

Best regards

Heinrich



This is what I used to do in "mosel" language from FICO Xpress (I
don't have a license anymore so I am discovering GLPK ). How can I do
this in GLPK language? What's the workaround that we can use for this?



You could use the C preprocessor.




Many thanks in advance for your help. It's really appreciated.

Kind regards,
Manuel.








Re: AW: [Fwd: Portable version]

2020-11-02 Thread Heinrich Schuchardt
On 02.11.20 16:53, Andraschko, Bernhard wrote:
> Hi,
>
>
> thank you for your answer! Changing LD_LIBRARYY_PATH in the glpsol file
> worked. But is there a way to create a completely portable version, i.e.
> one that I can put anywhere on my file system without changing this
> variable?

If you use a shared library the operating system must know where to find
it. LD_LIBRARY_PATH is one way of telling where to search.

You can link glpsol statically with all involved libraries. Then you
don't have to care about library locations anymore.

This is what Domingo suggested.

You can use the ldd command to find all linked shared libraries.

Best regards

Heinrich

>
>
> Thanks
>
> Bernhard
>
>
>
> --------
> *Von:* Heinrich Schuchardt 
> *Gesendet:* Montag, 2. November 2020 12:20:59
> *An:* help-glpk@gnu.org; Andrew Makhorin
> *Cc:* Andraschko, Bernhard
> *Betreff:* Re: [Fwd: Portable version]
>  
> Am 2. November 2020 10:53:06 MEZ schrieb Andrew Makhorin :
>
>  Forwarded Message 
> From: "Andraschko, Bernhard" 
> To: help-glpk@gnu.org 
> Subject: Portable version
> Date: Mon, 2 Nov 2020 07:21:45 +
>
> Hi,
>
> I'm currently working for the Chair of Symbolic Computation in
> Passau
> and help developing ApCoCoA-2, a computer algebra framework
> mainly for
> commutative algebra for Linux and for Windows.
>
> We would like to include include a version of GLPK into our
> framework,
> but have failed yet with compiling a portable standalone version of
> glpsol as the configuration and the built always writes direkt paths
> into many files. Also replacing all paths by new ones didn't help.
>
> Is there a way to compile a portable version?
>
> Best Regards
> Bernhard Andraschko
>
>
>
> Dear Bernhard,
>
> please, provide a log of the errors that you observed.
>
> On Linux you may have to set LD_LIBRARYY_PATH if you put GLPK library
> into an unusual place.
>
> Don't forget running ldconfig.
>
> On Windows the GLPK library must be in one of the directories indicated
> by %PATH%.
>
> Best regards
>
> Heinrich




Re: [Fwd: Portable version]

2020-11-02 Thread Heinrich Schuchardt
Am 2. November 2020 10:53:06 MEZ schrieb Andrew Makhorin :
> Forwarded Message 
>From: "Andraschko, Bernhard" 
>To: help-glpk@gnu.org 
>Subject: Portable version
>Date: Mon, 2 Nov 2020 07:21:45 +
>
>> Hi,
>> 
>> I'm currently working for the Chair of Symbolic Computation in Passau
>> and help developing ApCoCoA-2, a computer algebra framework mainly
>for
>> commutative algebra for Linux and for Windows.
>> 
>> We would like to include include a version of GLPK into our
>framework,
>> but have failed yet with compiling a portable standalone version of
>> glpsol as the configuration and the built always writes direkt paths
>> into many files. Also replacing all paths by new ones didn't help.
>> 
>> Is there a way to compile a portable version?
>> 
>> Best Regards
>> Bernhard Andraschko

Dear Bernhard,

please, provide a log of the errors that you observed.

On Linux you may have to set LD_LIBRARYY_PATH if you put GLPK library into an 
unusual place.

Don't forget running ldconfig.

On Windows the GLPK library must be in one of the directories indicated by 
%PATH%.

Best regards

Heinrich


Re: [Fwd: Help please]

2020-10-17 Thread Heinrich Schuchardt
On 10/17/20 7:24 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> From: Manuel Castro 
> To: help-glpk@gnu.org
> Subject: Help please
> Date: Sat, 17 Oct 2020 17:02:16 -
>
>> Hi there,
>>
>> I have the following constraint:
>>
>>
>> subject to linctr20 {i in 1..365}: 
>>    sum {j in (i - 1) * 48 + 1..(i * 48)} FlexibleLoadIncrease[j], <=

The comma should be removed.

>> FlexibleLoadEnergyRating * LoadPowerProfile[j];

j is the index for the sum on the left side. i is the index of the
constraint. So j cannot be used as index on the right side. Did you mean i?

Best regards

Heinrich

>>
>>
>> FlexibleLoadIncrease is a decision variable
>> whilst FlexibleLoadEnergyRating and LoadPowerProfile are param.
>>
>> I get the following error message:
>>
>> \Local\Temp\SolverStudio cyzbbe4o\model.txt:147: j not defined
>> Context: ...[ j ] , <= FlexibleLoadEnergyRating * LoadPowerProfile [ j
>> ]
>> MathProg model processing error
>>
>> I have spent hours and hours trying to resolve this by going through
>> the forums but couldn't find a solution. My last option was to contact
>> you. Any help would be appreciated. Many thanks.
>>
>> Kind regards,
>> MAnuel.
>




Re: GLPSOL in webassemby faster than native ?

2020-09-30 Thread Heinrich Schuchardt
On 9/30/20 10:02 PM, Michael Hennebry wrote:
> On Tue, 29 Sep 2020, Domingo Alvarez Duarte wrote:
>
>> I found why GLPK in wasm was faster with "--cuts" option than native,
>> it was due wasm using qsort from muslc that is a "stable sort", I've
>> added it to my GLPK repository and running all models in the
>> "examples" folder only "color.mod" produces a different solution (that
>> seems to be valid anyway).

My expectation is that all sort algorithms produce the same result if
you supply a sort key that is different for all elements.

Could you, please, elaborate where in the GLPK code you see a problem
due to an incomplete sort key?

Do you generally observe a faster solution time? Or do you have single
model that when solved in a specific sequence that by chance is produced
by muslc is faster?

Best regards

Heinrich

>
> Michael Hennebry wrote:
>
>> Roadblocks include the toolchain and the system libraries.
>
>> The math library can matter.
>
>
> How did you find it?
>




Re: Adding if/then/else statement to GMPL

2020-08-25 Thread Heinrich Schuchardt
Am 25. August 2020 20:17:06 MESZ schrieb Domingo Alvarez Duarte 
:
>Hello Heinrich !
>
>Here is better example from examples/shikaku.mod:
>

Just another example where the existing if-then-else expression can be used to 
shorten the code.

Anyway comparing a binary to =1 is not a good idea in GLPK. You should use > .5.

Best regards

Heinrich

>With if/then/else:
>
>=
>
>/* Output solution graphically */
>printf "\nSolution:\n";
>for { row in rows1 } {
>     for { col in cols1 } {
>     if (sum{(i,j,k,l,m,n) in B:
>     col >= l and col <= n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1} 1) > 0 then
>     {
>     if (sum{(i,j,k,l,m,n) in B:
>     row >= k and row <= m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1} 1) > 0 then printf "+";
>     else printf "-";
>     }
>     else
>     {
>     if (sum{(i,j,k,l,m,n) in B:
>     row >= k and row <= m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1} 1) > 0 then printf "|";
>     else printf " ";
>     }
>
>     if (sum{(i,j,k,l,m,n) in B:
>     col >= l and col < n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1} 1) > 0 then printf "---";
>     else printf "   ";
>     }
>     printf "\n";
>
>     for { col in cols: (sum{ s in rows: s = row } 1) = 1 } {
>     if (sum{(i,j,k,l,m,n) in B:
>     row >= k and row < m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1} 1) > 0 then printf "|";
>     else printf " ";
>    if (sum{ (i,j) in V: i = row and j = col} 1) > 0 then printf " 
>%2d", givens[row,col];
>     else printf "  .";
>     }
>     if (sum{ r in rows: r = row } 1) = 1 then printf "|\n";
>}
>
>=
>
>Original:
>
>=
>
>/* Output solution graphically */
>printf "\nSolution:\n";
>for { row in rows1 } {
>     for { col in cols1 } {
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     col >= l and col <= n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1}) > 0 and
>     card({(i,j,k,l,m,n) in B:
>     row >= k and row <= m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1}) > 0} "+";
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     col >= l and col <= n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1}) = 0 and
>     card({(i,j,k,l,m,n) in B:
>     row >= k and row <= m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1}) > 0} "|";
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     row >= k and row <= m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1}) = 0 and
>     card({(i,j,k,l,m,n) in B:
>     col >= l and col <= n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1}) > 0} "-";
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     row >= k and row <= m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1}) = 0 and
>     card({(i,j,k,l,m,n) in B:
>     col >= l and col <= n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1}) = 0} " ";
>
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     col >= l and col < n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1}) > 0} "---";
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     col >= l and col < n and (row = k or row = m) and
>     x[i,j,k,l,m,n] = 1}) = 0} "   ";
>     }
>     printf "\n";
>
>     for { (col,p) in { cols, 1 }: card({ s in rows: s = row }) = 1 } {
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     row >= k and row < m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1}) > 0} "|";
>     printf{0..0: card({(i,j,k,l,m,n) in B:
>     row >= k and row < m and (col = l or col = n) and
>     x[i,j,k,l,m,n] = 1}) = 0} " ";
>     printf{0..0: card({ (i,j) in V: i = row and j = col}) > 0} " 
>%2d", givens[row,col];
>    printf{0..0: card({ (i,j) in V: i = row and j = col}) = 0} " 
>.";
>     }
>     printf{0..0: card({ r in rows: r = row }) = 1} "|\n";
>}
>
>=
>
>Cheers !
>On 24/8/20 16:59, Heinrich S

Re: best Python interface for GLPK

2020-08-24 Thread Heinrich Schuchardt
Am 24. August 2020 19:35:25 MESZ schrieb Joshua Friedman :
>I have tried pymprog and while 0-1 integer programs and linear programs
>seems to work great, there might be a bug in integer programs. Is there
>a
>good interface for python I can use to teach my students. I also need
>to
>use sensitivity reports.
>Thanks

https://en.wikibooks.org/wiki/GLPK/Python has a list of known Python wrappers 
for GLPK.

Best regards

Heinrich






Re: Adding if/then/else statement to GMPL

2020-08-24 Thread Heinrich Schuchardt
On 24.08.20 16:33, Domingo Alvarez Duarte wrote:
> Hello Meketon !
>
> Could you share your view of how it would be expressed (an ideal model
> sample) ?
>
> If you want to talk about it, maybe I'll be interested in implement it !
>
> Can you share a collection of models data to be used as base for the
> test/implementation ?

Dear Domingo,

I do not yet understand what was you weren't able to express with the
current syntax.

Instead of

if length(p) == 3 then display "true 3"; else display "false 3";
if length(p) == 5 then display "true 5"; else display "false 5";

you can write:

param p,symbolic := "dad";
display if length(p) == 3 then "true 3" else "false 3";
display if length(p) == 5 then "true 5" else "false 5";
solve;
end;

Best regards

Heinrich



Re: [Fwd: installation help]

2020-07-16 Thread Heinrich Schuchardt
On 7/15/20 11:06 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> From: "Pandey, Sanjit" 
> To: help-glpk@gnu.org 
> Subject: installation help
> Date: Wed, 15 Jul 2020 20:45:19 +
>
>> Hi,
>>  
>> I keep getting following error when I try to install glpk for java.
>> Any idea what is going on ?
>>  
>> src/c/glpk_wrap.c:14977: error: ‘arg1’ undeclared (first use in this
>> function)
>> src/c/glpk_wrap.c:14977: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:14983: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI_LPXKKT_1cs_1quality_1set’:
>> src/c/glpk_wrap.c:14991: error: ‘LPXKKT’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:14991: error: ‘arg1’ undeclared (first use in this
>> function)
>> src/c/glpk_wrap.c:14991: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:14997: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI_LPXKKT_1cs_1quality_1get’:
>> src/c/glpk_wrap.c:15005: error: ‘LPXKKT’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:15005: error: ‘arg1’ undeclared (first use in this
>> function)
>> src/c/glpk_wrap.c:15005: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:15011: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI_new_1LPXKKT’:
>> src/c/glpk_wrap.c:15020: error: ‘LPXKKT’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:15020: error: ‘result’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:15035: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:15043: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI_delete_1LPXKKT’:
>> src/c/glpk_wrap.c:15049: error: ‘LPXKKT’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:15049: error: ‘arg1’ undeclared (first use in this
>> function)
>> src/c/glpk_wrap.c:15049: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:15053: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1create_1prob’:
>> src/c/glpk_wrap.c:15093: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1get_1prob_1name’:
>> src/c/glpk_wrap.c:15697: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1get_1obj_1name’:
>> src/c/glpk_wrap.c:15730: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1get_1row_1name’:
>> src/c/glpk_wrap.c:15864: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1get_1col_1name’:


Dear Sanjit,

symbol lpx_get_col_name() exists in GLPK 4.40 but not in GLPK 4.65.

So it seems that besides GLPK 4.65 an old version of GLPK is installed.
 And you tried to wrap the glpk.h from that old version.

Maybe you installed a GLPK version that came with your operating system
distribution.

Please, uninstall all old versions of GLPK and retry.

If you need further assistance, please, provide

* operating system
* installation paths
* full log including your input

Best regards

Heinrich

>> src/c/glpk_wrap.c:15899: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1check_1kkt’:
>> src/c/glpk_wrap.c:17213: error: ‘LPXKKT’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:17213: error: ‘arg3’ undeclared (first use in this
>> function)
>> src/c/glpk_wrap.c:17213: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:17221: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1check_1int’:
>> src/c/glpk_wrap.c:18172: error: ‘LPXKKT’ undeclared (first use in
>> this function)
>> src/c/glpk_wrap.c:18172: error: ‘arg2’ undeclared (first use in this
>> function)
>> src/c/glpk_wrap.c:18172: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c:18179: error: expected expression before ‘)’ token
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1read_1mps’:
>> src/c/glpk_wrap.c:18390: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1read_1freemps’:
>> src/c/glpk_wrap.c:18547: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1read_1cpxlp’:
>> src/c/glpk_wrap.c:18624: warning: cast to pointer from integer of
>> different size
>> src/c/glpk_wrap.c: In function
>> ‘Java_org_gnu_glpk_GLPKJNI__1glp_1lpx_1read_1model’:
>> 

Re: [Fwd: Need help in Fixing GUSEK Code]

2020-04-10 Thread Heinrich Schuchardt
On 4/10/20 11:57 AM, Andrew Makhorin wrote:
>  Forwarded Message 
> From: sahani rathnasiri 
> To: help-glpk@gnu.org
> Subject: Need help in Fixing GUSEK Code
> Date: Fri, 10 Apr 2020 19:08:39 +1000
>
>> Hi All,
>>
>> I am running code in GUSEK and I need to define three indexes. I am
>> getting a syntax error. Please help me fix this.
>> My constraint;
>> subject to order_quantity_constraint_min {i in I, j in J, n in N: i
>> <= t, j <> 2 and n <= r}: Z[i,j]* Qmin[i,n] <= a[i,n];
>>
>> The result I receive in NEOS;
>>
>> amplin, line 50 (offset 2865):
>>         syntax error
>> context:  subject to order_quantity_constraint_min {i in I, j in J, n
>> in N: i <=  >>> t, <<<  j <> 2 and n <= r}: Z[i,j]* Qmin[i,n] <=
>> a[i,n];

Dear Sahani,

the output points you to where the problem is: "t,".

Probably you mean

i <= t and j <> 2 and n <= r

Best regards

Heinrich

>> Executing AMPL.
>>
>> If anyone can help me, really appreciate your help in this regard.
>>
>> Thank You,
>>
>> Best Regards,
>>
>> Sahani 



Re: Submittingjob to NEOS Server using GUSEK and/or GLPSOL

2020-03-20 Thread Heinrich Schuchardt
On 3/20/20 8:53 AM, Heinrich Schuchardt wrote:
> On 3/20/20 3:37 AM, Deb Midya wrote:
>>
>>     Hi,
>>
>>
>> Thanks in advance.
>>
>> I'm using GUSEK on windows 10. I can submit a job and get solution
>> locally.
>>
>> Is it possible to submit a job to NEOS using GUSEK and/or GLPSOL?
>>
>> Regards,
>>
>> Deb
>>
>
> Hello Deb,
>
> do you refer to the content management system NEOS (https://www.neos.io/)?
>
> NEOS is written PHP. With PHP you could schedule a job and display its
> output.
>
> You could also write a PHP extension calling the GLPK library. The book
> Blake Schwendiman, "Building Custom PHP Extensions", p. 142ff has a
> chapter on wrapping GLPK in a PHP extension. Part of it is available at
> https://books.google.de/books?id=MzZ5WiISx5AC .
>
> Unfortunately it is unclear what you really want to do. Could you,
> please, describe it in more detail.
>
> Best regards
>
> Heinrich
>

On 3/20/20 5:23 PM, Bence Bagi wrote:
> Hello Heinrich,
>
> I believe Deb is talking about the NEOS Server for Optimization,
> available here: https://neos-server.org/neos/
>
> Best,
>
> Bence

https://neos-server.org/neos/solvers/index.html does not list GLPK.

So Deb would have to contact Wisconsin Institute for Discovery at the
University of Wisconsin if he wants GLPK to be hosted.

Best regards

Heinrich



Re: Submittingjob to NEOS Server using GUSEK and/or GLPSOL

2020-03-20 Thread Heinrich Schuchardt

On 3/20/20 3:37 AM, Deb Midya wrote:


Hi,


Thanks in advance.

I'm using GUSEK on windows 10. I can submit a job and get solution locally.

Is it possible to submit a job to NEOS using GUSEK and/or GLPSOL?

Regards,

Deb



Hello Deb,

do you refer to the content management system NEOS (https://www.neos.io/)?

NEOS is written PHP. With PHP you could schedule a job and display its
output.

You could also write a PHP extension calling the GLPK library. The book
Blake Schwendiman, "Building Custom PHP Extensions", p. 142ff has a
chapter on wrapping GLPK in a PHP extension. Part of it is available at
https://books.google.de/books?id=MzZ5WiISx5AC .

Unfortunately it is unclear what you really want to do. Could you,
please, describe it in more detail.

Best regards

Heinrich



Re: [Help-glpk] is this list (help-glpk) still active?

2020-03-03 Thread Heinrich Schuchardt




On 3/3/20 1:17 PM, Rémi Lapeyre wrote:




Le 26 juil. 2019 à 21:54, Heinrich Schuchardt  a écrit :

On 7/26/19 8:20 PM, Meketon, Marc via Help-glpk wrote:

I don’t recall receiving any emails for a few months.  I sent out a
request back in early June
(https://lists.gnu.org/archive/html/help-glpk/2019-06/msg0.html)
that did not generate any response, and prior to that there was some
traffic in April, but nothing in May or June or July (so far).  This
seems unusual so I’m wondering if something has changed.


Hello Marc,

the list still is functional. Looking at the downloads at
https://sourceforge.net/projects/glpk-java/files/glpk-java/stats/timeline?dates=2010-04-27+to+2019-07-26
interest in the software is constant. But we haven't seen any new
release for a while.

Best regards

Heinrich



Do you know where we can find the sources for GLPK?
There is only releases available at https://www.gnu.org/software/glpk/ and 
Wikipedia redirects to http://cvs.savannah.gnu.org/viewvc/glpk/ but I can’t 
find the source of the tarball there. There is also no information regarding 
how to contribute to the project or send a patch.


https://ftp.gnu.org/gnu/glpk/glpk-4.65.tar.gz
is the most current source tarball. There  is no Git code repository.

The main contributor Andrew Makhorin has previously integrated patches
sent to the GLPK help list.

Best regards

Heinrich



Re: Help with slow model translation

2020-02-21 Thread Heinrich Schuchardt

On 2/21/20 6:26 PM, Heinrich Schuchardt wrote:

On 2/21/20 5:46 PM, Greg Gruber wrote:

Hello,

I have a model that I have developed using MathProg, that I am using
regularly. Some problem datasets result in very large models. The
problem itself is solving very quickly, but I am finding the model
translation (reading the .mod file, data files, and setting up the
problem) to be very slow.

I came across this on the wikipedia entry: " The take-home message is
that nested set iterations should be avoided where possible, as these
greatly expand the dimensionality and size of the model space to be
processed.", and it discusses a case on the OSeMOSYS energy model where
the execution time was reduced from 15 hours to 9 minutes by a
reformulation.

Unfortunately, I'm not sure what they mean here, and I am looking for an
example. I have tried searching the OSeMOSYS site for more information,
as well as searching for publications by Jonas Horsch, who did the
reformulation, but have had no luck yet.

Does anybody have examples illustrating how to avoid nested-set
iterations in MathProg?

Thanks in advance,
Greg


Hello Greg,

please, provide an example model which shall be simplified.

Best regards

Heinrich




Thanks for the example model.

Using the GMPL language is not very efficient to formulate the complex
constraints you have.

For creating the problem formulation for very large problems I would
always prefer using a programming language like Java to generate the
model formulation and directly call the solver library from the
programming language.

Your problem has more than 30 million variables. I doubt that you will
get a solution for this size of a problem with GLPK.

Best regards

Heinrich



Re: Help with slow model translation

2020-02-21 Thread Heinrich Schuchardt

On 2/21/20 5:46 PM, Greg Gruber wrote:

Hello,

I have a model that I have developed using MathProg, that I am using
regularly. Some problem datasets result in very large models. The
problem itself is solving very quickly, but I am finding the model
translation (reading the .mod file, data files, and setting up the
problem) to be very slow.

I came across this on the wikipedia entry: " The take-home message is
that nested set iterations should be avoided where possible, as these
greatly expand the dimensionality and size of the model space to be
processed.", and it discusses a case on the OSeMOSYS energy model where
the execution time was reduced from 15 hours to 9 minutes by a
reformulation.

Unfortunately, I'm not sure what they mean here, and I am looking for an
example. I have tried searching the OSeMOSYS site for more information,
as well as searching for publications by Jonas Horsch, who did the
reformulation, but have had no luck yet.

Does anybody have examples illustrating how to avoid nested-set
iterations in MathProg?

Thanks in advance,
Greg


Hello Greg,

please, provide an example model which shall be simplified.

Best regards

Heinrich







Re: Off-by-one error when solving integer linear program

2019-12-17 Thread Heinrich Schuchardt

On 12/18/19 12:12 AM, Matthew Keeter wrote:

Hi folks,

I used GLPK to solve a problem in this year’s Advent of Code [1], and noticed
that it produces a very slightly wrong answer for one of the examples.

It’s an integer linear programming problem, pasted below the fold in CPLEX LP 
format.

The correct answer is 82892753, and I’m getting 82892752.

I’ve pasted my glpsol output at [2]

Strangely, other folks have gotten the correct answer with the same input;
there’s a reddit thread discussing it at [1].  I'm on a Mac OS 10.13.6,
GLPK 4.65, GMP 6.1.2, compiled with Apple LLVM version 10.0.0
(clang-1000.11.45.5)

Any ideas?


There are several tolerances taken into account by GLPK including
tol_int defaulting to 1e-5. If a problem is ill-conditioned, you may get
errors due to these tolerances.

Looking at your ore_consumption constraint you are looking for a
solution that is exact to a factor of 1 in 177 trillions. This is
nothing GLPK can deliver.

When running your problem with

./glpsol --lp ore.lp -o result

I get in file result:

Status: INTEGER OPTIMAL
Objective:  out = 82892753 (MAXimum)

KKT.PB: max.abs.err = 1.00e+00 on row 10
max.rel.err = 1.00e+00 on row 10
SOLUTION IS INFEASIBLE

So equation PSHF is not fulfilled by the solution GLPK provides.

Best regards

Heinrich



Aw: GLPK Java on Android

2019-12-11 Thread Heinrich Schuchardt


 
 Please, have a look at 

https://en.m.wikibooks.org/wiki/GLPK/Android_app

Best regards

Heinrich
Am 11.12.19, 23:57 schrieb "Yasmin M." :

  
   I'm trying to use the GLPK's library in the Android Studio adding it at the directory “libs” of the Project, however when I try to execute the application in the cell phone, in the moment that a function calls the library, it's crashing and showing a message that “libglpk-java.so” was not found. There is anyway to use the library in the Android Studio or will be a release soon with a version of the GLPK-Java that runs in the IDE?
   
 




Re: Issue with reading from Excel

2019-12-09 Thread Heinrich Schuchardt
Hello Marc,

which driver are you using?

Your current directory is assumed to be examples\sql.
Did you cd to that directory?

Best regards

Heinrich Schuchardt

http://www.xypron.de

Am 09.12.19 um 16:23 schrieb Meketon, Marc\ via \Users list for GLPK (GNU 
Linear Programming Kit)

> Hello GLPK’ers
> 
> I’m trying to use GMPL to read from Excel.  Below is essentially from the 
> Sudok_excel.mod example found in the distribution, but where I updated it 
> with a later driver:
> 
> set fields dimen 2;
> param givens{1..9, 1..9}, integer, >= 0, <= 9, default 0;
> /* the "givens" */
> 
> table ti IN 'ODBC'
>   'DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};'
>   'dbq=C:\glpk_463\examples\sql\sudoku.xlsx'
>   'SELECT ID, COL, LIN, VAL FROM [Sudoku$] '
>   'WHERE ID = 1' :
>   fields <- [COL, LIN], givens ~ VAL;
> 
> end;
> 
> ==>When I run this, two problems occur, and help would be appreciated:
> ==>  1.  A window pops up asking me which Excel file to use.  Is there a way 
> to eliminate it?
> ==>  2.  I get the error below.  This is really important to solve.  I have 
> tried both named ranges for the Excel data, and worksheet names (that end 
> with a $).
> 
> GLPSOL: GLPK LP/MIP Solver, v4.57
> Parameter(s) specified in the command line:
>  --cover --clique --gomory --mir -m sudoku_excel.mod
> Reading model section from sudoku_excel.mod...
> 12 lines were read
> Reading ti...
> Connected to EXCEL 12.00. - C:\glpk_463\examples\sql\sudoku.xlsx
> SELECT COL, LIN, VAL FROM WHERE ID = 1
> db_iodbc_open: Query
> "SELECT COL, LIN, VAL FROM WHERE ID = 1"
> failed.
> 
> The driver reported the following diagnostics whilst running SQLExecDirect
> 42000:1:-3506:[Microsoft][ODBC Excel Driver] Syntax error in FROM clause.
> sudoku_excel.mod:5: error on opening table ti
> MathProg model processing error




Re: [Help-glpk] Interrupting GLPK on demand

2019-10-14 Thread Heinrich Schuchardt

On 10/14/19 7:26 PM, Szabolcs Horvát wrote:

Hello Heinrich,

Thanks for the suggestion.

Would this method not prevent any allocated memory from being cleaned
up? I am not very familiar with GLPK yet, but the need for
setjmp/longjmp suggests that any cleanup steps would be skipped.


In the error hook function you should call glp_free_env(). This will
free all memory allocated by calling GLPK functions in the current thread.

Cf.
https://sourceforge.net/p/winglpk/code/HEAD/tree/trunk/examples/c/glp_error_hook_demo.c

glpk-4.65/examples/threads/multiseed.c is an example showing error
handling for multi-threaded applications.

Best regards

Heinrich



Best regards,
Szabolcs

On Mon, 14 Oct 2019 at 19:11, Heinrich Schuchardt  wrote:


Hello Szabolcs,

you can create a terminal hook function (see glp_term_hook()). In this
hook function you can trigger an abort using glp_error(). Use a error
hook function (see glp_error_hook()) to catch the error and longjmp() to
return to the setjmp() in the calling program.

An example in Java is available as:

https://sourceforge.net/p/glpk-java/code/HEAD/tree/trunk/examples/java/GmplSwing.java

An example for an error hook function in C is available as:

https://sourceforge.net/p/winglpk/code/HEAD/tree/trunk/examples/c/glp_error_hook_demo.c

Best regards

Heinrich

On 10/14/19 2:45 PM, Szabolcs Horvát wrote:

Hello,

Is there a way to interrupt GLPK without killing the entire process?

I am interested in terminating glp_intopt(). In principle, this is
possible by calling glp_ios_terminate() from the callback function
passed to glp_intopt(). However, glp_intopt() will internally call
glp_simplex(), which may take a very long time. Thus in practice this
does not work. I could not find any way to interrupt glp_simplex() on
demand.  It is possible to set a time limit (tm_lim in glp_smcp), but
this is not what I need. I would like to have the ability to
interactively interrupt the computation.

For example, glp_simplex() could periodically call a user-supplied
function. If this function returns "true", the computation should be
interrupted gracefully.

I do not need a partial result to be returned. I simply need a clean
interruption, with the resources used by the function properly cleaned
up (e.g. no unreleased memory). I assume that this is possible, since
a time limit is already implemented. In principle, I could even look
up the part of the code that checks the time, and add an additional
interruption check. I am wondering why this wasn't implemented
already, and whether simply doing this would cause any problems. Some
old messages posted to this mailing list seem to suggest that
implementing interruption may not be easy, which seems to be in
contradiction with the fact that a time limit is already implemented.
https://lists.gnu.org/archive/html/help-glpk/2006-04/msg00059.html

Summary:

   - Is there a way to interrupt glp_intopt() cleanly and reliably?
   - If not, consider this a feature request. Please add this functionality.
   - Would there be an issue with extending the time-limit check to also
call a user-supplied interruption-check function?

Use case:

I am not very familiar with ILP solvers. I am actually using graph
theory code that relies on GLPK. I am using this code from a
high-level language that is typically used interactively (think Python
in a Jupyter notebook). Given the nature of the problems that GLPK
solves, it is very hard to predict how long a computation would take.
It could be seconds or days. Therefore, it is important to be able to
interrupt computations gracefully, without needing to kill the entire
session.

In particular, this problem came up while working on the igraph
library: https://github.com/igraph/igraph/issues/897

Best regards,
Szabolcs

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








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


Re: [Help-glpk] Interrupting GLPK on demand

2019-10-14 Thread Heinrich Schuchardt

Hello Szabolcs,

you can create a terminal hook function (see glp_term_hook()). In this
hook function you can trigger an abort using glp_error(). Use a error
hook function (see glp_error_hook()) to catch the error and longjmp() to
return to the setjmp() in the calling program.

An example in Java is available as:

https://sourceforge.net/p/glpk-java/code/HEAD/tree/trunk/examples/java/GmplSwing.java

An example for an error hook function in C is available as:

https://sourceforge.net/p/winglpk/code/HEAD/tree/trunk/examples/c/glp_error_hook_demo.c

Best regards

Heinrich

On 10/14/19 2:45 PM, Szabolcs Horvát wrote:

Hello,

Is there a way to interrupt GLPK without killing the entire process?

I am interested in terminating glp_intopt(). In principle, this is
possible by calling glp_ios_terminate() from the callback function
passed to glp_intopt(). However, glp_intopt() will internally call
glp_simplex(), which may take a very long time. Thus in practice this
does not work. I could not find any way to interrupt glp_simplex() on
demand.  It is possible to set a time limit (tm_lim in glp_smcp), but
this is not what I need. I would like to have the ability to
interactively interrupt the computation.

For example, glp_simplex() could periodically call a user-supplied
function. If this function returns "true", the computation should be
interrupted gracefully.

I do not need a partial result to be returned. I simply need a clean
interruption, with the resources used by the function properly cleaned
up (e.g. no unreleased memory). I assume that this is possible, since
a time limit is already implemented. In principle, I could even look
up the part of the code that checks the time, and add an additional
interruption check. I am wondering why this wasn't implemented
already, and whether simply doing this would cause any problems. Some
old messages posted to this mailing list seem to suggest that
implementing interruption may not be easy, which seems to be in
contradiction with the fact that a time limit is already implemented.
https://lists.gnu.org/archive/html/help-glpk/2006-04/msg00059.html

Summary:

  - Is there a way to interrupt glp_intopt() cleanly and reliably?
  - If not, consider this a feature request. Please add this functionality.
  - Would there be an issue with extending the time-limit check to also
call a user-supplied interruption-check function?

Use case:

I am not very familiar with ILP solvers. I am actually using graph
theory code that relies on GLPK. I am using this code from a
high-level language that is typically used interactively (think Python
in a Jupyter notebook). Given the nature of the problems that GLPK
solves, it is very hard to predict how long a computation would take.
It could be seconds or days. Therefore, it is important to be able to
interrupt computations gracefully, without needing to kill the entire
session.

In particular, this problem came up while working on the igraph
library: https://github.com/igraph/igraph/issues/897

Best regards,
Szabolcs

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




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


Re: [Help-glpk] is this list (help-glpk) still active?

2019-07-26 Thread Heinrich Schuchardt

On 7/26/19 8:20 PM, Meketon, Marc via Help-glpk wrote:

I don’t recall receiving any emails for a few months.  I sent out a
request back in early June
(https://lists.gnu.org/archive/html/help-glpk/2019-06/msg0.html)
that did not generate any response, and prior to that there was some
traffic in April, but nothing in May or June or July (so far).  This
seems unusual so I’m wondering if something has changed.


Hello Marc,

the list still is functional. Looking at the downloads at
https://sourceforge.net/projects/glpk-java/files/glpk-java/stats/timeline?dates=2010-04-27+to+2019-07-26
interest in the software is constant. But we haven't seen any new
release for a while.

Best regards

Heinrich


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


Re: [Help-glpk] [Fwd: Installation of software]

2019-04-07 Thread Heinrich Schuchardt
On 4/7/19 7:21 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: m...@gnu.org
> Subject: Installation of software
> Date: Sat, 6 Apr 2019 16:30:11 +0430
>
>> Dear GLPK team,
>> I have downloaded GLPK package (version 4.65) and wanted to run it on
>> a 64-bit windows. However, I could not find the steps to install the
>> software. Could you please let me know how can I install it?
>> Thank you very much and I am looking forward to hearing from you.
>> Best regards
>>  
>

Hello Reza,

you can download a precompiled version of GLPK for Windows from

https://sourceforge.net/projects/winglpk/

The glpsol 64bit executable and the DLLs are in folder w64.
To start glpsol open the command shell and navigate to that folder.

If you want a GUI around glpsol have a look at
http://gusek.sourceforge.net/gusek.html

Best regards

Heinrich


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


Re: [Help-glpk] stalled GLPK when launching ret = glp_simplex in VBA

2019-02-27 Thread Heinrich Schuchardt
Hello Jean-Christophe,

the data you provide is insufficient for an analysis. What is needed is
the actual problem or at least the relevant debug output of glp_simplex().

The term_hook() function in
https://sourceforge.net/p/winglpk/code/HEAD/tree/trunk/examples/vba/glpk.bas
is printing to the debug console. What is the output of glp_simplex when
stalling?

Inside the terminal hook function you could call glp_error() when a
problem takes too long. This would allow you to gracefully terminate at
least. Or call do_events in the terminal hook function to allow stopping
via the debug controls.

You could use function gpl_write_prob(), glp_write_lp(), glp_write_mps()
to save the current problem to disk betore calling glp_simplex(). When a
problem "stalls" try to run the saved file with glpsol to see if for
this instance the problem is reproducible outside of your VBA program.

Best regards

Heinrich

On 2/27/19 5:42 PM, Huber, Jean-Christophe wrote:
> Dear GLPK users,
> 
>  
> 
> I developed a model using GLPK v64 dll from VBA in Excel. This model is
> mapping several initial conditions and thus launches the solver in many
> successive “nodes” of initial conditions.
> 
> For some of them, even if seldom, we have a stalling problem within the
> dll itself. We first tried removing the scaling option as it removes
> most these occurrence but this is also not 100% OK.
> 
>  
> 
> Are there some ways to know why the simplex is stalling? Or any way to
> facilitate solutions with some options?
> 
>  
> 
> At the moment, the only options I use are similar to the VBA example
> given in V64 package (see below)
> 
>  
> 
> Many thanks for any hints or advice!
> 
>  
> 
> Regards
> 
> Jean-Christophe Huber
> 
>  
> 
>  
> 
> ' 
> 
>     '  link with dll calculation
> 
>     ' 
> 
>    
> 
> '-- Management of solver errors
> 
>     On Error GoTo error0
> 
>  
> 
> ' Register error hook function
> 
>     glp_error_hook AddressOf error_hook
> 
>    
> 
> ' Register terminal hook function
> 
>     glp_term_hook AddressOf term_hook
> 
>  
> 
>   
> 
> '-- Creation of the calculation object
> 
>     lp = glp_create_prob()
> 
>     Name = str2bytes("glpVBA")
> 
>     glp_set_prob_name lp, Name(0)
> 
>    
> 
> glp_term_out GLP_OFF
> 
>  
> 
>     '-- Variables names and bounds, objective cost and integer option
> 
>     ' Set the number of variables
> 
>     glp_add_cols lp, NbVariables
> 
>    
> 
> ' Define each variable
> 
>     For variable_index = 1 To NbVariables
> 
>     ' set variable name
> 
>     Name = str2bytes(Variable_name(variable_index))
> 
>     glp_set_col_name lp, variable_index, Name(0)
> 
>    
> 
> ' set variable kind
> 
>     ' kind of structural variable:
> 
>     ' GLP_CV = 1    continuous variable
> 
>     ' GLP_IV = 2    long variable
> 
>     ' GLP_BV = 3    binary variable
> 
>     ' glp_set_col_kind lp, #col, #kind
> 
>    
> 
> ' set variable type of bound and bounds values
> 
>     ' Bounds Management
> 
>     'GLPK_FR   free variable:  -inf <  x[k] < +inf
> 
>     'GLPK_LO   lower bound:    l[k] <= x[k] < +inf >> ">="
> 
>     'GLPK_UP   upper bound:    -inf <  x[k] <= u[k] >> "<="
> 
>     'GLPK_DB   double bound:   l[k] <= x[k] <= u[k]
> 
>     'GLPK_FX   fixed variable: l[k]  = x[k]  = u[k] >> "="
> 
>     Select Case Variable_BoundType(variable_index)
> 
>     Case "FX"
> 
>     glp_set_col_bnds lp, variable_index, GLP_FX,
> Variable_LoBound(variable_index), Variable_UpBound(variable_index)
> 
>     Case "UP"
> 
>     glp_set_col_bnds lp, variable_index, GLP_UP, 0,
> Variable_UpBound(variable_index)
> 
>     Case "LO"
> 
>     glp_set_col_bnds lp, variable_index, GLP_LO,
> Variable_LoBound(variable_index), 0
> 
>     Case "FR"
> 
>     glp_set_col_bnds lp, variable_index, GLP_FR, 0, 0
> 
>     Case "DB"
> 
>     If Abs(Variable_LoBound(variable_index) -
> Variable_UpBound(variable_index)) <= epsilon Then
> 
>     glp_set_col_bnds lp, variable_index, GLP_FX,
> Variable_LoBound(variable_index), Variable_UpBound(variable_index)
> 
>     Else
> 
>     glp_set_col_bnds lp, variable_index, GLP_DB,
> Variable_LoBound(variable_index), Variable_UpBound(variable_index)
> 
>     End If
> 
>     End Select
> 
>    
> 
> ' set objective cost for each variable
> 
>     glp_set_obj_coef lp, variable_index,
> Variable_ObjectiveCost(variable_index)
> 
>     Next
> 
>  
> 
>  
> 
>     '-- Constraints names and bounds
> 
>     ' Set the number of constraints
> 
>     glp_add_rows lp, NbConstraints
> 
>    
> 
> ' Define each constraint
> 
>     For constraint_index = 1 To NbConstraints
> 
>     ' set 

Re: [Help-glpk] Use of GLPK with other software

2018-12-28 Thread Heinrich Schuchardt
On 12/29/18 8:15 AM, Federico Miyara wrote:
> 
> Hi,
> 
> I've just subscribed to this list. My field is acoustics and I plan to
> use the solver to optimize combinations of sounds to comply with certain
> constraints for their use in experiments. The problem boils down to a
> mixed integer linear programming case.
> 
> I would like to know if it is possible to call this library from
> mathematical software such as Scilab or Octave (or Matlab). I could
> prepare the input data within the Scilab environment, then I would need
> to call the solver and finally retrieve the solutions for further use
> within the Scilab environment.
> 
> I'm working with version 6.0.1 of Scilab on Windows 7 and I've
> downloaded the most recent version of GLPK.

A plugin for Scilab exists:
https://github.com/ycollet/scilab-mip/blob/master/sciglpk/

A Matlab plugin is provided here:
http://glpkmex.sourceforge.net/

Using GLPK with Octave is described in
https://octave.org/doc/v4.0.0/Linear-Programming.html

I have not worked with any of these.

Best regards

Heinrich

> 
> In case it is possible, what steps should I follow to "make it happen"?
> 
> Is it necessary to compile the library? How?
> 
> As my knowledge of C is quite elementary, any practical hint regarding
> the shortest path towards my goal (including readings) will be appreciated.
> 
> Regards,
> 
> Federico Miyara
> Argentina   
> 
> 
>   Libre de virus. www.avast.com
> 
> 
> 
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] GLPK input format

2018-08-29 Thread Heinrich Schuchardt
On 03/12/2018 07:09 AM, aku...@tezu.ernet.in wrote:
> Hi, I am a beginner with glpk and wanted to know if we can input a .tsv
> file into glpsol.

You can read a comma separated file via the table command. See the
examples/csv folder and doc/gmpl.pdf. Tab separated files are not
supported. For larger data sets you can also use an ODBC data source.

Best regards

Heinrich

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


Re: [Help-glpk] Help solving a scheduling optimisation problem

2018-07-12 Thread Heinrich Schuchardt
Hello Joaquim,

I guess the constraints are easier to write, if a binary is 1 if it matches the first occupied timeslot of a job and zero for all other timeslots.

Best regards

Heinrich
Am 12.07.18, 23:34, "Joaquim Leitão"  schrieb:

  
Hi All,

I am fairly new to glpk and linear programming. I am working on a
scheduling problem, and have been facing some problems in the
specification of one of its constraints.

The variables in my problem are binary, encoding the schedule for a
given series of jobs. In my problem I have a total of n time
slots that can be used to schedule certain jobs: If I was
considering a total of three jobs I would have three sets of
variables - xA, xB and xC, all of dimension n -, and for a
given index i (1 <= i <= n) if xA[i] = 1 then job A
would be scheduled for time slot i.

My problem is related to the fact that, while some jobs only require
one time slot to complete; others may require multiple, consecutive
time slots. Imagine that a given job - job B, for example - requires
2 time slots. I know that xB must only take the value "1" in 2
consecutive time slots, taking the value "0" in the remaining (n-2)
slots. But how can I write this as a problem constraint?

I have tried to make use of the exists keyword but as far as
I can understand I cannot use it in constraints in linear
problems... An obvious constraint that comes to mind is to make the
sum of xB for all i be equal to 2 (sum{i in 1..n} xB[i]  =
2), but this only restricts the total number of assigned slots and
does not make them consecutive.

Any suggestions/comments are very welcome.

Best regards,
Joaquim

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


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


Re: [Help-glpk] [Fwd: WINGLPK-4.57]

2018-06-10 Thread Heinrich Schuchardt



The current version is 4.65
I have no probem downloading from
https://sourceforge.net/projects/winglpk/files/latest/download

Version 4.57 is available at
https://sourceforge.net/projects/winglpk/files/winglpk/GLPK-4.57/winglpk-4.57.zip/download

GLPK for Windows contains the GLPK binaries, the Java and the CLI/C#
bindings.

You will additionally need a Python binding if you want to call GLPK
from Python 3. See https://en.wikibooks.org/wiki/GLPK/Python for options.

Best regards

Heinrich Schuchardt


On 06/10/2018 01:39 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: help-glpk@gnu.org 
> Subject: WINGLPK-4.57
> Date: Sun, 10 Jun 2018 08:36:55 + (UTC)
> 
> Hello,
> 
> I tried with sourceforge.net but failed to get
> winglpk-4.57.zip. If possible please let me know any other other version
> compatible with windows 7 and python version>3. Please send me its link
> 
> Thanks,
> 
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] [Fwd: Hello. I need a example to use GLPK java for MIP.]

2018-05-16 Thread Heinrich Schuchardt



On 05/16/2018 01:39 PM, Andrew Makhorin wrote:

 Forwarded Message 
To: help-glpk@gnu.org 
Subject: Hello. I need a example to use GLPK java for MIP.
Date: Wed, 16 May 2018 10:39:46 + (UTC)

Dear help-glpk.


I'm a student learning optimization.


I'm doing optimization modeling in JAVA.


However, there are only 1-dimension variables among the existing
examples
Can you give me an example that has more than 2-dimensional variables?


For example,
If the objective function is sum (s in S, p in P) x (s, p)


Hello Minjun,

sets (like S and P) are not supported by the GLPK library. So you have 
to create a column for each combination of s and p in your own Java coding.


If that looks too tedious, the code at
https://www.xypron.de/projects/linopt/
might help you. See the example a
https://www.xypron.de/projects/linopt/examples.html

Best regards

Heinrich




forall (s in S, p in P) x (s, p) is_binary
I want to show it in java.


Could you pass me some more difficult examples than the example in the
existing folder?


Thank you.


Best regards.



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



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


Re: [Help-glpk] [Fwd: Hi. Can you tell me how to limit on variables GLPK has?]

2018-05-15 Thread Heinrich Schuchardt
Hello Min-jun,

your mail had to be forwarded manually because you are not subscribed to
the GLPK help list, cf. https://lists.gnu.org/mailman/listinfo/help-glpk

I am not sure whether I have correctly understood your questions. So
maybe the answers below are not what you were looking for. Don't
hesitate to ask again.

The number of constraints and variables is limited by memory and by
INT_MAX (2 ^ 31 - 1).

Well conditioned LP problems with a few hundred thousand rows and
variables may be solvable. Badly conditioned LP problems with less then
1 variables may fail to be solved.

MIP problems with less then 100 binary variables may not solve in
reasonable time. Some other MIPs with several 1000 binaries have been
solved successfully with GLPK.

A Java binding is available at http://glpk-java.sourceforge.net/
If you are using Windows you could download the GLPK for Windows code
from https://sourceforge.net/projects/winglpk/
It comprises GLPK for Java.

There is also a WikiBook available at
https://en.wikibooks.org/wiki/GLPK

Best regards

Heinrich

On 05/15/2018 06:16 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: help-glpk@gnu.org
> Subject: Hi. Can you tell me how to limit on variables GLPK has?
> Date: Tue, 15 May 2018 23:55:36 +0900
> 
> Dear. GLPK.
> 
> Hello. I am a student who tries to solve the optimization problem using
> GLPK's Solver.
> 
> I am wondering how many constraints on variables GLPK has.
> 
> Can you tell me how to limit GLPK to Java API by linking it?
> 
> Thank you.
> 
> Best regards.
> 

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


Re: [Help-glpk] Requesting for help

2018-05-11 Thread Heinrich Schuchardt
Hello Megersa,

if your problem is infeasable than with and without presolver there
simply is no solution to retrieve.

If you are calling GLPK via the API you could use glp_get_unbnd_ray() to
determine which variable causes your problem to be infeasable. Next you
could relax the constraints on this variable.

Best regards

Heinrich

On 05/11/2018 08:28 PM, Megersa Tesfaye wrote:
> Hi, I develop a CLEWS model for Ethiopia as my PhD dissertation and when
> I run a model it says,there is no Primal feasible, use nopresol to have
> actual solution. my question is how can I use nopresol to get actual
> solution until I iterate the parameters and make the solution feasible.
> Love to hear from you
> 
> */Megersa Tesfaye
> /*
> */PhD Candidate(Water Resources Engineering),/*
> */M.SC  in Hydrology & Water Resources /   B.SC
>  in Civil Engineering  /    B.SC  in SWC Eng.
> /*
> */Mobile: 0911724512 / 0909789583/*
>          
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] [Fwd: Requesting for help]

2018-05-11 Thread Heinrich Schuchardt
Hello Megersa,

your message had to be forwarded manually because you are not subscribed
to the GLPK help list,
cf. https://lists.gnu.org/mailman/listinfo/help-glpk

NO PRIMAL OPTIMUM SOLUTION simply indicates that you try to solve
problem for which no solution exists.

You are using OSeMOSYS to generate the CSV files passed to the provided
model. So the error could be in the data that you provide to OSeMOSYS,
or in the OSeMOSYS model.

Without accesss to your model and data it is impossible to say due to
which constraint the problem has no solution.

If you cannot figure this out, I guess the first to approach are the
maintainers of OSeMOSYS (http://www.osemosys.org/contact-us1.html).

If you still think this is a GLPK specific problem, please, provide a
reproducable example, e.g. the GMPL model, the CSV files, and the
parameters passed to GLPK.

Best regards

Heinrich

On 05/09/2018 09:02 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: help-glpk-ow...@gnu.org
> Subject: Requesting for help
> Date: Thu, 10 May 2018 05:12:27 +1200
> 
> Dear, I run OSeMOSYS using glpk solver and after generating a model
> successfully it says NO PRIMAL OPTIMUM SOLUTION...ant help.
> 
> 
> Megersa Tesfaye
> 
> PhD Candidate(Water Resources Engineering),
> M.SC in Hydrology & Water Resources /   B.SC in Civil Engineering  /
> B.SC in SWC Eng.
> 
> Mobile: 0911724512 / 0909789583
>   
> 
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] How to linearize a weighted average with a decision variable?

2018-04-26 Thread Heinrich Schuchardt
On 04/25/2018 03:15 AM, Matt wrote:
> Hi all,
> 
> I'm trying to model a problem but it turned out to be non linear.
> 
> A simplified version of the model is written below. Basically it
> averages the weighted value of all enabled points, provided there are
> exactly M enabled points.
> 
> *max sum(i) { enabled[i] * value[i] * weight[i] } / sum(i) { enabled[i]
> * weight[i] }*
> *s.t. sum (i) enabled[i] = M

If there are no further constraints there is no need for a MIP solver.
The problem can be solved by sorting by value and weight.

If the number of binaries is small (<= 20) you will be able to iterate
over all permutations with sum(enabled) = M sorted by descending
objective and to take the first combination satisfying all constraints.

Regards

Heinrich

> *
> 
> - *value*is a vector of decimal numbers in [0, 1] (precomputed)
> - *weight*is a vector of decimal numbers in [0, 1] (precomputed)
> - *enabled*is a vector of either 0 or 1 (decision variable)
> 
> The model is very simple so I'm guessing there probably is a way to
> linearize it or some workaround I'm not aware of.
> 
> Thanks,
> Matt
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] [Fwd: Help for GLPK Java program]

2018-04-12 Thread Heinrich Schuchardt

Dear Titouan,

the library functions are described in detail in file doc/glpk.pdf of 
the GLPK source distribution. Have a look at the chapter "Problem 
retrieving routines". See for instance glp_get_mat_row() and 
glp_get_mat_col().


Best regards

Heinrich

On 04/12/2018 12:12 PM, Andrew Makhorin wrote:

 Forwarded Message 
From: SORANGE DELIEGE Titouan
To: help-glpk@gnu.org 
Subject: Help for GLPF java program
Date: Thu, 12 Apr 2018 10:32:40 +0200

Good morning,

  


I am currently working on a linear programming project using GLPK and
Java.

  


I have built the matrix that I need to give to GLPK (with the three
arguments ia, ja and ar with the glp_load_matrix method) and I have set
all the coefficients for each constraint of my problem.

  


I would like to print all the coefficients from the ar array to have an
overview of the matrix from GLPK (before the solving) but I don’t know
which function I should use for that. I tried to use
GLPK.glp_get_row_prim for each line and each column of that same line
(with a loop) but the values are all set at 0 and it seems fair as this
function is used for LP relaxation…

Thank you for your help.

  


Regards,

  


Titouan





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



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


Re: [Help-glpk] Controlling Precision of Variable Bounds

2018-04-04 Thread Heinrich Schuchardt
In  src/api/prmip.c the output is limited to 6 digits of precision
(%13.6g). So this is only an output issue.

If you use the GMPL language to specify your problem you can indicate
the output precision in the printf statement.

Best Regards

Heinrich

var P, integer >= 0, <=33;
var x0, integer, >= 0;
var x1, integer, >= 0;
var x2, >= 0, <= 217.3512;
var x3, integer, >= 0;
var x4, integer, >= 0;
var x5, integer, >= 0, <= 154;
maximize obj: P;
s.t. _C1: - 9.8796 * P + 10 * x0 + 10 * x1 + x2 = -108.6756;
s.t. _C2: - 7 * P + 7 * x3 + 7 * x4 + x5 = -77;
solve;
printf "P,  %13.12g (%13.12g, %13.12g)\n", P, P.lb, P.ub;
printf "x0, %13.12g (%13.12g, %13.12g)\n", x0, x0.lb, x0.ub;
printf "x1, %13.12g (%13.12g, %13.12g)\n", x1, x1.lb, x1.ub;
printf "x2, %13.12g (%13.12g, %13.12g)\n", x2, x2.lb, x2.ub;
printf "x3, %13.12g (%13.12g, %13.12g)\n", x3, x3.lb, x3.ub;
printf "x4, %13.12g (%13.12g, %13.12g)\n", x4, x4.lb, x4.ub;
printf "x5, %13.12g (%13.12g, %13.12g)\n", x5, x5.lb, x5.ub;
end;

On 04/04/2018 04:41 PM, marky1991 . wrote:
> I'm trying to solve a problem that has noninteger bounds for its
> variables, the problem and the outputted solution attached. I'm invoking
> glpsol with the command "glpsol --lp parents_allocated-pulp.lp -o
> parents_allocated-pulp.sol --mipgap 0.01".
> 
> The trouble is that the upper bound for my "x2" variable is being
> limited to "217.351" instead of the given "217.3512" and I'm not sure
> why. Is there some parameter I can pass to make it go past 3 decimal
> places for the upper bound?
> 
> I tried --exact and every other parameter that I could see but none
> helped. Is there some way to increase the number of digits in the bounds?
> 
> My output with 4.65:
> 
> GLPSOL: GLPK LP/MIP Solver, v4.65
> Parameter(s) specified in the command line:
>  --lp parents_allocated-pulp.lp -o parents_allocated-pulp2.sol --mipgap
> 0.01
> Reading problem data from 'parents_allocated-pulp.lp'...
> 2 rows, 7 columns, 8 non-zeros
> 6 integer variables, none of which are binary
> 22 lines were read
> GLPK Integer Optimizer, v4.65
> 2 rows, 7 columns, 8 non-zeros
> 6 integer variables, none of which are binary
> Preprocessing...
> 1 row, 2 columns, 2 non-zeros
> 2 integer variables, none of which are binary
> Scaling...
>  A: min|aij| =  1.000e+00  max|aij| =  7.000e+00  ratio =  7.000e+00
> Problem data seem to be well scaled
> Constructing initial basis...
> Size of triangular part is 1
> Solving LP relaxation...
> GLPK Simplex Optimizer, v4.65
> 1 row, 2 columns, 2 non-zeros
> * 0: obj =   1.1e+01 inf =   0.000e+00 (1)
> * 1: obj =   3.3e+01 inf =   0.000e+00 (0)
> OPTIMAL LP SOLUTION FOUND
> Integer optimization begins...
> Long-step dual simplex will be used
> + 1: mip = not found yet <=  +inf    (1; 0)
> + 1: >   3.3e+01 <=   3.3e+01   0.0% (1; 0)
> + 1: mip =   3.3e+01 <= tree is empty   0.0% (0; 1)
> INTEGER OPTIMAL SOLUTION FOUND
> Time used:   0.0 secs
> Memory used: 0.1 Mb (59394 bytes)
> Writing MIP solution to 'parents_allocated-pulp.sol'...
> 
> Thanks for the help.
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] Compiling and linking problems

2018-03-16 Thread Heinrich Schuchardt
Hello Mike,

https://stackoverflow.com/questions/6394512/standard-c-library-in-mingw
writes:
"MinGW is designed to build native Windows code, and as such it builds
against Windows' native libc."

So probably you want to change this line in src/env/stdc.c:

-#elif defined(__WOE__)
+#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__WOE__)

Please, reply if this works. Then Andrew could update it in the next
version of GLPK.

There might be more lines needing such a change:

examples/glpsol.c:956:#ifndef __WOE__
src/env/time.c:88:#elif defined(__WOE__)
src/env/dlsup.c:107:#elif defined(__WOE__)
src/env/tls.c:85:#ifdef __WOE__
src/env/stdc.c:52:#elif defined(__WOE__)

Best regards

Heinrich


On 03/15/2018 02:35 PM, mike.stegl...@berlin.de wrote:
> Dear GLPK-Team,
> 
>  
> 
> I have got some problems with building glpk 4.65 on Windows 10 with
> msys/mingw.
> 
>  
> 
> I tried to build it with:
> 
> ./configure --enable-static --disable-shared
> 
> make
> 
>  
> 
> Configure finished without problems. All sources are compiled without
> errors.
> 
> But it ends with the following issues:
> 
> …
> 
> /bin/sh ../libtool --tag=CC   --mode=link gcc  -g -O2   -o glpsol.exe
> glpsol.o ../src/libglpk.la -lm
> 
> libtool: link: gcc -g -O2 -o glpsol.exe glpsol.o  ../src/.libs/libglpk.a
> 
> ../src/.libs/libglpk.a(libglpk_la-stdc.o): In function `glp_xgmtime':
> 
> C:\Users\Mike\Documents\Projekte\CMPL-1-12\Cmpl\data\glpk-4.65\src/env/stdc.c:81:
> undefined reference to `gmtime_r'
> 
> ../src/.libs/libglpk.a(libglpk_la-stdc.o): In function `glp_xstrtok':
> 
> C:\Users\Mike\Documents\Projekte\CMPL-1-12\Cmpl\data\glpk-4.65\src/env/stdc.c:93:
> undefined reference to `strtok_r'
> 
> collect2.exe: error: ld returned 1 exit status
> 
> make[2]: *** [glpsol.exe] Error 1
> 
> make[2]: Leaving directory
> `/Documents/Projekte/CMPL-1-12/Cmpl/data/glpk-4.65/examples'
> 
> make[1]: *** [all-recursive] Error 1
> 
> make[1]: Leaving directory
> `/Documents/Projekte/CMPL-1-12/Cmpl/data/glpk-4.65'
> 
> make: *** [all] Error 2  
> 
>  
> 
>  
> 
> I have seen that in stdc.c are alternative versions of some function
> depending on some defines. But I am not sure what is  do do. I was
> wondering that the defines are  set by the configure script.    
> 
> I use as mentioned before msys/mingw:
> 
> $ gcc -v
> 
> Using built-in specs.
> 
> COLLECT_GCC=C:\MinGW\bin\gcc.exe
> 
> COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
> 
> Target: mingw32
> 
> Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu
> --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr
> --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw
> --disable-win32-registry --with-arch=i586 --with-tune=generic
> --enable-languages=c,c++,objc,obj-c++,fortran,ada
> --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static
> --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions
> --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw
> --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp
> --disable-libvtv --enable-nls
> 
> Thread model: win32
> 
> gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
> 
>  
> 
>  
> 
> Any suggestions are welcome!
> 
>  
> 
> Thanks,
> 
>  
> 
> Mike
> 
>  
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] scaling in glpk_4_64.dll

2018-03-16 Thread Heinrich Schuchardt
Hello Jean-Christophe,

I have now installed a 64bit Excel 2010.

I observed the following:

I open a new Excel, import modules lp.bas and glpk.bas, and run routine
lp(). Excel crashes.

I open a new Excel, import modules lp.bas and glpk.bas, I comment the
lines setting the callbacks and run routine lp(). Excel successfully
runs the program.

I open a new Excel, import modules lp.bas and glpk.bas, I comment the
lines setting the callbacks, uncomment the lines and run routine lp().
Excel successfully runs the program.

I moved the callback routines from glpk.bas to lp.bas. I open a new
Excel, import the modified modules lp.bas and glpk.bas, and run routine
lp(). Excel successfully runs the program.

I currently have no clue why this inconsistent behavior occurs.

Best regards

Heinrich

On 03/16/2018 03:39 PM, Huber, Jean-Christophe wrote:
> Dear GLPK-team,
> 
>  
> 
> I’m using GLPK64 from VBA/Excel and wanted to define scaling options.
> 
> In the given example for VBA (file glpk.bas in the GLPK64 zip file from
> SourceForge), there is no declaration for the scaling function.
> 
>  
> 
> I tried adding manually as defined below:
> 
>  
> 
> /#if win64 then/
> 
> /Declare PtrSafe Sub glp_scale_prob Lib "C:\GLP_DLL\glpk_4_64.dll"
> (ByVal lp As LongPtr, ByVal flags As Long)/
> 
> /#else/
> 
> /Declare PtrSafe Sub glp_scale_prob Lib
> "C:\GLP_DLL\glpk_4_64_stdcall.dll" (ByVal lp As LongPtr, ByVal flags As
> Long)/
> 
> /#endif/
> 
>  
> 
> This works well in win32, using the stdcall compilation.
> 
> This does not work (VBA crashes at execution) when using the w64 build.
> Without scaling, there is no other issue with other functions.
> 
>  
> 
> By the way, there is also no declaration for « glp_print_sol » function
> of GLPK. I could ad dit but I’m wondering why the example in GLPK.bas do
> not include it. Any issue with it ?
> 
>  
> 
> Thansk for support / advice
> 
> Regards
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] scaling in glpk_4_64.dll

2018-03-16 Thread Heinrich Schuchardt
On 03/16/2018 03:39 PM, Huber, Jean-Christophe wrote:
> Dear GLPK-team,
> 
>  
> 
> I’m using GLPK64 from VBA/Excel and wanted to define scaling options.
> 
> In the given example for VBA (file glpk.bas in the GLPK64 zip file from
> SourceForge), there is no declaration for the scaling function.
> 
>  
> 
> I tried adding manually as defined below:
> 
>  
> 
> /#if win64 then/
> 
> /Declare PtrSafe Sub glp_scale_prob Lib "C:\GLP_DLL\glpk_4_64.dll"
> (ByVal lp As LongPtr, ByVal flags As Long)/
> 
> /#else/
> 
> /Declare PtrSafe Sub glp_scale_prob Lib
> "C:\GLP_DLL\glpk_4_64_stdcall.dll" (ByVal lp As LongPtr, ByVal flags As
> Long)/

Your definition looks ok. Could you, please, send me a Basic module
(*.bas file) demonstrating the problem.

In the 4.65 release of GLPK for Windows I will add the missing scaling
function definitions for VBA.

' scaling options:
Public Const GLP_SF_GM =  ' perform geometric mean scaling
Public Const GLP_SF_EQ = ' perform equilibration scaling
Public Const GLP_SF_2N = ' round scale factors to power of two
Public Const GLP_SF_SKIP =   ' skip if problem is well scaled
Public Const GLP_SF_AUTO =   ' choose scaling options automatically

' Problem scaling routines
' set (change) row scale factor
Declare PtrSafe Sub glp_set_rii(ByVal lp As LongPtr, ByVal i As Long,
ByVal rii As Double)
' set (change) column factor
Declare PtrSafe Sub glp_set_sjj(ByVal lp As LongPtr, ByVal j As Long,
ByVal sjj As Double)
' retrieve row scale factor
Declare PtrSafe Function glp_get_rii(ByVal lp As LongPtr, ByVal i As
Long) As Double
' retrieve column factor
Declare PtrSafe Function glp_get_sjj(ByVal lp As LongPtr, ByVal j As
Long) As Double
' scale problem data
Declare PtrSafe Sub glp_scale_prob(ByVal lp As LongPtr, ByVal flags As Long)
' unscale problem data
Declare PtrSafe Sub glp_unscale_prob(ByVal lp As LongPtr)

Best regards

Heinrich Schuchardt

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


Re: [Help-glpk] scaling in glpk_4_64.dll

2018-03-16 Thread Heinrich Schuchardt
Hello Jean-Christophe,

VBA is a 32bit stdcall application. You cannot call 64bit libraries.

Is your problem too big for 32bit?

Best regards

Heinrich Schuchardt

http://www.xypron.de

Am 16.03.18 um 15:39 schrieb Huber, Jean-Christophe

> Dear GLPK-team,
> 
> I'm using GLPK64 from VBA/Excel and wanted to define scaling options.
> In the given example for VBA (file glpk.bas in the GLPK64 zip file from 
> SourceForge), there is no declaration for the scaling function.
> 
> I tried adding manually as defined below:
> 
> #if win64 then
> Declare PtrSafe Sub glp_scale_prob Lib "C:\GLP_DLL\glpk_4_64.dll" (ByVal lp 
> As LongPtr, ByVal flags As Long)
> #else
> Declare PtrSafe Sub glp_scale_prob Lib "C:\GLP_DLL\glpk_4_64_stdcall.dll" 
> (ByVal lp As LongPtr, ByVal flags As Long)
> #endif
> 
> This works well in win32, using the stdcall compilation.
> This does not work (VBA crashes at execution) when using the w64 build. 
> Without scaling, there is no other issue with other functions.
> 
> By the way, there is also no declaration for < glp_print_sol > function of 
> GLPK. I could ad dit but I'm wondering why the example in GLPK.bas do not 
> include it. Any issue with it ?
> 
> Thansk for support / advice
> Regards
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk

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


Re: [Help-glpk] [Fwd: Antonio Carlos Moretti <moretti+dated+1521124706.e2c...@ime.unicamp.br>]

2018-03-12 Thread Heinrich Schuchardt
Hello Antonio,

your message had to be forwarded manually because you are not subscribed
to the GLPK help list, cf.
https://lists.gnu.org/mailman/listinfo/help-glpk

The following reply probably did not reach you:
http://lists.gnu.org/archive/html/help-glpk/2018-03/msg7.html

I hope the following pages help you:

https://en.wikibooks.org/wiki/GLPK/Fortran
https://github.com/ArmstrongJ/GLPK-Fortran

Best regards

Heinrich Schuchardt

On 03/11/2018 05:10 AM, Andrew Makhorin wrote:
>  Forwarded Message 
> From: Antonio Carlos Moretti <moretti+dated
> +1521124706.e2c...@ime.unicamp.br>
> To: help-glpk@gnu.org
> Subject: 
> Date: Sat, 10 Mar 2018 11:38:24 -0300
> 
> Hello,
> Is there any way to call glpk from a fortran program?
> 
> Thanks for the help,
> Antonio
> 
> 
> 
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] GLPK input format

2018-03-12 Thread Heinrich Schuchardt
The table command can be used to read a csv file or to connect to any ODBC data base.

Have a look at the directories doc and examples of the source distribution.

Regards 

Heinrich
-- 
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.On 3/12/18, 7:09 AM aku...@tezu.ernet.in wrote:
Hi, I am a beginner with glpk and wanted to know if we can input a .tsv
file into glpsol.
Suppose I have a lp problem with hundred constraints and variables of the
same order then it becomes problematic to create a .lp file manually. So,
is there a way to provide the input from an excel sheet or some other
plain-text format.

Thank you


* * * D I S C L A I M E R * * *
This e-mail may contain privileged information and is intended solely for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail in error and destroy it from your system. Though considerable effort has been made to deliver error free e-mail messages but it can not be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, delayed, or may contain viruses. The recipient must verify the integrity of this e-mail message.

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


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


Re: [Help-glpk] Glpk java in android

2018-02-25 Thread Heinrich Schuchardt
This may be helpful
https://github.com/alotau/GLPKAndroid
Am 26.02.18, 04:31, Syed Reazul Elahee <reazul.ela...@sysnova.com> schrieb:
Still confuse . Do not know what to do for using glpk in android 
application .


On মঙ্গলবার 20 ফেব্রু 2018 05:02 অপরাহ্ণ, Heinrich Schuchardt wrote:
> Please, read
> http://glpk-java.sourceforge.net/architecture.html
>
> Best regards
>
> Heinrich Schuchardt
>
> http://www.xypron.de
>
> Am 20.02.18 um 11:11 schrieb Syed Reazul Elahee
>
>> Hello ,
>>
>> I am trying to make an android app which includes linear programming . I
>> have included glpk-java.jar in my project .
>>
>> After running this _*System.out.println( GLPK.glp_version());
>> *_
>>
>> i am getting this error _*java.lang.UnsatisfiedLinkError:
>> dalvik.system.PathClassLoader[DexPathList[[zip file
>> "/data/app/com.example.root.glpktest-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
>> /system/lib]]] couldn't find "libglpk_java.so".*_
>>
>> Do not know what to do . Any help ??
>>
>> -- 
>>
>> Syed Reazul Elahee
>> Junior Programmer
>> Sysnova Information Systems Limited
>> (Sister concern of Kazi Farms Group)
>> Ahmad and Kazi Tower
>> 35 Dhanmandi Road 2
>> Dhaka 1205
>> Bangladesh
>> www.sysnova.com
>>
>> ___
>> Help-glpk mailing list
>> Help-glpk@gnu.org
>> https://lists.gnu.org/mailman/listinfo/help-glpk

-- 

Syed Reazul Elahee
Junior Programmer
Sysnova Information Systems Limited
(Sister concern of Kazi Farms Group)
Ahmad and Kazi Tower
35 Dhanmandi Road 2
Dhaka 1205
Bangladesh
www.sysnova.com



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


Re: [Help-glpk] Glpk java in android

2018-02-25 Thread Heinrich Schuchardt
Hello Syed,

I have no experience in developing for Android.

But please have a look at
https://developer.android.com/ndk/guides/concepts.html

Best regards

Heinrich
Am 26.02.18, 04:31, Syed Reazul Elahee <reazul.ela...@sysnova.com> schrieb:
Still confuse . Do not know what to do for using glpk in android 
application .


On মঙ্গলবার 20 ফেব্রু 2018 05:02 অপরাহ্ণ, Heinrich Schuchardt wrote:
> Please, read
> http://glpk-java.sourceforge.net/architecture.html
>
> Best regards
>
> Heinrich Schuchardt
>
> http://www.xypron.de
>
> Am 20.02.18 um 11:11 schrieb Syed Reazul Elahee
>
>> Hello ,
>>
>> I am trying to make an android app which includes linear programming . I
>> have included glpk-java.jar in my project .
>>
>> After running this _*System.out.println( GLPK.glp_version());
>> *_
>>
>> i am getting this error _*java.lang.UnsatisfiedLinkError:
>> dalvik.system.PathClassLoader[DexPathList[[zip file
>> "/data/app/com.example.root.glpktest-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
>> /system/lib]]] couldn't find "libglpk_java.so".*_
>>
>> Do not know what to do . Any help ??
>>
>> -- 
>>
>> Syed Reazul Elahee
>> Junior Programmer
>> Sysnova Information Systems Limited
>> (Sister concern of Kazi Farms Group)
>> Ahmad and Kazi Tower
>> 35 Dhanmandi Road 2
>> Dhaka 1205
>> Bangladesh
>> www.sysnova.com
>>
>> ___
>> Help-glpk mailing list
>> Help-glpk@gnu.org
>> https://lists.gnu.org/mailman/listinfo/help-glpk

-- 

Syed Reazul Elahee
Junior Programmer
Sysnova Information Systems Limited
(Sister concern of Kazi Farms Group)
Ahmad and Kazi Tower
35 Dhanmandi Road 2
Dhaka 1205
Bangladesh
www.sysnova.com



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


Re: [Help-glpk] Glpk java in android

2018-02-20 Thread Heinrich Schuchardt
Please, read
http://glpk-java.sourceforge.net/architecture.html

Best regards

Heinrich Schuchardt

http://www.xypron.de

Am 20.02.18 um 11:11 schrieb Syed Reazul Elahee

> Hello ,
> 
> I am trying to make an android app which includes linear programming . I 
> have included glpk-java.jar in my project .
> 
> After running this _*System.out.println( GLPK.glp_version());
> *_
> 
> i am getting this error _*java.lang.UnsatisfiedLinkError: 
> dalvik.system.PathClassLoader[DexPathList[[zip file 
> "/data/app/com.example.root.glpktest-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,
>  
> /system/lib]]] couldn't find "libglpk_java.so".*_
> 
> Do not know what to do . Any help ??
> 
> -- 
> 
> Syed Reazul Elahee
> Junior Programmer
> Sysnova Information Systems Limited
> (Sister concern of Kazi Farms Group)
> Ahmad and Kazi Tower
> 35 Dhanmandi Road 2
> Dhaka 1205
> Bangladesh
> www.sysnova.com
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk

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


Re: [Help-glpk] piecewise linear function

2018-02-15 Thread Heinrich Schuchardt
Hello Giovanni,

please, read doc/gmpl.pdf which comes with the GLPK source.

The <<>> syntax may exist in AMPL but it does not exist in GMPL.

Depending on your piecewise linear function being concave or convex you can replace it with some linear constraints or you will have to introduce extra binary variables.

Best regards

Heinrich
Am 15.02.18, 21:10, Giovanni Di Stasi  schrieb:
I am trying to use such functions but I get a syntax error. In particular, this is my program, taken by the following book chapter:https://ampl.com/BOOK/CHAPTERS/20-piecewise.pdfset ORIG; # originsset DEST; # destinationsparam supply {ORIG} >= 0; # amounts available at originsparam demand {DEST} >= 0; # amounts required at destinationscheck: sum {i in ORIG} supply[i] = sum {j in DEST} demand[j];param rate1 {i in ORIG, j in DEST} >= 0;param rate2 {i in ORIG, j in DEST} >= rate1[i,j];param rate3 {i in ORIG, j in DEST} >= rate2[i,j];param limit1 {i in ORIG, j in DEST} > 0;param limit2 {i in ORIG, j in DEST} > limit1[i,j];var Trans {ORIG,DEST} >= 0; # units to be shippedminimize Total_Cost: sum {i in ORIG, j in DEST}<> Trans[i,j];subject to Supply {i in ORIG}:sum {j in DEST} Trans[i,j] = supply[i];subject to Demand {j in DEST}:sum {i in ORIG} Trans[i,j] = demand[j];When I try to make glpk parse it, I get the following error:glpsol --model glpk/Test --data /tmp/DATAg5ZQ0L -w /tmp/OUTXlm0STGLPSOL: GLPK LP/MIP Solver, v4.61Parameter(s) specified in the command line: --model glpk/Test --data /tmp/DATAg5ZQ0L -w /tmp/OUTXlm0STReading model section from glpk/Test...glpk/Test:14: syntax error in _expression_Context: ...>= 0 ; minimize Total_Cost : sum { i in ORIG , j in DEST } 

Re: [Help-glpk] Issue with symbolic parameters input from csv files

2018-02-07 Thread Heinrich Schuchardt
Hello Joel,

please, provide the model file and the csv file that show the error.
Otherwise it is hard to figure out what your problem is.

Best regards

Heinrich

On 02/07/2018 09:19 PM, joel mortyn wrote:
> Hi,
> 
> I have a MIP model and am running into an issue when inputting data from
> csv files versus entering them into the data section of the model file.
> The issue involves symbolic parameters that are referenced in multiple
> data sets. For example, I have two sets:
> {n in Nodes} and {b in Blocks}. The Blocks set has a parameter
> Block_Node that matches one of the Nodes. The data reads just  fine from
> the csv files, as when I use the display statement I get the following:
> 
> Display statement at line 153
>    Block_Node[1] = 1
> Display statement at line 154
> Nodes:
>    1
>    719
>    742
>    752
>    787
>    791
>    793
>    796
>    823
>    828
> 
> I create a set of BlockNodes using the following:
>    set BlockNodes:=setof{b in Blocks, n in Nodes:
> (Node_ID[n]=Block_Node[b])} (b,n);
> 
> However, when the data is input from csv files, glpk does not recognize
> this join. When I try to display the set BlockNodes, I get the following
> error:
>    "no value for Node_ID[1]"
> 
> If rather than using csv files, I enter the same data at the end of the
> model file, the model solves with no issue.
> 
> I am thinking that using the csv files is causing a data type conversion
> issue. I have tried forcing the Node_IDs and Block_Nodes to text by
> using quotation marks but the issue persisted.
> 
> Any help would be much appreciated. Thanks,
> 
> Joel
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] [Fwd: Unable to resolve installation of GLPK on MacOS 10]

2018-01-27 Thread Heinrich Schuchardt
see
https://en.wikibooks.org/wiki/GLPK/R
Am 27.01.18, 13:26, Andrew Makhorin  schrieb:
 Forwarded Message 
From: reynold tan 
To: m...@gnu.org , g...@gnu.org 
Subject: Unable to resolve installation of GLPK on MacOS 10
Date: Sat, 27 Jan 2018 11:16:09 +

Hi GLPK team, 


I have downloaded your package but am unable to install it on R (ver
3.4.3) for macOS10. I have tried to search on the internet for solutions
but to no avail. Can you kindly help?


Thank you!


Regards,

Reynold







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


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


Re: [Help-glpk] Need help in installing GLPK-java in mac os x 10.7.5

2018-01-25 Thread Heinrich Schuchardt
Hello Syed,

the *.dylib  files for GLPK and GLPK for Java must be in the search path
for binary libraries.

The relevant environment variables can be found in

https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html

Best regards

Heinrich

On 01/25/2018 05:14 AM, Syed Reazul Elahee wrote:
> Thank you . I have successfully build glpk-java in my mac . I can see
> glpsol version from terminal .
> 
> glpk-java-javadoc.jar,glpk-java-sources.jar and glpk-java.jar files
> created inside swig directory .
> 
> i have used this jars in my java project . when i run my project i am
> getting a new error message
> 
> " *The dynamic link library for GLPK for java could not be loaded .
> Consider using java -Djava.library.path=The current value of system
> property java.library.path is :
> /Users/elahee/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.*"
> 
> 
> any solution ?
> 
> 
> On বুধবার 24 জানু 2018 03:25 অপরাহ্ণ, Heinrich Schuchardt wrote:
>> Did you install the JDK?
>>
>> Did you export the necessary environment variables?
>>
>> http://glpk-java.sourceforge.net/gettingStarted.html
>>
>> The paths to jni.h differ between Linux and OS X.
>>
>> Am 24.01.18, 09:58, Syed Reazul Elahee <reazul.ela...@sysnova.com>
>> schrieb:
>>
>> i have downloaded libglpk-java-1.11.0 and tried to configure . but
>> it is giving an error , saying "*jni.h not found* " .
>>
>> What to do next ?
>>
>>
>> On বুধবার 24 জানু 2018 11:17 পূর্বাহ্ণ, Heinrich Schuchardt wrote:
>>> Hello Syed,
>>>
>>> brew install swig
>>>
>>> then build GLPK for Java from source available at
>>> http://glpk-java.sourceforge.net/
>>>
>>> Best regards
>>>
>>> Heinrich
>>> Am 24.01.18, 06:00, Syed Reazul Elahee
>>> <reazul.ela...@sysnova.com> schrieb:
>>>
>>> Hello ,
>>>
>>> I have successfully installed glpk in mac osx 10.7.5 by*brew
>>> install glpk* comand . From terminal i can see glpk version
>>> *4.64***by typing*glpsol* comand .
>>>
>>> Now i need glpk-jar jar files to add in my netbeans project .
>>> But i do not find any jar for mac .Do i have to build jar
>>> from source ? if yes , the how ?
>>>
>>> Please help
>>>
>>> -- 
>>>
>>> Syed Reazul Elahee
>>> Trainee Programmer
>>> Sysnova Information Systems Limited
>>> (Sister concern of Kazi Farms Group)
>>> Ahmad and Kazi Tower
>>> 35 Dhanmandi Road 2
>>> Dhaka 1205
>>> Bangladesh
>>> www.sysnova.com
>>>
>>> ___ Help-glpk
>>> mailing list Help-glpk@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/help-glpk 
>>>
>>
>> -- 
>>
>> Syed Reazul Elahee
>> Trainee Programmer
>> Sysnova Information Systems Limited
>> (Sister concern of Kazi Farms Group)
>> Ahmad and Kazi Tower
>> 35 Dhanmandi Road 2
>> Dhaka 1205
>> Bangladesh
>> www.sysnova.com
>>
> 
> -- 
> 
> Syed Reazul Elahee
> Trainee Programmer
> Sysnova Information Systems Limited
> (Sister concern of Kazi Farms Group)
> Ahmad and Kazi Tower
> 35 Dhanmandi Road 2
> Dhaka 1205
> Bangladesh
> www.sysnova.com
> 


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


Re: [Help-glpk] Need help in installing GLPK-java in mac os x 10.7.5

2018-01-24 Thread Heinrich Schuchardt
Did you install the JDK?

Did you export the necessary environment variables?

http://glpk-java.sourceforge.net/gettingStarted.html

The paths to jni.h differ between Linux and OS X.

Am 24.01.18, 09:58, Syed Reazul Elahee <reazul.ela...@sysnova.com> schrieb:

  
i have downloaded libglpk-java-1.11.0 and tried to configure .
  but it is giving an error , saying "jni.h not found " . 

What to do next ?


On বুধবার 24 জানু 2018 11:17 পূর্বাহ্ণ,
  Heinrich Schuchardt wrote:


  
  
  Hello Syed,

brew install swig 

then build GLPK for Java from source available at
http://glpk-java.sourceforge.net/

Best regards

Heinrich
  
  Am 24.01.18, 06:00, Syed Reazul Elahee
<reazul.ela...@sysnova.com> schrieb:

  Hello , 
  
  I have successfully installed glpk in mac osx 10.7.5 by brew install glpk comand . From
terminal i can see glpk version 4.64
by typing glpsol comand .
  Now i need glpk-jar jar files to add in my netbeans project
. But i do not find any jar for mac .Do i have to build jar
from source ? if yes , the how ? 
  
  Please help
  
  -- 

Syed Reazul Elahee
Trainee Programmer
Sysnova Information Systems Limited
(Sister concern of Kazi Farms Group)
Ahmad and Kazi Tower
35 Dhanmandi Road 2
Dhaka 1205
Bangladesh
www.sysnova.com
  ___
  Help-glpk mailing list
  Help-glpk@gnu.org
  https://lists.gnu.org/mailman/listinfo/help-glpk

  


-- 

Syed Reazul Elahee
Trainee Programmer
Sysnova Information Systems Limited
(Sister concern of Kazi Farms Group)
Ahmad and Kazi Tower
35 Dhanmandi Road 2
Dhaka 1205
Bangladesh
www.sysnova.com
  


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


Re: [Help-glpk] Need help in installing GLPK-java in mac os x 10.7.5

2018-01-23 Thread Heinrich Schuchardt
Hello Syed,

brew install swig 

then build GLPK for Java from source available at
http://glpk-java.sourceforge.net/

Best regards

Heinrich
Am 24.01.18, 06:00, Syed Reazul Elahee  schrieb:

  
Hello , 

I have successfully installed glpk in mac osx 10.7.5 by brew install glpk comand . From
  terminal i can see glpk version 4.64
  by typing glpsol comand .
Now i need glpk-jar jar files to add in my netbeans project . But
  i do not find any jar for mac .Do i have to build jar from source
  ? if yes , the how ? 

Please help

-- 

Syed Reazul Elahee
Trainee Programmer
Sysnova Information Systems Limited
(Sister concern of Kazi Farms Group)
Ahmad and Kazi Tower
35 Dhanmandi Road 2
Dhaka 1205
Bangladesh
www.sysnova.com
  
___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


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


Re: [Help-glpk] [Fwd: Re: [Fwd: GLPK-java on mac 10.7.5]]

2018-01-23 Thread Heinrich Schuchardt
You should be able to install GLPK and Swig with brew.

Then build GLPK for Java according to the INSTALL file.
Am 23.01.18, 11:01, Andrew Makhorin  schrieb:
 Forwarded Message 
From: sindhu nir 
To: Andrew Makhorin 
Subject: Re: [Help-glpk] [Fwd: GLPK-java on mac 10.7.5]
Date: Tue, 23 Jan 2018 11:45:05 +0600

Thanks for replying . I saw the link but did not find any installation
procedure on mac osx 10.7.5 . Please help


On Mon, Jan 22, 2018 at 12:56 PM, Andrew Makhorin  wrote:

> I need to install glpk-java on mac 10.7.5 . Is there any
procedure for
> it ?
>

Please see http://en.wikibooks.org/wiki/GLPK/Java .






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


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


Re: [Help-glpk] [Fwd: is there a dll edition of glpk mip solver?]

2017-12-07 Thread Heinrich Schuchardt
On 12/07/2017 07:11 AM, Liujianxin (Jason) wrote:
> Dear Heinrich,
> 
>  
> 
> Thank you very much for the help document recommended. It helped me a lot.
> 
> Right now I’m trying to use ctypes library of Python 3.5.4 to load
> glpk_4_64.dll to solve lp and mip problems.
> 

Please, find appended an example showing how to initialize the iocp
structure.

Regars

Heinrich
#!/usr/bin/python

from ctypes import *

# Constants
GLP_MAX = 2
GLP_ON = 1
GLP_IV = 2
GLP_LO = 2
GLP_UP = 3

# Structure glp_iocp
class IOCP(Structure) :
	_fields_ = [
		('msg_lev', c_int),
		('br_tech', c_int),
		('bt_tech', c_int),
		('tol_int', c_double),
		('tol_obj', c_double),
		('tm_lim', c_int),
		('out_frq', c_int),
		('out_dly', c_int),
		('cb_func', c_void_p),
		('cb_info', c_void_p),
		('cb_size', c_int),
		('pp_tech', c_int),
		('mip_gap', c_double),
		('mir_cuts', c_int),
		('gmi_cuts', c_int),
		('cov_cuts', c_int),
		('clq_cuts', c_int),
		('presolve', c_int),
		('fp_heur', c_int),
		('ps_heur', c_int),
		('ps_tm_lim', c_int),
		('sr_heur', c_int),
		('use_sol', c_int),
		('save_sol', c_char_p),
		('alien', c_int),
		('flip', c_int),
		('foo_bar', c_double * 23)]

solver = cdll.LoadLibrary('libglpk.so')

# Adjust function prototypes
solver.glp_create_prob.restype = c_void_p
solver.glp_init_iocp.argtypes = [ POINTER(IOCP) ]
solver.glp_intopt.argtypes = [ c_void_p, POINTER(IOCP) ]
solver.glp_mip_obj_val.restype = c_double
solver.glp_mip_col_val.restype = c_double
solver.glp_set_row_bnds.argtypes = [ c_void_p, c_int, c_int, c_double, c_double ]
solver.glp_set_col_bnds.argtypes = [ c_void_p, c_int, c_int, c_double, c_double ]
solver.glp_set_obj_coef.argtypes = [ c_void_p, c_int, c_double]

# Create problem
lp = c_void_p(solver.glp_create_prob())
solver.glp_set_prob_name(lp, 'Problem')

# Define rows and columns
solver.glp_add_rows(lp, 2)
solver.glp_set_row_name(lp, 1, 'p')
solver.glp_set_row_bnds(lp, 1, GLP_UP, 0.0, 10.5)
solver.glp_set_row_name(lp, 2, 'q')
solver.glp_set_row_bnds(lp, 2, GLP_UP, 0.0, 19.7)
solver.glp_add_cols(lp, 2)
solver.glp_set_col_name(lp, 1, 'x1')
solver.glp_set_col_bnds(lp, 1, GLP_LO, 0.0, 0.0)
solver.glp_set_col_name(lp, 2, 'x2')
solver.glp_set_col_bnds(lp, 2, GLP_LO, 0.0, 0.0)
solver.glp_set_col_kind(lp, 2, GLP_IV)

# Define objective
solver.glp_set_obj_dir(lp, GLP_MAX)
solver.glp_set_obj_name(lp, 'obj')
solver.glp_set_obj_coef(lp, 1, 0.61)
solver.glp_set_obj_coef(lp, 2, 0.49)

# Define matrix
ia = (c_int*5)()
ja = (c_int*5)()
ar = (c_double*5)()
ia[1]=1; ia[2]=1; ia[3]=2; ia[4]=2
ja[1]=1; ja[2]=2; ja[3]=1; ja[4]=2
ar[1]=1.0; ar[2]=2.0; ar[3]=3.0; ar[4]=1.0
solver.glp_load_matrix(lp, 4, ia, ja, ar);

# Solve
iocp = IOCP()
solver.glp_init_iocp(iocp)
iocp.presolve = GLP_ON
ret = solver.glp_intopt(lp, iocp)
if ret:
	print('Failure\n')
	solver.glp_delete_prob(lp)
	solver.glp_free_env()
	quit()

# Get results
z = solver.glp_mip_obj_val(lp)
x1 = solver.glp_mip_col_val(lp, c_int(1))
x2 = solver.glp_mip_col_val(lp, c_int(2))
print('obj = %g; x1 = %g; x2 = %g\n'%(z, x1, x2))

# Cleanup
solver.glp_delete_prob(lp)
solver.glp_free_env()
___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] [Fwd: is there a dll edition of glpk mip solver?]

2017-12-06 Thread Heinrich Schuchardt
Have a look at the chapter on glp_intopt.

Best regards

Heinrich
-- 
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 07.12.17, 07:11, "Liujianxin (Jason)"  schrieb:



Dear Heinrich,
 
Thank you very much for the help document recommended. It helped me a lot.
Right now I’m trying to use ctypes library of Python 3.5.4 to load glpk_4_64.dll to solve lp and mip problems.
 
Test lp problem:

I tried to call the glpk_4_64.dll to solve this problem and succeeded. The following is my code:
from ctypes import *
solver = windll.LoadLibrary('./solver/glpk/w64/glpk_4_64.dll')
lp = solver.glp_create_prob()
solver.glp_set_prob_name(lp, c_wchar_p("short"))
solver.glp_set_obj_dir(lp, c_int(2))
solver.glp_add_rows(lp, c_int(2))
solver.glp_set_row_name(lp, c_int(1), c_wchar_p("p"))
solver.glp_set_row_bnds(lp, c_int(1), c_int(3), c_double(0.0), c_double(1.0))
solver.glp_set_row_name(lp, c_int(2), c_wchar_p("q"))
solver.glp_set_row_bnds(lp, c_int(2), c_int(3), c_double(0.0), c_double(2.0))
solver.glp_add_cols(lp, c_int(2))
solver.glp_set_col_name(lp, c_int(1), c_wchar_p("x1"))
solver.glp_set_col_bnds(lp, c_int(1), c_int(2), c_double(0.0), c_double(0.0))
solver.glp_set_obj_coef(lp, c_int(1), c_double(0.6))
solver.glp_set_col_name(lp, c_int(2), c_wchar_p("x2"))
solver.glp_set_col_bnds(lp, c_int(2), c_int(2), c_double(0.0), c_double(0.0))
solver.glp_set_obj_coef(lp, c_int(2), c_double(0.5))
ia = (c_int*5)()
ja = (c_int*5)()
ar = (c_double*5)()
ia[1]=1; ia[2]=1; ia[3]=2; ia[4]=2
ja[1]=1; ja[2]=2; ja[3]=1; ja[4]=2
ar[1]=1.0; ar[2]=2.0; ar[3]=3.0; ar[4]=1.0
solver.glp_load_matrix(lp, c_int(4), ia, ja, ar)
solver.glp_simplex(lp, None);
solver.glp_get_obj_val.restype = c_double
solver.glp_get_col_prim.restype = c_double
z = solver.glp_get_obj_val(lp)
x1 = solver.glp_get_col_prim(lp, c_int(1))
x2 = solver.glp_get_col_prim(lp, c_int(2))
print("z = %g; x1 = %g; x2 = %g\n"%(z, x1, x2))
solver.glp_delete_prob(lp)
solver.glp_free_env()
the script works fine, and right answer output: z = 0.46; x1 = 0.6; x2 = 0.2.
 
But when I tried to constrain x2 as an integer variable, the original problem was changed into a mip problem, the following script cannot output right answer:
from ctypes import *
solver = windll.LoadLibrary('./solver/glpk/w64/glpk_4_64.dll')
lp = solver.glp_create_prob()
solver.glp_set_prob_name(lp, c_wchar_p("short"))
solver.glp_set_obj_dir(lp, c_int(2))
solver.glp_add_rows(lp, c_int(2))
solver.glp_set_row_name(lp, c_int(1), c_wchar_p("p"))
solver.glp_set_row_bnds(lp, c_int(1), c_int(3), c_double(0.0), c_double(1.0))
solver.glp_set_row_name(lp, c_int(2), c_wchar_p("q"))
solver.glp_set_row_bnds(lp, c_int(2), c_int(3), c_double(0.0), c_double(2.0))
solver.glp_add_cols(lp, c_int(2))
solver.glp_set_col_name(lp, c_int(1), c_wchar_p("x1"))
solver.glp_set_col_bnds(lp, c_int(1), c_int(2), c_double(0.0), c_double(0.0))
solver.glp_set_obj_coef(lp, c_int(1), c_double(0.6))
solver.glp_set_col_name(lp, c_int(2), c_wchar_p("x2"))
solver.glp_set_col_bnds(lp, c_int(2), c_int(2), c_double(0.0), c_double(0.0))
solver.glp_set_obj_coef(lp, c_int(2), c_double(0.5))
solver.glp_set_col_kind(lp, c_int(2), c_int(2))
ia = (c_int*5)()
ja = (c_int*5)()
ar = (c_double*5)()
ia[1]=1; ia[2]=1; ia[3]=2; ia[4]=2
ja[1]=1; ja[2]=2; ja[3]=1; ja[4]=2
ar[1]=1.0; ar[2]=2.0; ar[3]=3.0; ar[4]=1.0
solver.glp_load_matrix(lp, c_int(4), ia, ja, ar);
solver.glp_intopt(lp, None)
solver.glp_mip_obj_val.restype = c_double
solver.glp_mip_col_val.restype = c_double
z = solver.glp_mip_obj_val(lp)
x1 = solver.glp_mip_col_val(lp, c_int(1))
x2 = solver.glp_mip_col_val(lp, c_int(2))
print("z = %g; x1 = %g; x2 = %g\n"%(z, x1, x2))
solver.glp_delete_prob(lp)
solver.glp_free_env()
the script ran without exceptions but I got all zero output: z = 0; x1 = 0; x2 = 0. It seems the solver didn’t work.
 
I don’t know why, could you give me some clue? Thx in advance.
 
B.R.
 
Jason
 




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


Re: [Help-glpk] [Fwd: is there a dll edition of glpk mip solver?]

2017-12-04 Thread Heinrich Schuchardt
Please, read doc/glpk.pdf that comes with the GLPK source.

https://ftp.gnu.org/gnu/glpk/glpk-4.64.tar.gz
or
https://sourceforge.net/projects/winglpk/files/latest/download
-- 
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 05.12.17, 03:19, "刘建新" <dragon...@163.com> schrieb:
Dear Heinrich,
Thank you very much for your quick response.
I found more documents from the url  you sent me. It seems that the glpk function could be called without the executable, am I right? thx



发自我的小米手机在 Heinrich Schuchardt <xypron.g...@gmx.de>,2017年12月4日 20:10写道:Dear Jason,



GLPK consists of a executable glpsol.exe and a dll with the GLPK library.



The ways PuLP was written is that it calls the executable and does not

interface to the API exposed by the dll in class solvers.py.



See https://en.wikibooks.org/wiki/GLPK/Python

for alternatives.



Best regards



Heinrich





On 12/04/2017 12:27 PM, Andrew Makhorin wrote:

>  Forwarded Message 

> To: help-glpk@gnu.org

> Subject: is there a dll edition of glpk mip solver?

> Date: Mon, 04 Dec 2017 14:22:51 +0800

> 

> dear mr/ms,

> 

> 

> 

> i'm trying to build an executable using pulp with solver glpk. 

> 

> It works all right except the console window of glpk flashing through

> screen while solving mip problems.

> 

> i'm wondering if there is a dll edition of glpk so i can avoid the

> console window?

> 

> thx in advance.

> 

> 

> 

> Best Regards,

> 

> 

> 

> Jason




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


Re: [Help-glpk] [Fwd: is there a dll edition of glpk mip solver?]

2017-12-04 Thread Heinrich Schuchardt
Dear Jason,

GLPK consists of a executable glpsol.exe and a dll with the GLPK library.

The ways PuLP was written is that it calls the executable and does not
interface to the API exposed by the dll in class solvers.py.

See https://en.wikibooks.org/wiki/GLPK/Python
for alternatives.

Best regards

Heinrich


On 12/04/2017 12:27 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: help-glpk@gnu.org
> Subject: is there a dll edition of glpk mip solver?
> Date: Mon, 04 Dec 2017 14:22:51 +0800
> 
> dear mr/ms,
> 
> 
> 
> i'm trying to build an executable using pulp with solver glpk. 
> 
> It works all right except the console window of glpk flashing through
> screen while solving mip problems.
> 
> i'm wondering if there is a dll edition of glpk so i can avoid the
> console window?
> 
> thx in advance.
> 
> 
> 
> Best Regards,
> 
> 
> 
> Jason

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


Re: [Help-glpk] Gusek - release 0.2.23

2017-12-04 Thread Heinrich Schuchardt
On 12/04/2017 12:39 PM, Luiz Bettoni wrote:
> Gusek project was updated on SourceForge:
>    http://gusek.sourceforge.net 
> 
> Release changes:
>  - GLPK updated to 4.63 (0.2.23)

Actually updated to 4.64

Regards

Heinrich

>  - Minor fixes on run and convert models (0.2.22)
> 
> Gusek provide an open source LP/MILP IDE for Win32, packing a custom
> version of the SciTE editor linked to the GLPK standalone solver
> (glpsol.exe).
> 
> 
> Best Regards,
> Luiz Bettoni
> 

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


Re: [Help-glpk] lp/mip preprocessor api

2017-12-02 Thread Heinrich Schuchardt
On 12/02/2017 05:54 PM, Andrew Makhorin wrote:
> Hi Heinrich,
> 
>>
>> the API should allow the user to add his own simplifications.
>>
>> This may require access to the npp internal structure.
> 
> It would be problematic. I only plan to include a set of preprocessing
> operations sufficient in most cases (at least for LP). On the other
> hand, if the user needs to perform his own preprocessing, why not to do
> that independently on the glpk preprocessor?

You have already implemented a lot of useful presolving and scaling
routines.

If I wanted to build on it and simply add another one I would not like
to reimplement your work.

> 
>>
>> It would be great if the variable mapping could be applied forward and
>> reverse in the MIP callback hook.
> 
> Could you provide an example of what you mean?

In the MIP callback currently we can only access the scaled and
presolved model.

If we could apply the backwards transformation we would be able to
understand the solution in our original variables.

If we could apply the forward transformation we would be able to create
a constraint in our own variables and than add the transformed
constraint to the scaled and presolved model.

Best regards

Heinrich

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


Re: [Help-glpk] [Fwd: a polite question] GLPKmex 64bit

2017-11-24 Thread Heinrich Schuchardt

Dear František,

it seems that the only maintained version of GLPKmex is to be found at 
https://github.com/blegat/glpkmex. It includes 64bit support.


Cf. https://en.wikibooks.org/wiki/GLPK/Matlab

Please, contact the maintainer Benoît Legat if you run into problems.

Best regards

Heinrich

On 11/24/2017 02:35 PM, Andrew Makhorin wrote:

 Forwarded Message 
To: m...@gnu.org
Subject: a polite question
Date: Fri, 24 Nov 2017 12:55:22 +0100

Dear Colleague,
  
I have the following problem:
  
I use a private toolbox utilizing glpkmex in matlab.
  
While I used glpkmex in win32 operating system and matlab 32 bit, the

toolbox worked OK.
  
Now, I am using win 64 and matlab 64 bit. Now, my toolbox does not

operate.
  
I guess that the problem is in glpk files. However, my attempts to use

glpk-4.62 and glpk-4.63 are not successful.
  
  
Would you be so kind to advice me a procedure to be successful?
  
Many thanks in advance for your kind answer.
  
  
Best regards,
  
Frantisek




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




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


Re: [Help-glpk] GLPK 4.63 Windows. "no glpk_java in java.library.path"

2017-10-23 Thread Heinrich Schuchardt
Hello Chris,

what is the bitness of the Java engine you use?

Does the bitness of the Java engine match the bitness of the DLLs that
are in the PATH?

Please, provide the complete error output.

Best regards

Heinrich

On 10/23/2017 12:18 AM, Chris Jones wrote:
> Installed glpk 4.63 via the sourceforge windows .zip file.
> 
> Java code uses maven configuration:
> 
> 
> 
>             org.gnu.glpk
> 
>             glpk-java
> 
>             1.10.0
> 
>              compile
> 
>         
> 
> 
> 
> java.library.path is
> 
> c:\glpk-4.63\w64
> 
> Contents of that directory are:
> 
> C:\glpk-4.63\w64>dir
>  Volume in drive C is OS_Install
>  Volume Serial Number is A41E-0F08
> 
>  Directory of C:\glpk-4.63\w64
> 
> 10/22/2017  03:16 PM              .
> 10/22/2017  03:16 PM              ..
> 07/01/2017  06:17 AM             1,159 Build_CLI.bat
> 07/25/2017  09:00 AM               337 Build_GLPK_with_VC10.bat
> 07/25/2017  09:00 AM               349 Build_GLPK_with_VC10_DLL.bat
> 07/25/2017  09:00 AM               339 Build_GLPK_with_VC14.bat
> 07/25/2017  09:00 AM               351 Build_GLPK_with_VC14_DLL.bat
> 07/25/2017  09:00 AM               335 Build_GLPK_with_VC9.bat
> 07/25/2017  09:00 AM               347 Build_GLPK_with_VC9_DLL.bat
> 07/01/2017  05:51 AM             1,664 Build_JNI_with_VC14_DLL.bat
> 10/03/2015  03:00 PM             1,359 check_cli.bat
> 10/03/2015  10:21 PM             2,124 check_jni.bat
> 07/01/2017  06:17 AM               895 check_vb.bat
> 01/21/2017  06:00 PM                31 config.h
> 07/25/2017  09:00 AM               401 config_VC
> 07/25/2017  09:33 PM           202,264 glpk-java-javadoc.jar
> 07/25/2017  09:33 PM            55,097 glpk-java-sources.jar
> 07/25/2017  09:33 PM            47,032 glpk-java.jar
> 07/25/2017  09:00 AM             3,749 glpk_4_63.def
> 07/25/2017  09:33 PM         1,849,344 glpk_4_63.dll
> 07/25/2017  09:33 PM            27,395 glpk_4_63.exp
> 07/25/2017  09:33 PM            45,882 glpk_4_63.lib
> 07/25/2017  09:33 PM         8,425,472 glpk_4_63.pdb
> 07/25/2017  09:33 PM           720,384 glpk_4_63_java.dll
> 07/25/2017  09:33 PM           130,365 glpk_4_63_java.exp
> 07/25/2017  09:33 PM           220,568 glpk_4_63_java.lib
> 07/25/2017  09:33 PM         5,459,968 glpk_4_63_java.pdb
> 07/18/2017  06:51 PM             1,050 glpk_cli_dll.rc
> 07/18/2017  06:55 PM             1,048 glpk_java_dll.rc
> 07/25/2017  09:33 PM           556,544 glpsol.exe
> 07/25/2017  09:33 PM         5,099,520 glpsol.pdb
> 07/25/2017  09:34 PM           120,320 libglpk-cli.dll
> 07/25/2017  09:34 PM           689,664 libglpk_cli_native.dll
> 07/25/2017  09:34 PM           120,491 libglpk_cli_native.exp
> 07/25/2017  09:34 PM           206,688 libglpk_cli_native.lib
> 07/25/2017  09:34 PM         5,279,744 libglpk_cli_native.pdb
> 07/18/2017  06:51 PM               459 Makefile_CLI_VC_DLL
> 07/18/2017  06:54 PM               454 Makefile_JNI_VC_DLL
> 07/25/2017  09:00 AM             5,941 makefile_VC
> 07/25/2017  09:26 PM             6,018 makefile_VC_DLL
> 07/25/2017  09:00 AM               951 readme.txt
> 07/25/2017  09:34 PM           389,120 vc140.pdb
> 
> 
> I installed glpk on a mac, and got it to work fine.
> 
> What might I be missing?
> 
> Thanks,
> CJ
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] MathProg two-dimensional array

2017-10-08 Thread Heinrich Schuchardt
Hello Ralf,

please, have a look at the examples directory of the source distribution, e.g. sudoku.mod and at gmpl.pdf.

Regards

Heinrich



Am 08.10.17, 09:43, "r...@jazzcon.de"  schrieb:
Hello everyone,

trying to define arrays with two dimensions, I could not
solve this topic in GMPL:


  set ORIG;
  set DEST;
  set LINKS within {ORIG,DEST};

  printf {i in ORIG, j in DEST} "LINKS[%s,%s] = %g \n",i,j,LINKS[i][j];

  data;

  set ORIG := GARY CLEV PITT;
  set DEST := FRA DET LAN WIN STL FRE LAF;

  set LINKS :=
 (GARY,*) DET LAN STL LAF
 (CLEV,*) FRA DET LAN WIN STL LAF
 (PITT,*) FRA WIN STL FRE;

  end;


This definition brings up this error message:

"LINKS cannot be subscripted"


So my question is: how can I define Links so, that it can be accessed
with this command:

Links[i][j]


Thanks for any comments!



Ralf




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


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


Re: [Help-glpk] [Fwd: Re: [Fwd: graceful tree labeling example]]

2017-10-05 Thread Heinrich Schuchardt
Hello Mike,

your model uses more integers than needed. This typically makes problems
harder to solve.

You just need the binaries gt, vx, and ex. All other variables can be
float. The constraints enforce that they will be integer.

Best regards

Heinrich Schuchardt

On 10/05/2017 09:28 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: Andrew Makhorin <m...@gnu.org>
> Cc: help-glpk@gnu.org
> Subject: Re: [Help-glpk] [Fwd: graceful tree labeling example]
> Date: Thu, 5 Oct 2017 13:55:08 -0500
> 
> The merged model and data sections are attached, gzipped this time to
> hopefully avoid confusing the mime type detection.
> 
> Thanks for including the model.
> 
> cheers,
> 
> Mike A.
> 
> On Thu, Oct 5, 2017 at 1:05 PM, Andrew Makhorin <m...@gnu.org> wrote:
>>> I recently implemented a MathProg model that attempts to generate a
>>> graceful labeling for a given input tree. I thought I'd post here to
>>> see if there was any interest in including it in the examples that
>>> come with the GLPK source distribution.
>>>
>>> The model and an example data file are attached. You can also find
>>> them on github, along with a README and a few more example inputs:
>>>
>>> https://github.com/appleby/graceful-tree
>>>
>>> This is my first attempt at a MathProg model, so I'm happy to hear
>>> corrections or suggestions for improving the model in any case.
>>>
>>
>> Thank you for your contribution.
>>
>> Please merge model and data sections into one file and then post it to
>> the list. I will include it into the next release of the package.
>> Thanks.
>>
>> Andrew Makhorin
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] [Fwd: GLPK for Java]

2017-09-16 Thread Heinrich Schuchardt
On 09/16/2017 03:01 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> From: schwa...@googlemail.com
> To: help-glpk@gnu.org 
> Subject: GLPK for Java
> Date: Sat, 16 Sep 2017 14:03:45 +0200
> 
> Dear All --
> 

In many aspects your code does not correlate to the problem you want to
solve.
Read doc/glpk.pdf carefully and try to understand the example code.
Check every value you pass to glp_set_mat_row in the line of code
causing the error. What is ind[] used for? What does len = 2 mean?

>  
> 
> We have already run several GMPL examples with WinGLPK but need to solve
> linear programs in our Java application. I imported glpk-4.63\examples
> \java into an Eclipse Project so I am able to run the examples now. In
> particular we need to do call GLPK as shown in Lp.java which I wanted to
> modify such that it first solves another simple example whose GMPL code
> is as follows:
> 
> 
>  
> 
> 
> minimize z = -3 * x1 - x2
> 
> 
>  
> 
> 
> subject to
> 
> 
>  2 * x2   <=  6
> 
> 
> 2 * x1 + 3 * x2  <= 13
> 
> 
>   2 <=   x1<=  5
> 
> 
> where,
> 
> 
> 0.0 <= x1
> 
> 
> 0.0 <= x2
> 
> 
>  
> 
> Unfortunately my modification of Lp.java results in the error
> 
>  
> 
> glp_set_mat_row: i = 1; ind[2] = 0; column index out of range
> 
> 
> Error detected in file ..\src\api\prob1.c at line 773
> 
> 
> org.gnu.glpk.GlpkException: function glp_set_mat_row failed
> 
> 
>  at org.gnu.glpk.GLPKJNI.glp_set_mat_row(Native Method)
> 
> 
>  at org.gnu.glpk.GLPK.glp_set_mat_row(GLPK.java:382)
> 
> 
>  
> 
> but although I have found the Javadoc I seems difficult to me to explain
> the reason for my error.
> 
>  
> 
> My questions are
> 
>  
> 
>  1. Can anybody explain this error?
>  2. Is is possible to create the GPLK for Java problem instances by
> loading GMPL source code from a file?
>  3. Can we write a problem correctly created with GPLK for Java to a
> GMPL source code file on disk?
>  
> 
> The answer to Q3 is the line
> 
>  
> 
> 
> GLPK.glp_write_lp(lp, null, "mincost.lp");
> 
> 
>  
> 
> which I found in the example MinimumCostFlow.java so 
> 
>  
> 
> glp_read_lp
> public static int glp_read_lp(glp_prob P,
>   glp_cpxcp parm,
>   String fname)
>  
> 
> should be the answer to Q2. If the latter will help me load the above
> GMPL Problem into GLPK and GPLK for Java could generate a Java source
> file creating an instance of the Problem that has been loaded into an
> GLPK object then my current Problem would be solved.
> 
> 
> 
>  
> 
>   * Is somebody able to devise a general method for generating the
> Java source creating a GLPK instance which represents a problem
> described by GMPL code above?
> 
>  
> 
>  
> 
> This is my current Code:
> 
>  
> 
> import org.gnu.glpk.GLPK;
> 
> import org.gnu.glpk.GLPKConstants;
> 
> import org.gnu.glpk.GlpkException;
> 
> import org.gnu.glpk.SWIGTYPE_p_double;
> 
> import org.gnu.glpk.SWIGTYPE_p_int;
> 
> import org.gnu.glpk.glp_prob;
> 
> import org.gnu.glpk.glp_smcp;
> 
>  
> 
> public class Produktionsplanung {
> 
> // Minimize z = -3 * x1 - x2
> 
> //
> 
> // subject to
> 
> //  2 * x2  <=  6
> 
> // 2 * x1 + 3 * x2  <= 13
> 
> // x1   <=  5
> 
> // where,
> 
> // 0.0 <= x1
> 
> // 0.0 <= x2
> 
>  
> 
> public static void main(String[] arg) {
> 
> glp_prob lp;
> 
> glp_smcp parm;
> 
> SWIGTYPE_p_int ind;
> 
> SWIGTYPE_p_double val;
> 
> int ret;
> 
>  
> 
> try {
> 
> // Create problem
> 
> lp = GLPK.glp_create_prob();
> 
> System.out.println("Problem created");
> 
> GLPK.glp_set_prob_name(lp, "myProblem");
> 
>  
> 
> // Define one column per variable (2)
> 
> GLPK.glp_add_cols(lp, 2);
> 
> GLPK.glp_set_col_name(lp, 1, "x1");
> 
> GLPK.glp_set_col_kind(lp, 1, GLPKConstants.GLP_CV);
> 
> GLPK.glp_set_col_bnds(lp, 1, GLPKConstants.GLP_DB, 0, 100);
> 
> GLPK.glp_set_col_name(lp, 2, "x2");
> 
> GLPK.glp_set_col_kind(lp, 2, GLPKConstants.GLP_CV);
> 
> GLPK.glp_set_col_bnds(lp, 2, GLPKConstants.GLP_DB, 0, 100);
> 
>  
> 
> // Create constraints
> 
>  
> 
> // Allocate memory
> 
> ind = GLPK.new_intArray(3);
> 
> val = GLPK.new_doubleArray(2);
> 
>  
> 
> // Create one row per constraint (3)
> 
> GLPK.glp_add_rows(lp, 3);
> 
>  
> 
> // Set row details
> 
> // subject to 2 * x2 <=  6
> 
> GLPK.glp_set_row_name(lp, 1, "c1");
> 
> GLPK.glp_set_row_bnds(lp, 1, 

Re: [Help-glpk] High-dimensinal outer totalistic rule CA genetator for Wolfram CA emulation

2017-09-12 Thread Heinrich Schuchardt
On 09/12/2017 10:33 AM, v...@cs.elte.hu wrote:
> Greetings!
> 
> I would like to contribute the attached example CPLEX LP model in the
> next release of GLPK. Reviews, opinions, suggestions and bug reports are
> kindly welcome!
> 
> This is an automatically generated model file, which was a part of an
> exhaustive search batch process. Tidied (automatically with selfmade
> custom tools) for this contribution.
> 
> Model results were published here:
> http://conwaylife.com/forums/viewtopic.php?f=11=2598#p38406
> 
> Thanks in advance,
> NASZVADI, Peter
> 

Hello Peter,

thank for your example which comes with a good lot of explanatory text.

GLPK uses the GMPL modeling language. Are you able to reformulate your
problem in GMPL? I think that would make the model file much more
instructive.

Best regards

Heinrich

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


Re: [Help-glpk] Thread Safety of GLPK

2017-08-30 Thread Heinrich Schuchardt
On 08/30/2017 08:13 PM, Simone Atzeni wrote:
> Heinrich,
> 
> looking at the thread example I added the glp_config("TLS”) check and I was 
> getting a undefined reference which made me realized that for some reason I 
> was linking to a wrong and old GLPK library instead of the one manually 
> compiled by me.
> 
> So it’s all good now.

Nice to hear.

Still I heavily recommend to use an error hook function. Otherwise an
error in GLPK will stop your whole application.

Best regards.

Heinrich


> 
> Thanks for your help!
> Best,
> Simone
> 
>> On Aug 30, 2017, at 12:04, Heinrich Schuchardt <xypron.g...@gmx.de> wrote:
>>
>> On 08/30/2017 07:23 PM, Simone Atzeni wrote:
>>> Hi Heinrich,
>>>
>>> you mean the line:
>>>
>>> std::string filename = "ilp_problem" + std::to_string(rand()) + ".lp”;
>>>
>>> or the problem name:
>>>
>>> glp_set_prob_name(mip, "overlap”);
>>>
>>> The filename is not used at all in the function, it was just something I 
>>> forgot to remove.
>>
>> Sorry I got that wrong.
>>
>> Giving the problem the same name should not be a problem because the
>> name is in thread local memory.
>>
>> Please, add the error catching code as in the example code.
>>
>> If this catches your error you should be able identify the responsible
>> line of code by setting a variable after each line and writing it to the
>> console in the error hook function.
>>
>> Regards
>>
>> Heinrich
>>
>>
>>>
>>> Thanks,
>>> Simone
>>>
>>>
>>>> On Aug 30, 2017, at 11:05, Heinrich Schuchardt <xypron.g...@gmx.de> wrote:
>>>>
>>>> Hello Simone,
>>>>
>>>> in your program all threads create random file names that are generated
>>>> from the same name space. The initial value of the random number
>>>> generator probably will be the same for all threads. This will lead to
>>>> two threads trying to write the same file.
>>>>
>>>> Either use a Singleton for the file name creation or use separate
>>>> namespaces by refering to the thread id like:
>>>> solution--counter.txt
>>>>
>>>> Your code lacks proper error handling for errors.
>>>>
>>>> You should path unique filenames to the threads.
>>>>
>>>> Please, have a look at glpk-4.63/examples/threads. It shows how to
>>>> handle GLPK errors in multithreaded applications.
>>>>
>>>> The example code creates one thread per problem. In a real world program
>>>> you should use a thread pool.
>>>>
>>>> Best regards
>>>>
>>>> Heinrich Schuchardt
>>>>
>>>>
>>>> On 08/30/2017 05:51 AM, Simone Atzeni wrote:
>>>>> Hi all,
>>>>>
>>>>> thanks for your answers.
>>>>> I updated to version 4.63, but I keep getting errors such as 
>>>>> "segmentation fault" or "glp_free: memory allocation error”.
>>>>>
>>>>> I have a function, with a few parameters in input, which creates the MIP 
>>>>> and solve it (attached the function which creates the MIP).
>>>>> This function is called by multiple threads with different parameters and 
>>>>> they do not share any data.
>>>>> As soon as I call the function within a mutex lock/unlock everything 
>>>>> works fine.
>>>>>
>>>>> I compiled the GLPK package with Clang/LLVM 4.9 which has support for 
>>>>> TLS, so I think everything should be fine.
>>>>> Do I need to do something else to make GLPK thread safe?
>>>>>
>>>>> Thanks.
>>>>> Best,
>>>>> Simone
>>>
>>>
> 
> 


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


Re: [Help-glpk] Thread Safety of GLPK

2017-08-30 Thread Heinrich Schuchardt
On 08/30/2017 07:23 PM, Simone Atzeni wrote:
> Hi Heinrich,
> 
> you mean the line:
> 
> std::string filename = "ilp_problem" + std::to_string(rand()) + ".lp”;
> 
> or the problem name:
> 
> glp_set_prob_name(mip, "overlap”);
> 
> The filename is not used at all in the function, it was just something I 
> forgot to remove.

Sorry I got that wrong.

Giving the problem the same name should not be a problem because the
name is in thread local memory.

Please, add the error catching code as in the example code.

If this catches your error you should be able identify the responsible
line of code by setting a variable after each line and writing it to the
console in the error hook function.

Regards

Heinrich


> 
> Thanks,
> Simone
> 
> 
>> On Aug 30, 2017, at 11:05, Heinrich Schuchardt <xypron.g...@gmx.de> wrote:
>>
>> Hello Simone,
>>
>> in your program all threads create random file names that are generated
>> from the same name space. The initial value of the random number
>> generator probably will be the same for all threads. This will lead to
>> two threads trying to write the same file.
>>
>> Either use a Singleton for the file name creation or use separate
>> namespaces by refering to the thread id like:
>> solution--counter.txt
>>
>> Your code lacks proper error handling for errors.
>>
>> You should path unique filenames to the threads.
>>
>> Please, have a look at glpk-4.63/examples/threads. It shows how to
>> handle GLPK errors in multithreaded applications.
>>
>> The example code creates one thread per problem. In a real world program
>> you should use a thread pool.
>>
>> Best regards
>>
>> Heinrich Schuchardt
>>
>>
>> On 08/30/2017 05:51 AM, Simone Atzeni wrote:
>>> Hi all,
>>>
>>> thanks for your answers.
>>> I updated to version 4.63, but I keep getting errors such as "segmentation 
>>> fault" or "glp_free: memory allocation error”.
>>>
>>> I have a function, with a few parameters in input, which creates the MIP 
>>> and solve it (attached the function which creates the MIP).
>>> This function is called by multiple threads with different parameters and 
>>> they do not share any data.
>>> As soon as I call the function within a mutex lock/unlock everything works 
>>> fine.
>>>
>>> I compiled the GLPK package with Clang/LLVM 4.9 which has support for TLS, 
>>> so I think everything should be fine.
>>> Do I need to do something else to make GLPK thread safe?
>>>
>>> Thanks.
>>> Best,
>>> Simone
> 
> 


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


Re: [Help-glpk] Thread Safety of GLPK

2017-08-30 Thread Heinrich Schuchardt
Hello Simone,

in your program all threads create random file names that are generated
from the same name space. The initial value of the random number
generator probably will be the same for all threads. This will lead to
two threads trying to write the same file.

Either use a Singleton for the file name creation or use separate
namespaces by refering to the thread id like:
solution--counter.txt

Your code lacks proper error handling for errors.

You should path unique filenames to the threads.

Please, have a look at glpk-4.63/examples/threads. It shows how to
handle GLPK errors in multithreaded applications.

The example code creates one thread per problem. In a real world program
you should use a thread pool.

Best regards

Heinrich Schuchardt


On 08/30/2017 05:51 AM, Simone Atzeni wrote:
> Hi all,
> 
> thanks for your answers.
> I updated to version 4.63, but I keep getting errors such as "segmentation 
> fault" or "glp_free: memory allocation error”.
> 
> I have a function, with a few parameters in input, which creates the MIP and 
> solve it (attached the function which creates the MIP).
> This function is called by multiple threads with different parameters and 
> they do not share any data.
> As soon as I call the function within a mutex lock/unlock everything works 
> fine.
> 
> I compiled the GLPK package with Clang/LLVM 4.9 which has support for TLS, so 
> I think everything should be fine.
> Do I need to do something else to make GLPK thread safe?
> 
> Thanks.
> Best,
> Simone

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


Re: [Help-glpk] [Fwd: C# API Exception]

2017-06-13 Thread Heinrich Schuchardt
Hello Curtis,

the error you received that the GLPK library could not be called.

In your project you will need the following:

* glpk_4_61.dll - the GLPK native library
* libglpk_cli_native.dll - the GLPK for C#/CLI native library
* libglpk_cli.dll - the GLPK for C#/CLI assembly

libglpk_cli.dll is just a wrapper for the GLPK library.
It calls the libglpk_cli_native.dll library
which in turn calls the glpk_4_61.dll library.

Best regards

Heinrich Schuchardt

On 06/13/2017 07:33 AM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: 'help-glpk@gnu.org' <help-glpk@gnu.org>
> Subject: C# API Exception
> Date: Mon, 12 Jun 2017 22:51:50 +
> 
> Good afternoon,
> 
> I wanted to know if I could ask for help when working with the GLPK API.
> I imported the libglpk-cli.dll from the source code into Visual Studio
> 2015 as part of my references.
> 
> Following the example in the source code, I included the code listed
> below.
> 
> When I compiled, I had the exception thrown.
> 
> Any help would be greatly appreciated.
> 
> Thanks for all of the hard work that you do,
> 
> Curtis Passorelli
> 
> Exception:
> 
> An unhandled exception of type 'System.TypeInitializationException'
> occurred in libglpk-cli.dll
> 
> Additional information: The type initializer for
> 'org.gnu.glpk.GLPKPINVOKE' threw an exception.
> 


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


Re: [Help-glpk] glp_intopt runs forever (related to Dusan Plavak's issue)

2017-06-10 Thread Heinrich Schuchardt
Hello Rafael,

even after scaling your model the ratio between minimum and maximum
coefficient in the matrix is very big. See below.

Please, check the code that generates your model:

Can't the following values be set to zero:
+ 4e-12 x_5

Maybe these values just arise due to rounding errors in the code you use
to generate the model?

Maybe also the difference between the x_5 coefficients in r_1 and r_2
are due to rounding errors?

You could simply round all values to the nearest multiple of
10E-8 or of 2^-27.

#include 
ar[counter] = floor(1. * left_parts[i][j] + .5) / 1.;

Best regards

Heinrich Schuchardt

Writing problem data to 'problem.lp'...
51 lines were written
GLPK Integer Optimizer, v4.62
13 rows, 9 columns, 73 non-zeros
5 integer variables, none of which are binary
Preprocessing...
9 rows, 9 columns, 53 non-zeros
5 integer variables, none of which are binary
Scaling...
 A: min|aij| =  4.000e-12  max|aij| =  1.875e+01  ratio =  4.688e+12
GM: min|aij| =  4.116e-04  max|aij| =  2.430e+03  ratio =  5.903e+06
EQ: min|aij| =  1.694e-07  max|aij| =  1.000e+00  ratio =  5.903e+06
2N: min|aij| =  1.242e-07  max|aij| =  1.435e+00  ratio =  1.156e+07
Constructing initial basis...
Size of triangular part is 9
Solving LP relaxation...
GLPK Simplex Optimizer, v4.62
9 rows, 9 columns, 53 non-zeros
  0: obj =   0.0e+00 inf =   3.793e+04 (4)
  6: obj =   6.353265000e+00 inf =   0.000e+00 (0)
* 9: obj =  -6.292433767e-16 inf =   1.722e-12 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
+ 9: mip = not found yet >=  -inf(1; 0)
+20: >>>>>   1.799565000e-01 >=  -5.670240878e-16 100.0% (8; 0)
Warning: numerical instability (dual simplex, phase II)
Warning: numerical instability (dual simplex, phase II)
Warning: numerical instability (dual simplex, phase II)



On 06/10/2017 12:29 PM, Rafael Korbaš wrote:
> Hello Heinrich,
> 
> 
> I'm Dusan's colleague and I'm also trying to understand, why our
> lp-solving function in certain conditions loops forever. Dusan forwarded
> me your email and I've read it. As you pointed out, if we try to solve
> the problem statement obtained through the glp_write_lp(), everything is
> fine.
> 
> Therefore I came up with a compilable C++ code (the "main.cpp"
> attachment) that replicates the issue. The problem statement is
> hardcoded, so the only thing you need to do is to compile it, e.g. with
> the following command:
> 
> g++ main.cpp -std=gnu++11 -lglpk
> 
> And run it.
> 
> It should output the line "51 lines were written", since it writes the
> problem statement to the problem.lp file and afterwards, it loops
> foreverer at the line 152 (the "glp_intopt" call). I have a feeling that
> the "problem.lp" file gets solved without problems, because of some
> rounding during the output of the "glp_write_lp" function, but I don't
> see that deep into the issue to draw any conclusions.
> 
> I use the latest available version of libglpk, i.e. version 4.61, the
> same as Dusan.
> 
> I hope that I provided you enough information to replicate the behavior
> by yourself and if you need anything else, don't hesitate to write us an
> email.
> 
> 
> Best regards,
> 
> Rafael
> 

\* Problem: amounts *\

Minimize
 obj: + 0.03 x_6 + 0.0375 x_7 + 0.075 x_8 + 0.0375 x_9

Subject To
 r_1: + 9.3 x_5 + 2.548 x_4 + 0.17905 x_3 + 5.0773125 x_2 + 1.0491 x_1
 - ~r_1 = -8
 r_2: + 9.3 x_5 + 0.744 x_4 + 0.02325 x_3 + 0.6800625 x_2 + 0.0651 x_1
 - ~r_2 = -32000
 r_3: + 0.369 x_4 + 0.10291 x_3 + 3.5285625 x_2 + 0.0082 x_1 - ~r_3
 = -16000
 r_4: + 1.435 x_4 + 0.05289 x_3 + 0.8686875 x_2 + 0.9758 x_1 - ~r_4
 = -32000
 r_5: + x_5 + 10 x_4 + x_3 + 18.75 x_2 + x_1 <= 800
 r_6: + x_6 + 9.3 x_5 + 2.548 x_4 + 0.17905 x_3 + 5.0773125 x_2
 + 1.0491 x_1 >= 400
 r_7: - x_6 + 9.3 x_5 + 2.548 x_4 + 0.17905 x_3 + 5.0773125 x_2
 + 1.0491 x_1 <= 400
 r_8: + x_7 + 9.3 x_5 + 0.744 x_4 + 0.02325 x_3 + 0.6800625 x_2
 + 0.0651 x_1 >= 160
 r_9: - x_7 + 9.3 x_5 + 0.744 x_4 + 0.02325 x_3 + 0.6800625 x_2
 + 0.0651 x_1 <= 160
 r_10: + x_8 + 0.369 x_4 + 0.10291 x_3 + 3.5285625 x_2 + 0.0082 x_1
 >= 80
 r_11: - x_8 + 0.369 x_4 + 0.10291 x_3 + 3.5285625 x_2 + 0.0082 x_1
 <= 80
 r_12: + x_9 + 1.435 x_4 + 0.05289 x_3 + 0.8686875 x_2 + 0.9758 x_1
 >= 160
 r_13: - x_9 + 1.435 x_4 + 0.05289 x_3 + 0.8686875 x_2 + 0.9758 x_1
 <= 160

Bounds
 0 <= ~r_1 <= 16
 0 <= ~r_2 <= 64000
 0 <= ~r_3 <= 32000
 0 <= ~r_4 <= 64000
 100 <= x_1 <= 400
 8 <= x_2 <= 16
 2 <= x_3 <= 400
 4 <= x_4 <= 20
 4 <= x_5 <= 30

Generals
 x_1
 x_2
 x_3
 x_4
 x_5

End
___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] Loading matrix param from Excel table in GLPK

2017-03-10 Thread Heinrich Schuchardt
Hello Rodolfo,

I guess it would be a better idea to format the CSV such that C1 and C2
values go into columns:

ITU,AGU,5
ITU,CEN,6
PMO,AGU,7
PMO,CEN,8

Otherwise use:

set D, dimen 3;
set C2;
set C1 := setof{(i,j,k) in D} i;
param traffic_st{i in C1, j in C2} >=0 :=
  if j = "AGU" then sum{(i,k,l) in D} k else sum{(i,k,l) in D} l;
table t1 IN "CSV" "foo.csv" :
D <- [IDX, AGU, CEN];
display traffic_st;
data;
set C2:=AGU CEN;
end;

with foo.csv:

IDX,AGU,CEN
ITU,5,6
PMO,7,8

Please, be aware that GLPK for Windows 4.61 comes with examples for
using the GLPK library with Visual Basic for Applications (VBA).

Best regards

Heinrich
On 03/10/2017 09:00 PM, Rodolfo Grosso wrote:
> Hi,
> 
> I want to pass matrix values contained in excel file or csv to a
> matrix parameter, for example, Excel table:
>  AGUCEN
> ITU  56
> PMO   78
> 
> 
> 
> So that I can read  through the parameter traffic:
> 
> traffic[ITU,AGU]=5
> traffic[PMO,AGU]=7
> ...
> 
> In the real case there are many values.
> 
> For this, I made the following code, but it did not work:
> 
> set C1;
> set C2;
> param traffic_st{C1,C2} >=0;
> 
> table data IN "CSV" "traffic_st1.csv":
> [i ~ C1], {j in C2} ;
> 
> and I define C2 in .dat file like:
> 
> set C2:=AGU CEN;
> 
> 
> Thank you in advance for your help
> 
> 
> Best regards.
> Rodolfo


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


Re: [Help-glpk] [Fwd: Download help]

2017-02-16 Thread Heinrich Schuchardt
Hello Christian,

see
https://en.m.wikibooks.org/wiki/GLPK

Best regards

Heinrich Schuchardt

http://www.xypron.de

Am 15.02.17 um 17:49 schrieb Andrew Makhorin

>  Forwarded Message 
> From: Christian Samatis <cgsama...@gmail.com>
> To: help-glpk@gnu.org
> Subject: Download help
> Date: Wed, 15 Feb 2017 09:00:38 -0500
> 
> Hello,
> 
> 
> I am completely new to programming and I am trying to download GLPK to
> my computer via the link  http://ftp.gnu.org/gnu/glpk/ However, I am not
> sure how to accomplish this. When I click on the link it opens an Index
> with a ton of files. Which file(s) am I supposed to open/and or save to
> my computer?  How do I gain access to GLPK?
> 
> 
> Thanks for all the help,
> Christian Samatis
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk

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


[Help-glpk] xstrerror

2017-01-31 Thread Heinrich Schuchardt
Hello Andrew,

the glibc implementation of strerror uses a buffer of 1024 bytes.

See
https://sourceware.org/git/?p=glibc.git;a=blob;f=string/strerror.c;h=0d235c6b6b7f720ae1b8839b7dc00222b29a4717;hb=HEAD

I suggest that you use the same size in xstrerror.

Best regards

Heinrich


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


Re: [Help-glpk] things I don't understand in src/env/time.c + bugs + suggested patch

2017-01-29 Thread Heinrich Schuchardt
On 01/29/2017 06:22 PM, Andrew Makhorin wrote:
> Hi Chris,
> 
>>> Not sure, but gmtime_s looks like a MSVC function. Could you point me
>>> out where gmtime_s is standardized? Thanks.
>>
>> gmtime_s is included in the (optional) annex K of C11. However, the
>> parameters are reversed compared to the MSVC version and the standard
>> one returns struct tm * while the MSVC one returns errno_t.
>>
>> Moreover, some searching shows that gmtime_s is documented starting
>> with VS 2010 (and _gmtime_s in VS 2005 and VS 2008). However, since VS
>> 2005 gmtime returns a different pointer per thread [1], so there is no
>> reason to use gmtime_s here - gmtime_s offers additional error
>> checking for null pointers, which is not an issue in this code.
>>
> 
> Thank you for information.
> 
> As Heinrich noticed, gmtime, strerror, and strtok are non-thread-safe
> (for example, in most recent version of glibc strtok just uses a static
> pointer without a tls specifier), so in a multi-threaded environment
> thread-safe versions of these functions should be used. The problem I
> encountered is that gcc (Debian 4.7.2-5) 4.7.2 installed on my Linux
> machine doesn't have gmtime_s, strerror_s, and strtok_s. It is unclear
> what to do if no thread-safe version of these functions are available.
> 

glibc (and POSIX 2008) has these functions:

struct tm *gmtime_r(const time_t *timep, struct tm *result);
int strerror_r(int errnum, char *buf, size_t buflen);
char *strtok_r(char *str, const char *delim, char **saveptr);

Windows (and C11) supply

errno_t gmtime_s(struct tm* _tm, const __time_t* time);
errno_t strerror_s(char *buffer, size_t numberOfElements, int errnum);
char *strtok_s(char *strToken, const char *strDelimit, char **context);

We can use __WOE__ to decide which function to use.

Best regards

Heinrich Schuchardt

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


[Help-glpk] Thred safety

2017-01-28 Thread Heinrich Schuchardt
Here is a list of functions that are not thread safe under POSIX 2008:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_01

Problematic coding includes:
strtok used in mplsql.c
gmtime used in time.c
strerror used in stream.c, gzguts.h, mpl6.c, glprpr.c

I wonder if dlsup.c is thread safe.

Best regards

Heinrich Schuchardt


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


[Help-glpk] GLPK for Windows 4.61

2017-01-28 Thread Heinrich Schuchardt
GLPK for Windows 4.61 has been released. It is available at
http://winglpk.sourceforge.net. It comes with 32bit (cdecl and stdcall)
and 64bit binaries and libraries.

Examples for usage with VBA (Visual Basic for Applications) and
LibreOffice have been added.

The distribution includes Glpk for C#/CLI 1.8.0 providing a .NET/Mono
wrapper for GLPK 4.61 and Glpk for Java 1.8.0 providing a Java binding
for GLPK 4.61.

Best regards

Heinrich Schuchardt

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


Re: [Help-glpk] things I don't understand in src/env/time.c + bugs + suggested patch

2017-01-28 Thread Heinrich Schuchardt
On 01/28/2017 01:31 PM, David Monniaux wrote:
> Over glpk-4.61
> 
> src/env/time.c contains:
> 
> double glp_time(void)
> { struct timeval tv;
>   struct tm *tm;
>   int j;
>   double t;
>   gettimeofday(, NULL);
>   tm = gmtime(_sec);
>   j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
>   xassert(j >= 0);
>   t = double)(j - EPOCH) * 24.0 + (double)tm->tm_hour) * 60.0 +
>  (double)tm->tm_min) * 60.0 + (double)tm->tm_sec) * 1000.0 +
>  (double)(tv.tv_usec / 1000);
>   return t;
> }
> 
> This code suffers from several problems:
> - The division tv.tv_usec / 1000 is integer division, then converted to
> double; why not simply multiply by 1E-3, which is more precise?
> - It uses gmtime, which is not reentrant (as opposed to gmtime_r). In
> fact, my attention was called to this function because of error reports
> by Valgrind's DRD race condition analyser ran on code using glpk from
> different threads.

It is a shame that glibc does not define _tmbuf as thread local memory.

gmtime_r is not C standard but POSIX specific.
The relevant C11 function is gmtime_s.

It should be supported with GCC 4.7 and later.
So probably we should check for gmtime_s in configure.ac.

> 
> I also do not understand why it is useful to use such a function,
> calling jday() to convert Julian days, whereas the following returns the
> same result:
> 
> double glp_time(void)
> { struct timeval tv;
>gettimeofday(, NULL);
>   return tv.tv_sec + 1E3 * tv.tv_usec * 1E-3;

1E3 * 1E-3 = 1.
You wouldn't add seconds and microseconds without scaling.

tv_sec is counting from 0 to 59 (or 60 if you have leap second).
Why do you want to return the same values for 11:01:00 and 11:02:00?

> }
> 
> What am I missing?
> 
> If I'm missing nothing, this patch simplifies the code:
> 
> --- glpk-4.61-orig/src/env/time.c2017-01-22 08:00:00.0 +0100
> +++ glpk-4.61-time-patched/src/env/time.c2017-01-28
> 13:09:07.367464607 +0100
> @@ -53,17 +53,8 @@
>  
>  double glp_time(void)
>  { struct timeval tv;
> -  struct tm *tm;
> -  int j;
> -  double t;
>gettimeofday(, NULL);
> -  tm = gmtime(_sec);
> -  j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
> -  xassert(j >= 0);
> -  t = double)(j - EPOCH) * 24.0 + (double)tm->tm_hour) * 60.0 +
> - (double)tm->tm_min) * 60.0 + (double)tm->tm_sec) * 1000.0 +
> - (double)(tv.tv_usec / 1000);
> -  return t;
> +  return tv.tv_sec + 1E3 * tv.tv_usec * 1E-3;
>  }
>  
>  /* MS Windows version */
> @@ -92,17 +83,7 @@
>  #include 
>  
>  double glp_time(void)
> -{ time_t timer;
> -  struct tm *tm;
> -  int j;
> -  double t;
> -  timer = time(NULL);
> -  tm = gmtime();
> -  j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
> -  xassert(j >= 0);
> -  t = double)(j - EPOCH) * 24.0 + (double)tm->tm_hour) * 60.0 +
> - (double)tm->tm_min) * 60.0 + (double)tm->tm_sec) * 1000.0;
> -  return t;
> +{  return time(NULL) * 1E3;
>  }
>  
>  #endif
> 
> Regards
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] [Fwd: GLPK Infeasibility set inquiry]

2017-01-23 Thread Heinrich Schuchardt
Hello Xiaoxuan,

your mail had to be forwarded manually because you are not subscribed to
the GLPK help list, see
https://lists.gnu.org/mailman/listinfo/help-glpk

Library function glp_get_unbnd_ray returns one column or row leading to
primal or dual unboundedness.

Please, observe that if you use the presolver the column or row number
will relate to the presolved problem.

To get the column or row name you will have to call either of
glp_get_row_name or glp_get_col_name. This will only work if you do not
use the presolver.

For details see doc/glpk.pdf of the source distribution.

Best regards

Heinrich Schuchardt

On 01/23/2017 05:23 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: help-glpk@gnu.org
> Subject: GLPK Infeasibility set inquiry
> Date: Mon, 23 Jan 2017 10:46:54 -0500
> 
> Dear All,
> 
> 
> I just started learning using GLPK and I was wondering if there is an
> infeasibility set that helps users resolve issues with the run?
> 
> 
> I have seen a similar question on the list that got a "no" answer but it
> was in 2008, so I'd like to double check if there had been any updates.
> Please let me know if I should raise the question somewhere else. 
> 
> 
> Thank you so much!
> Xiaoxuan
> 
> 
> 
> ___
> Help-glpk mailing list
> Help-glpk@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 


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


Re: [Help-glpk] 1024 bit key used to sign GLPK distribution package

2017-01-23 Thread Heinrich Schuchardt
The procedure to upload new keys is described here
https://www.gnu.org/prep/maintain/maintain.html

If in doubt contact the GNU administrators.

Best regards

Heinrich Schuchardt

http://www.xypron.de

Am 23.01.17 um 10:25 schrieb Andrew Makhorin

> Hi Heinrich,
> 
> > you are using a 1024 bit key for signing GLPK distribution tar balls.
> > 
> > 1024 bit is no longer considered safe. Cf.
> > http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57-Part1-revised2_Mar08-2007.pdf
> > 
> > Furthermore you are using SHA-1 for signing.
> > SHA1 is also regarded as unsafe.
> > 
> > Please, create a signing key of at least and cross sign it with your old
> > 1024 bit key. You might use SHA-256 for signing.
> > 
> 
> Thanks for information. However, I follow the instruction for GNU
> maintainers, which requires a certain procedure to upload the tarballs
> to the main ftp site:
> 
>   For each upload destined for ftp.gnu.org or alpha.gnu.org, 
>   three files (a triplet) need to be uploaded via ftp ...
> 
>  (1) File to distributed (eg. foo.tar.gz)
> 
>  (2) Detached GPG binary signature for (1) (using gpg -b)
> (eg. foo.tar.gz.sig)
> 
>  (3) Clearsigned "directive" file (using gpg --clearsign)
>  (eg. foo.tar.gz.directive.asc)
> 
> I cannot change my gpg keys, because this would invalidate my signature
> recognized at GNU.
> 
> 
> Best regards,
> 
> Andrew Makhorin

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


[Help-glpk] 1024 bit key used to sign GLPK distribution package

2017-01-23 Thread Heinrich Schuchardt
Hello Andrew,

you are using a 1024 bit key for signing GLPK distribution tar balls.

1024 bit is no longer considered safe. Cf.
http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57-Part1-revised2_Mar08-2007.pdf

Furthermore you are using SHA-1 for signing.
SHA1 is also regarded as unsafe.

Please, create a signing key of at least and cross sign it with your old
1024 bit key. You might use SHA-256 for signing.

Best regards

Heinrich Schuchardt

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


[Help-glpk] TLS example

2017-01-17 Thread Heinrich Schuchardt
Hello Andrew,

I suggest to rename
  examples/tls
to
  examples/multithreading.

This will make it more obvious what can be found here.

Best regards

Heinrich

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


Re: [Help-glpk] [Fwd: Solutions upon timeout]

2017-01-17 Thread Heinrich Schuchardt
Hello Pietro,

your message had to be forwarded manually because you are not subscribed
to the GLPK help list, cf.
https://lists.gnu.org/mailman/listinfo/help-glpk

Yes, glp_mip_col_val will return the best known integer
feasible solution.

You can use glp_mip_status to find out if any integer solution exists
and if this solution is optimal.

For a description see glpk-4.60/doc/glpk.pdf of the source distribution
available at
http://ftp.gnu.org/gnu/glpk/glpk-4.60.tar.gz

Best regards

Heinrich

On 01/17/2017 04:58 PM, Andrew Makhorin wrote:
>  Forwarded Message 
> To: help-glpk@gnu.org
> Subject: Solutions upon timeout
> Date: Tue, 17 Jan 2017 14:15:38 +0100
> 
> Hello to everybody. I am using GLPK as a library in a
> software I am writing. My question is: if I set a
> timeout to a MIP search (tm_limit field in a glp_iocp
> structure) and then glp_intopt times out, how do I
> obtain the best known integer feasible solution found so
> far? Is it ok to use glp_mip_col_val?
> Thank you
> Pietro 


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


Re: [Help-glpk] Fwd: Re: Infinite cycles

2017-01-16 Thread Heinrich Schuchardt
On 01/16/2017 11:59 PM, Andrew Makhorin wrote:
> 
>> the interesting thing about Matheu's example is that the infeasability
>> is constantly increasing over multiple orders of magnitude.
> 
> I'm unable to reproduce the effect. Glpsol with default options has no
> problem on solving Mathieu's example. If --norelax option is specified,
> the primal simplex falls into infinite loop, but this might be expected,
> because Harris' ratio test (that is, --relax option used by default)
> decreases the number of degenerate steps and thus prevents cycling in
> many cases. If the primal simplex fails, I'd recommend using --dual and
> --flip options.
> 
> 
> Andrew Makhorin
> 
> 

With GLPK 4.61 on Linux 64bit and --norelax it is not simply an infinite
loop. The infeasibility increases constantly as shown in the log below.

glpsol -m GLP_buggy_6d21.mod --norelax

*   500: obj =   1.262121212e+04 inf =   4.004e-15 (2)
*  1000: obj =   1.262121212e+04 inf =   1.052e-14 (2)
*  1500: obj =   1.262121212e+04 inf =   1.703e-14 (2)
*  2000: obj =   1.262121212e+04 inf =   2.355e-14 (2)
*  2500: obj =   1.262121212e+04 inf =   3.006e-14 (2)
*  3000: obj =   1.262121212e+04 inf =   3.658e-14 (2)
*  3500: obj =   1.262121212e+04 inf =   4.309e-14 (2)
*  4000: obj =   1.262121212e+04 inf =   4.961e-14 (2)
*  4500: obj =   1.262121212e+04 inf =   5.612e-14 (2)
*  5000: obj =   1.262121212e+04 inf =   6.264e-14 (2)
*  5500: obj =   1.262121212e+04 inf =   6.915e-14 (2)
*  6000: obj =   1.262121212e+04 inf =   7.567e-14 (2)
*  6500: obj =   1.262121212e+04 inf =   8.218e-14 (2)
*  7000: obj =   1.262121212e+04 inf =   8.870e-14 (2)
*  7500: obj =   1.262121212e+04 inf =   9.521e-14 (2)
*  8000: obj =   1.262121212e+04 inf =   1.017e-13 (2)
...
*177000: obj =   1.262121211e+04 inf =   2.304e-12 (2)
*177500: obj =   1.262121211e+04 inf =   2.310e-12 (2)
*178000: obj =   1.262121211e+04 inf =   2.317e-12 (2)
*178500: obj =   1.262121211e+04 inf =   2.323e-12 (2)
*179000: obj =   1.262121211e+04 inf =   2.330e-12 (2)
...
*826000: obj =   1.262121208e+04 inf =   1.076e-11 (2)
*826500: obj =   1.262121208e+04 inf =   1.077e-11 (2)
*827000: obj =   1.262121208e+04 inf =   1.077e-11 (2)
*827500: obj =   1.262121208e+04 inf =   1.078e-11 (2)
*828000: obj =   1.262121208e+04 inf =   1.079e-11 (2)
...
*10719000: obj =   1.262121156e+04 inf =   1.397e-10 (2)
*10719500: obj =   1.262121156e+04 inf =   1.397e-10 (2)
*1072: obj =   1.262121156e+04 inf =   1.397e-10 (2)
*10720500: obj =   1.262121156e+04 inf =   1.397e-10 (2)
*10721000: obj =   1.262121156e+04 inf =   1.397e-10 (2)


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


[Help-glpk] VBA examples

2017-01-15 Thread Heinrich Schuchardt
Hello Andrew,

in https://github.com/xypron/glpk/tree/glpk-4.60-stdcall/examples/vba
I have created some VBA examples. (Testing on 64bit Office is still needed.)

I also worked on LibreOffice Basic, but succeeded only on 32bit.

Are VBA examples something you would like to include in the GLPK source or 
should I add them to GLPK on Windows?

My understanding is that usage of GLPK in conjunction with a proprietary 
software is allowable but conveying both together is not allowable under GPL. 
Distributing an Excel spreadsheet sheet can be considered as distribution in 
source form when using an XML based file format like OpenDocument (odf) or open 
XML (xlsx) if the file is not password protected.

Best regards

Heinrich Schuchardt

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


[Help-glpk] glp_version: do not initialize env

2017-01-14 Thread Heinrich Schuchardt
Hello Andrew,

if a multithreaded application wants to determine if GLPK supports a
feature we now supply glp_config which does not initialize env.
I guess we should do the same for glp_version.

This makes env smaller and can safely be called even if the library is
not TLS enabled.

#define str(s) # s
#define xstr(s) str(s)

const char *glp_version(void)
{ return xstr(GLP_MAJOR_VERSION) "." xstr(GLP_MINOR_VERSION);
}

Best regards

Heinrich

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


[Help-glpk] Fwd: Re: Determining if the GLPK library is compiled to be reentrant.

2017-01-14 Thread Heinrich Schuchardt
Hello Andrew,

I guess the best solution will be to return the empty string "" when an
option is not set and NULL if the option does not exist.

Then we can use

const char *ret = get_config("TLS");
if (!ret || !*ret) {
fprintf(stderr, "TLS not supported");
pthread_exit(NULL);
}

Best regards

Heinrich Schuchardt


 Forwarded Message 
Subject: Re: [Help-glpk] Determining if the GLPK library is compiled to
be reentrant.
Date: Sat, 14 Jan 2017 10:25:25 +0100
From: Heinrich Schuchardt <xypron.g...@gmx.de>
To: Andrew Makhorin <m...@gnu.org>
CC: Help-glpk@gnu.org <Help-glpk@gnu.org>

Hello Andrew,

I understand that you do not want to create env before checking if TLS
is configured. But, please, do not call abort() in glp_config().

Otherwise your abort statement will stop the complete application.
Imagine that being the webserver for a site on which a webapp is
deployed which calls the GLPK library.

Either simply return NULL. Or define a value with signifies an error:

glpk.h:
#define GLP_INVALID ((const void *) -1)

env/env.c:
const char *glp_config(const char *option)
{
...
   return GLP_INVALID;
...
}

Best regards

Heinrich Schuchardt

On 01/14/2017 03:27 AM, Andrew Makhorin wrote:
>> a program that uses a GLPK library which is not compiled with thread
>> local storage may fail fatally when run with multiple threads.
>>
>> I hence suggest to add a function that allows to determine if GLPK was
>> compiled to be reentrant. We could use the same function to return other
>> features too.
> 
> Done. Please see an updated version of glpk here:
> http://sourceforge.net/projects/noumenon/files/tmp/
> (Note that this is *not* an official release.)
> 
> I added API routine glp_config (see it in src/env/env.c) which provides
> necessary functionality.
> 
> 
> Andrew Makhorin
> 
> 


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


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


Re: [Help-glpk] Determining if the GLPK library is compiled to be reentrant.

2017-01-14 Thread Heinrich Schuchardt
Hello Andrew,

I understand that you do not want to create env before checking if TLS
is configured. But, please, do not call abort() in glp_config().

Otherwise your abort statement will stop the complete application.
Imagine that being the webserver for a site on which a webapp is
deployed which calls the GLPK library.

Either simply return NULL. Or define a value with signifies an error:

glpk.h:
#define GLP_INVALID ((const void *) -1)

env/env.c:
const char *glp_config(const char *option)
{
...
   return GLP_INVALID;
...
}

Best regards

Heinrich Schuchardt

On 01/14/2017 03:27 AM, Andrew Makhorin wrote:
>> a program that uses a GLPK library which is not compiled with thread
>> local storage may fail fatally when run with multiple threads.
>>
>> I hence suggest to add a function that allows to determine if GLPK was
>> compiled to be reentrant. We could use the same function to return other
>> features too.
> 
> Done. Please see an updated version of glpk here:
> http://sourceforge.net/projects/noumenon/files/tmp/
> (Note that this is *not* an official release.)
> 
> I added API routine glp_config (see it in src/env/env.c) which provides
> necessary functionality.
> 
> 
> Andrew Makhorin
> 
> 


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


  1   2   3   >