[Fwd: GLPK doubt]

2024-02-07 Thread Andrew Makhorin
 Forwarded Message 

Date: Wed, 7 Feb 2024 16:17:04 -0300
Subject: GLPK doubt
To: help-glpk@gnu.org
From: Nicolas Herculano Pires 
> Dear esteemed GNU colleague,
> 
> I hope this message finds you well. I am writing to address an issue I
> have encountered with GLPK, albeit it may seem trivial, it remains a
> pertinent concern. I am currently grappling with GLPK in the context
> of solving an optimization problem, specifically pertaining to
> portfolio project selection and scheduling.
> 
> My dilemma lies in the utilization of GLPK without employing decision
> variables. Allow me to elucidate further: I am employing GLPK to
> tackle a portfolio project selection conundrum encompassing 200
> projects over a planning horizon of 60 months. However, I have been
> unable to find any resources or documentation on how to utilize GLPK
> without employing decision variables.
> 
> You may wonder, "What is the significance of reducing these variables
> through GLPK?" The essence of my inquiry lies in the potential
> reduction of variables. To illustrate, envision a scenario where each
> of the 60 columns represents a month, and among these, only one column
> is selected per project. This leaves the remaining 59 columns
> redundant. Consequently, would it not be more efficient to represent
> the selected month with a single indicator column, rather than
> allocating separate columns for each month?
> 
> For instance, if GLPK selects column 30 (corresponding to month 30),
> the preceding columns (1 to 29) and subsequent columns (31 to 60)
> would inherently hold values of zero, rendering them unnecessary.
> Therefore, it seems logical to streamline the representation by
> condensing the 60 columns into a single indicator column denoting the
> selected month.
> 
> One might inquire, "But what if no month is selected?" In such
> instances, I propose to designate a value of zero to indicate the
> absence of a selected month, effectively reducing the total number of
> variables from 12,000 to a mere 200.
> 
> I am keen to explore any insights or guidance you may provide on this
> matter. Your expertise and assistance in optimizing the utilization of
> GLPK would be immensely appreciated.
> 
> Warm regards,
> Nícolas Herculano
> 

Re: [Fwd: GLPK CMake build configuration (Windows)]

2024-01-29 Thread Andrew Makhorin
On Mon, 2024-01-29 at 12:25 -0500, Derek Huang wrote:
> Hi,
>  
> Quick update on this—I tried rebuilding clean again using the
> CMakeLists.txt and realized there is an issue with the glpk_5_0.def
> files in ./w32 and ./w64 since they list glp_netgen_prob as an export,
> but it has no definition for the linker to find. I would think either
> glp_netgen_prob should be removed from glpk.h and the .def file or
> some definition for glp_netgen_prob that just asserts should be added.

It is a minor annoying bug in the batch script for MS Windows.

Please see https://www.mail-archive.com/bug-glpk@gnu.org/msg01020.html .



>  
> There is also an issue with running tests using ctest due to how DLL
> lookup is done at runtime, as the example programs must be run from
> ./examples (inputs are relative to that directory) so the GLPK DLL is
> not picked up. Static library builds and testing are fine however.
>  
> I have updated the CMakeLists.txt docs to reflect these and have done
> a bit of cleanup and since I couldn’t fine official VCS for GLPK I’ve
> attached the updated file here.
>  
> Best,
> Derek
>  



[Fwd: GLPK CMake build configuration (Windows)]

2024-01-27 Thread Andrew Makhorin
 Forwarded Message 

Date: Sat, 27 Jan 2024 00:30:37 -0500
Subject: GLPK CMake build configuration (Windows)
To: help-glpk@gnu.org
From: Derek Huang 
> Hi,
> My name is Derek Huang; I am currently a quant [developer] at TD
> Securities. I needed to use GLPK at work on Windows but found the
> NMake Makefiles not sufficient for my purpose as I wanted the
> following:
> 
> 1. Ability to link against C runtime statically or dynamically
> 2. Build more of the example programs (except netgen, got error
> saying glp_netgen disabled for licensing reasons)
> 3. Provide installation rule for Windows distinguishing debug/release
> config + C runtime linking
> 4. Build PE32 (32-bit) or PE32+ (64-bit) on Windows from the same
> Developer Command Prompt
> 
> CMake makes this relatively straightforward to do so I spent some time
> at home today in the evening to write a CMakeLists.txt (attached). I
> am not sure what is the best way to make contributions upstream, hence
> why I have attached it to the email. It contains explanations on a few
> ways one can build, run tests, and install using CMake, and I have
> verified all example programs run properly for 32-bit and 64-bit Debug
> + Release static and dynamic builds. The CMake generator (underlying
> build tool) used is Visual Studio 2022. Unfortunately, however, I have
> not yet added any formal documentation outside of the CMakeLists.txt.
> 
> Please let me know if this could be accepted as part of the GLPK
> source base as an alternative method to build on Windows and if so, if
> there are any specific steps I should take to introduce it to the
> source tree. Thank you.
> 
> Best,
> Derek
> cmake_minimum_required(VERSION 3.15)

##
# Usage
# =
#
# This section provides some brief instructions on how to compile, test, and
# install GLPK using CMake. Although currently configured only for use on
# Windows, the config can be extended to support *nix systems as well.
#
# Note:
#
# This file can be split up into smaller .cmake files if desired. It is a few
# hundred lines long unfortunately in large part since the sources are all
# listed explicitly instead of using globs and because of the install logic.
#
# Windows
# ---
#
# The following items are values to be determined by the user. They are used in
# the build commands enclosed in brackets to distinguish them.
#
# Arch: Win32, x64
# Config: Debug, Release
# Prefix: (desired install root)
#
# Building
# 
#
# Build static linking against C runtime dynamically + also build examples:
#
#   cmake -S . -B build_windows_[Arch] -A [Arch]
#   cmake --build build_windows_[Arch] --config [Config] -j
#
# Build dynamic linking against C runtime statically + no examples:
#
#   cmake -S . -B build_windows_[Arch] -A [Arch] -DBUILD_SHARED_LIBS=ON ^
#   -DGLPK_USE_STATIC_CRT=ON -DGLPK_BUILD_EXAMPLES=OFF
#   cmake --build build_windows_[Arch] --config [Config] -j
#
# Build dynamic linking against C runtime dynamically + also build examples
# while installing with multi-configuration install tree:
#
#   cmake -S . -B build_windows_[Arch] -A [Arch] -DBUILD_SHARED_LIBS=ON ^
#   -DGLPK_INSTALL_MULTI_CONFIG=ON
#   cmake --build build_windows_[Arch] --config [Config] -j
#
# Testing
# ~~~
#
#   ctest --test-dir build_windows_[Arch] -C [Config] -j
#
# Install
# ~~~
#
#   cmake --install build_windows_[Arch] --prefix [Prefix] --config [Config]
#
# If GLPK_INSTALL_MULTI_CONFIG is specified, and assuming that we are building
# shared libraries, the install tree looks like this:
#
# install_root/
#   bin/
# Debug/
#   glpk.dll
#   glpsol.exe
# Release/
#   glpk.dll
#   glpsol.exe
#   include/
# glpk.h
#   lib/
# Debug/
#   glpk.lib
#   glpk.pdb
# Release/
#   glpk.lib
#
# Otherwise, we have a flat install with "d" suffices, e.g.
#
# install_root/
#   bin/
# glpk.dll
# glpkd.dll
# glpsol.exe
# glpsold.exe
#   include/
# glpk.h
#   lib/
# glpk.lib
# glpkd.lib
# glpkd.pdb
#

# GLPK version
set(GLPK_VERSION_MAJOR 5)
set(GLPK_VERSION_MINOR 0)
set(GLPK_VERSION ${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR})

project(
glpk
VERSION 5.0
DESCRIPTION "GNU Linear Programming Kit"
HOMEPAGE_URL "https://www.gnu.org/software/glpk/;
LANGUAGES C
)

# select static/shared library compilation
option(BUILD_SHARED_LIBS "Build GLPK library as shared" OFF)
# use static C runtime library. defaulted to OFF to match the CMake default of
# using MultiThreaded$<$:Debug>DLL to select dynamic C runtime.
# see https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html,
# https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features
option(GLPK_USE_STATIC_CRT "Link against C runtime statically" OFF)
# to separate Debug and Release libraries, which also link against debug and
# release C runtimes respectively (should never be mixed), add an extra layer
# of namespacing to lib and bin, e.g. lib/Debug, 

[Fwd: Question to GLPK installation]

2023-12-13 Thread Andrew Makhorin
 Forwarded Message 
From: Mario Linsenmeyer 
To: help-glpk@gnu.org
Subject: Question to GLPK installation
Date: Wed, 13 Dec 2023 19:54:08 +0100

Hello all,
 
I don't know whether you are still answering at this email address but I
try it.
 
I have used GLPK during my study time and I wanted to refresh some
content from this time.
Therefore I have tried to download GLPK. 
I have downloaded:
glpk-5.0.tar.gz.sig and glpk-5.0.tar.gz.
I have extracted the gz-file and it looks like it worked. There are the
relevant folders (doc, examples, etc. and a lot of files).
In read me stand the next step should be to exectute configure
 
Normally, you should just `cd' to the directory `glpk-X.Y' and run the
`configure' script, e.g.
      ./configure
 
Ih this case I am using windows but nothing what I tried worked.
It is always occuring the error: the command configure is either wrong
written or could not be found.
I am in the right folder but I do not know what to type in that it
works.
 
Can you help me in this case?
 
Thank you.
 
Best regards
Mario Linsenmeyer
 
 



[Fwd: ANTONIO Carlos Moretti ]

2023-07-24 Thread Andrew Makhorin
 Forwarded Message 

Date: Mon, 24 Jul 2023 11:55:59 -0300
Subject: 
To: help-glpk@gnu.org
From: ANTONIO Carlos Moretti 
> Hello,I want to set the parameter presolve in the glp_intopt.
> I have no idea in how to do that.
> Can you,please, help me.
> Thanks in advance
> Antonio
> 

[Fwd: GLPK]

2023-07-05 Thread Andrew Makhorin
 Forwarded Message 
From: Adolfo Roquero 
To: m...@gnu.org
Subject: GLPK
Date: Wed, 5 Jul 2023 12:44:48 +0200

> Dear Mao,
> My name is Adolfo and I have been struggling for the past 2 weeks to
> install the GLPK solver to be used with cvxpy in a docker container. I
> have spent an incredible amount of time trying and I am very desperate
> at the moment. 
> Any help, guidance or support you can provide would be extremely
> valuable and appreciate.
> 
> 
> Thank you in advance,
> Adolfo Roquero



[Fwd: Re: [Fwd: Re: [Fwd: MathProg set vs param]]]

2023-05-28 Thread Andrew Makhorin
 Forwarded Message 

Date: Sun, 28 May 2023 14:08:46 -0300
Subject: Re: [Fwd: Re: [Fwd: MathProg set vs param]]
Cc: help-glpk@gnu.org, Andrew Makhorin 
To: Jeff Kantor 
From: Code Raguet 
>  
> > The ’set’ and ‘param’ statements need to be considered from
> > theperspective of a mathematical optimization model. 
> This may be the cause of my struggling. My lack of knowledge in LP
> isn't helping to link the proper domain abstractions.
> 
> For example, I need to work with some dataset as a matrix:
> 
> 
> 
> 
>   
>   
>   
>   
>   
>   
> 
> 
> 
> 
>   
>   
>   
> 
>   p1
>   p2
>   
>   
>   A
>   100
>   20
>   
>   
>   B
>   200
>   30
>   
>   
>   
> 
>   
> 
>   
> 
>   
> I managed to encode this table as the following statements. This works
> but my rationale is that the whole table is my "parameter".
> I'd like to be able to solve the model with another dataset where the
> only things that would remain are column names (p1 and p2).
> Everything else may change.
> So, do I need the S set? why? Is it possible to do this with param  p
> only?
> I think that my parameter is just p and not p and s.
> 
> 
> set S := A B;
> param p :
>             p1   p2    :=
>         A   100  20
>         B   200  30
>         ;
> 
> Thank you very much for your help, time and kindness.
> Ignacio.
> 
> On Sun, May 28, 2023 at 10:18 AM Andrew Makhorin  wrote:
> >  Forwarded Message 
> > 
> > From: Jeff Kantor 
> > 
> > To: Andrew Makhorin 
> > 
> > Cc: help-glpk@gnu.org
> > 
> > Subject: Re: [Fwd: MathProg set vs param]
> > 
> > Date: Sat, 27 May 2023 20:00:37 -0500
> > 
> > 
> > 
> > > Hi Ignacio,
> > 
> > > 
> > 
> > > The ’set’ and ‘param’ statements need to be considered from the
> > 
> > > perspective of a mathematical optimization model. A ’set’ refers
> > to a
> > 
> > > mathematical set of objects that will index other components of
> > the
> > 
> > > model, such as parameters, constraints, and decision variables.
> > The
> > 
> > > elements of the set must be unique. They can be integers or
> > strings.
> > 
> > > Identifying appropriate sets for a particular problem is often
> > 
> > > obvious, but other times worth some thought.
> > 
> > > 
> > 
> > > Elements of a set index parameters and provide a symbolic
> > reference to
> > 
> > > the numbers needed to specify expressions appearing in your model.
> > 
> > > 
> > 
> > > Parameters and sets are very different things.
> > 
> > > 
> > 
> > > Jeff
> > 
> > > 
> > 
> > > > On May 27, 2023, at 7:17 PM, Andrew Makhorin 
> > wrote:
> > 
> > > > 
> > 
> > > >  Forwarded Message 
> > 
> > > > From: Code Raguet 
> > 
> > > > To: help-glpk@gnu.org
> > 
> > > > Subject: MathProg set vs param
> > 
> > > > Date: Sat, 27 May 2023 19:51:01 -0300
> > 
> > > > 
> > 
> > > > > Hi, there!
> > 
> > > > > I'm new to MathProg (and LP) but I have several years as a
> > 
> > > > > software
> > 
> > > > > developer.
> > 
> > > > > I would like to understand the semantic differences between
> > set
> > 
> > > > > and
> > 
> > > > > param.
> > 
> > > > > When reading the doc and looking at examples, I understand
> > that
> > 
> > > > > the
> > 
> > > > > set statement is for sets, arrays, vectors, (n-tuples) and
> > simple
> > 
> > > > > symbolic elements. On the other hand, param statement is for
> > 
> > > > > simple
> > 
> > > > > scalar values or values of a set (usually indexed).
> > 
> > > > > 
> > 
> > > > > My issues are about the semantics and rationale behind these
> > 
> > > > > statements.
> > 
> > > > > Why are two different statements for doing quite similar (in
> > my
> > 
> > > > > understanding) purpose?
> > 
> > > > > I mean, both declare data structures (and initialize in the
> > data
> > 
> > > > > section).
> > 
> > > > > Aren't sets kind of a param after all?
> > 
> > > > > 
> > 
> > > > > for ex.:
> > 
> > > > > Imagine declaring an array of simple elements:
> > 
> > > > > set S := {'A', 'B'};
> > 
> > > > > param P{i in {'A', 'B'}};
> > 
> > > > > 
> > 
> > > > > How are these statements different?
> > 
> > > > > 
> > 
> > > > > 
> > 
> > > > > Thanks in advance,
> > 
> > > > > Ignacio.
> > 
> > > 
> > 
> > > 
> > 
> > 
> 
> 

[Fwd: MathProg set vs param]

2023-05-27 Thread Andrew Makhorin
 Forwarded Message 
From: Code Raguet 
To: help-glpk@gnu.org
Subject: MathProg set vs param
Date: Sat, 27 May 2023 19:51:01 -0300

> Hi, there!
> I'm new to MathProg (and LP) but I have several years as a software
> developer.
> I would like to understand the semantic differences between set and
> param.
> When reading the doc and looking at examples, I understand that the
> set statement is for sets, arrays, vectors, (n-tuples) and simple
> symbolic elements. On the other hand, param statement is for simple
> scalar values or values of a set (usually indexed).
> 
> My issues are about the semantics and rationale behind these
> statements.
> Why are two different statements for doing quite similar (in my
> understanding) purpose?
> I mean, both declare data structures (and initialize in the data
> section).
> Aren't sets kind of a param after all?
> 
> for ex.:
> Imagine declaring an array of simple elements:
> set S := {'A', 'B'};
> param P{i in {'A', 'B'}};
> 
> How are these statements different?
> 
> 
> Thanks in advance,
> Ignacio.



Re: Glpk and R

2023-03-16 Thread Andrew Makhorin
On Wed, 2023-03-15 at 13:02 +, Ma, Lingjie wrote:
> Hi,  Mr. Mao, 
> 
> I have some quantile regression type portfolio optimization programs
> which needs to call glpk package in R. 
> 
> My question is how to call glpk with R?

please see https://en.wikibooks.org/wiki/GLPK/R



> 
> Thanks,
> 
> Lingjie Ma
> 
> 
> 



[Fwd: Integer solutions]

2023-01-18 Thread Andrew Makhorin
 Forwarded Message 

Date: Tue, 17 Jan 2023 20:33:01 -0800
Subject: Integer solutions
To: 'Help-glpk@gnu.org' 
From: neillcl...@gmail.com
> Hi,
> If I call glp_simplex without specifying that any variables be
> integers and then call glp_intop it looks like it at least makes the
> objective function an integer.
> If I specify the variable should be integers as well via
> glp_set_col_kind with GLP_IV then I found the time to solve the
> problem was much larger (well to be expected I guess).
> What is the process I should follow if I want to perform a real
> relaxation of a full integer problem and only go to integers if the
> problem is not satisfiable (mostly what I use the calls for)?
> I couldn’t really see this spelled out in the docs.
> I use the object function to find redundant constraints and I can see
> this with both real and integer objectives. Obviously doing the real
> case first would be faster. Likewise I determine feasibility of a
> system of inequalities with a zero objective and want to do this in
> both reals and then integers.
> Thanks.
> Neill.
>  

[Fwd: Using the summation operator with GLPK.]

2022-11-01 Thread Andrew Makhorin
 Forwarded Message 
Date: Mon, 31 Oct 2022 20:46:36 +Subject: Using the summation
operator with GLPK.To: help-glpk@gnu.org From:
philliprusso So from reading the documentation I
guess that GLPK can read a file in and that there are a number of
formats to be using. So I would like to start using GLPK in the C++
language for Ubuntu 18.0.45 LTS that I am using for the windows
subsystem for linux and visual studio code.
The problem I am trying to solve is using the summation operator. In
latex format it goes like this:
(For a point list P(x,y)_{n}
\sum {k=0}^{n} \alpha_{k}*x^{i}*y^{j}
The summation with the value k and permuting n times over the formula
alpha of k multiplied by x to the i power multiplied by y to the j
power.
This is the formula for a 2D problem for a finite element analysis
coming from the book Analysis of Structures and Material Behaviors for
Kindle. The number of terms is said to formulate to (n+1)(n+2)/2.
Does GLPK handle the summation operator somehow. Can I see some example
of how to implement such a problem with a GLPK file format (any format
that works is great) and or how to calculate this thing. The trouble I
have is that with the inclusion of i and j with the summation operator I
couldn't find a calculator available on the internet that can handle
such a thing and also so far I have been unable to get help from anyone
that knows how to. Thank You! Any type of help would be greatly
appreciated.







Sent with Proton Mail secure email.




Re: Is glpk available for commercial deployment

2022-10-27 Thread Andrew Makhorin
On Thu, 2022-10-27 at 06:02 +, ajit.a.mu...@shell.com wrote:
> Hi,
>  
> I am using glpk for an optimisation problem.
> I was wondering if the tool that I have developed needs to
> commercialized, can I use the glpk for the commercial purpose.

Please see
https://www.gnu.org/licenses/gpl-faq.html#GPLCommercially


>  
> Can you please point if there is any documentation available for the
> same?
>  
> Thanks,
> Ajit  



Re: Linear Program Optimal Extreme Points

2022-10-18 Thread Andrew Makhorin
The following article by Katta Murty, "A Problem in Enumerating Extreme
Points, and an efficient Algorithm.", sheds some light on the issue; see
http://www-personal.umich.edu/~murty/segments.pdf



Re: Dual negative values in optimal table

2022-10-15 Thread Andrew Makhorin
On Sat, 2022-10-15 at 23:24 -0400, Hector Arciniegas wrote:
> Greetings, I don't understand why negative dual values appear in an
> optimal simplex table. Thanks.

Because your constraints are double-bounded, in which case dual values
(= lagrangian multipliers) can have any sign.


> 
> 
> MODELO
> MIN 36.00 25.00 16.00 9.00 4.00 1.00 0.00
> 
> 89 <= 3.00 0.00 0.00 5.00 6.00 6.00 <= 89
> 124 <= 8.00 1.00 5.00 8.00 5.00 7.00 <= 124
> 
> 0.00 <=var( 1) <= 9.00
> 0.00 <=var( 2) <= 10.00
> 0.00 <=var( 3) <= 11.00
> 0.00 <=var( 4) <= 12.00
> 0.00 <=var( 5) <= 13.00
> 0.00 <=var( 6) <= 14.00
> 
> 
> 
> status=GLP_OPT
> 
> *** -2 ***
> S 1 S 2 X 1 X 2 X 3 X 4 X 5 X 6
> Z -3.32 3.20 20.36 21.80 0.00 0.00 7.92 -1.48 80.60
> X 4 0.20 -0.00 -0.60 0.00 0.00 1.00 -1.20 -1.20 1.00
> X 3 -0.32 0.20 -0.64 -0.20 1.00 0.00 0.92 0.52 3.60
> low 89 124 0 0 0 0 0 0
> up 89 124 9 10 11 12 13 14
> stat 5 5 2 2 1 1 2 3
> 
> This table was obtained with the following routine.
> 
> void printTabla(glp_prob *lp1,int lug)
> {
> int m=glp_get_num_rows(lp1);
> int n=glp_get_num_cols(lp1);
> 
> int ind[n+1];
> double val[n+1];
> // glp_prob *lp1;
> // lp1 = glp_create_prob();
> //glp_copy_prob(lp1,lp, GLP_OFF);
> printf("*** %d ***\n",lug);
> printf(" ");
> for (int i=1;i<=m;i++)printf(" S%2d",i);
> for (int j=1;j<=n;j++)printf(" X%2d",j);
> printf("\nZ ");
> for(int i=1;i<=m;i++)printf("%6.2f",glp_get_row_dual(lp1,i));
> for(int j=1;j<=n;j++)printf("%6.2f",glp_get_col_dual(lp1,j));
> printf("%7.2f\n",glp_get_obj_val(lp1));
> 
> for(int i=1;i<=m;i++)
> {
> int ib=glp_get_bhead(lp1,i);
> if(ib>m)printf("X%2d ",ib-m);else printf("S%2d ",ib);
> int len=glp_eval_tab_row(lp1,ib,ind,val);
> double temp[n+m+1];for(int j=1;j<=n;j++)temp[j]=0;
> for(int j=1;j<=len;j++)temp[ind[j]]=val[j];temp[ib]=1;
> for(int j=1;j<=n+m;j++)printf("%6.2f",temp[j]);
> if(ib>m)printf("%7.2f\n",glp_get_col_prim(lp1,ib-m));
> else printf("%7.2f\n",glp_get_row_prim(lp1,ib));
> }
> for(int i=1;i<=m;i++)
> {
> if(glp_get_row_stat(lp1,i)!=GLP_BS)continue;
> printf("S%2d ",i);
> int len=glp_eval_tab_row(lp1,i,ind,val);
> double temp[n+n+1];
> for(int j=1;j<=n+n;j++)temp[j]=0.0;
> for(int j=1;j<=len;j++)temp[ind[j]]=val[j];
> for(int j=1;j<=n+n;j++)printf("%6.2f",temp[j]);
> printf("%7.2f\n",glp_get_row_prim(lp1,i));
> }
> printf("low ");
> for(int i=1;i<=m;i++)printf("%6.0f",glp_get_row_lb(lp1,i));
> for(int j=1;j<=n;j++)printf("%6.0f",glp_get_col_lb(lp1,j));
> printf("\nup ");
> for(int i=1;i<=m;i++)printf("%6.0f",glp_get_row_ub(lp1,i));
> for(int j=1;j<=n;j++)printf("%6.0f",glp_get_col_ub(lp1,j));
> printf("\nstat");
> for(int i=1;i<=m;i++)printf("%6d",glp_get_row_stat(lp1,i));
> for(int j=1;j<=n;j++)printf("%6d",glp_get_col_stat(lp1,j));
> printf("\n");
> }



[Fwd: Linear Program Optimal Extreme Points]

2022-10-06 Thread Andrew Makhorin
 Forwarded Message 
From: Prabhu Manyem 
To: fuk...@math.ethz.ch, Andrew Makhorin , avis@cs.mcgill.c
a
Subject: Linear Program Optimal Extreme Points
Date: Thu, 6 Oct 2022 10:04:22 +1030

Dear Andrew, Komei, David,

I am a retired Maths professor in Adelaide, Australia.

About the problem of enumerating all OEP (optimal extreme points) for
a Linear Program, I tried the following approach, using GLPK
software.. Is this a good way to handle degeneracy?  Please let me
know.

For my instances, I have explicitly added lower bound constraints of the
form
"x_i >= 0"  for each variable x_i..

(1) Solve the original Linear Program (call this LP0).. This returned
an optimal solution value of 50 (for my example).
The objective function is  "Max. Z = CX"... So  Z_{max} = 50.

(2) Now add the constraint  "CX = 50" to the original LP.. This gives
us a new LP, which we can call LP1... Solve  LP1.. With GLPK, I was
able to save the last BFS (basic feasible solution) of LP1 to a file,
say Soln-1.bas (using the  "-w Soln-1.bas"  option).
Soln-1.bas  is the first OEP (optimal extreme point).

(3) In Soln-1.bas, find the lexicographically first Non-Basic
variable.. For example, let us say that this is x5... Since I want to
avoid degeneracy and go to a new OEP,  I modify the Lower Bound for
x5... I modify  "x5 >= 0"  to  "x5 >= epsilon"  where epsilon is a
very small positive number.. Call this LP2.

(4) Now run LP2 using GLPK, using the previous basis Soln-1.bas as the
starting solution.. In GLPK, you can do this using the "--ini
Soln-1.bas" option in the terminal command line... The LP2 output
should be written to "Soln-2.bas".

(5) If Step 4 is a failure, that is, LP2 is infeasible, then check
Soln-1.bas, and find the NON-BASIC variable lexicographically next to
x5, for example, x8... Then the lower bound "x5 >= epsilon" should be
reset to zero ("x5 >= 0),  and the lower bound for x8 should be set to
epsilon (x8 >= epsilon)... Now run this new LP, again using the
"--ini Soln-1.bas"  option in GLPK.

On the other hand, if Step 4 is a success (that is, LP2 is feasible),
then Soln-2 is the second OEP.
Then we do something similar to Step 3... Open Soln-2.bas, find the
lexicographically smallest Non-basic variable, for example, x9, reset
the lower bound of x5 to zero (x5 >= 0), change the lower bound of x9
to epsilon (x9 >= epsilon), and the solve the new LP (call it LP3) in
GLPK using the  "--ini Soln-2.bas"  option.

We traverse the OEP's in a tree-like fashion..

I assume that the above approach  (setting a Non-basic variable to >=
epsilon and solving a new LP, using the last BFS of the previous LP as
a starting point for the new LP)  is NOT a new idea... But I would
like to know if this has been implemented.

Look forward to your comments and suggestions.. Thank you.. (And
thanks to Andrew for GLPK).

-Prabhu

Dr Prabhu Manyem
Retired Professor of Applied Mathematics
Nanchang Institute of Technology
Currently in Adelaide, Australia




[Fwd: Inquiry about using GNU MathProg]

2022-10-02 Thread Andrew Makhorin
 Forwarded Message 

Date: Sun, 2 Oct 2022 19:14:51 + (UTC)
Subject: Inquiry about using GNU MathProg
Cc: basma Mamdouh 
To: help-glpk@gnu.org 
From: basma mohamed 
Dear GLPK developers and helpers,


After greeting,


I recently started to use lp_solve for optimizing the protocols of
wireless networks using GNU MathProg “.mod” files.


I have a question about how I can use these tools to define a set or a
parameter
contains the paths originated from each source "S" whether it is a
complete path to destination "D" or not, with the ability to reach each
element: each path, each link, each vertex .


for example:


The set value would be the paths of S1, S2, and S3 in the form of 2-
tuples representing
links constituting the path, such that:


 { 
{ (S1,4) }, { (S1,S3), (S3, S2), (S2,5) }, { (S1,3), (3,1), (1,2), (2,D)
} , { (S2,5) }, { (S2,S3), (S3, S1), (S1,4) }, { (S2,S3), (S3, S1),
(S1,3), (3,1),
(1,2), (2,D) }, { (S3,S2), (S2,5)}, { (S3,S1), (S1,4) }, { (S3,S1),
(S1,3), (3,1),
(1,2), (2,D) }, { (S4,6) }  } 


I put all the graph edges in this set:


set Edges{i in Nodes , j in Nodes: sqrt( abs(xCoord[i] - xCoord[j]) *
abs(xCoord[i]
- xCoord[j]) + abs(yCoord[i] - yCoord[j]) * abs(yCoord[i] - yCoord[j])
), <=
range, != 0 };


Where Nodes is the union of all sets representing the graph vertices
IDs,
and   xCoord and yCoord are the sets contain their coordinates.


Could you help me achieve this; In general, i would appreciate it if you
mention examples and tutorials for using GNU MathProg in Networks
optimization .   


Thank you in advance ,


Respectfully 



[Fwd: For help]

2022-08-12 Thread Andrew Makhorin
 Forwarded Message 

Date: Fri, 12 Aug 2022 11:18:40 +0800
Subject: For help
To: help-glpk@gnu.org 
From: travelor <1085886...@qq.com>
> Hello, I'm having some trouble, could you tell me some parameter
> for GLPK to optimizing many Linear problem?
> I understarded many usage, such as ‘mipgap’and’ tmlim’. I want to know
> If there are any other parameters to optimizing problem?
> Regardless of the outcome, thank you very much. Looking forward to you
> reply.
>  

[Fwd: MIP solution/optimisation process information]

2022-07-14 Thread Andrew Makhorin
 Forwarded Message 
From: Pedro Magalhães 
To: help-glpk@gnu.org
Subject: MIP solution/optimisation process information
Date: Thu, 14 Jul 2022 10:32:31 +0200

> Hello,
> 
> I've recently realised that GLPK/GLPSOL only writes a limited amount
> of 
> information to solution files, namely those for MIP problems.
> 
> For example, they do not provide information about the best bound
> (best 
> relaxed solution), the MIP gap, the time used, the termination 
> condition, etc. This is relevant information for a variety of
> purposes.
> 
> Some of this can be obtained in the command line but not in the
> solution 
> file.
> 
> Is there a simple way to get this information on demand?
> 
> Regards,
> 
> Pedro
> 
> 
> 



Re: Maximum independent set computation

2022-07-05 Thread Andrew Makhorin
Hi Prabhu,

Thank you for your interest in glpk and the link to your article.

I think you may be interested in challenge MIS problems, some of which
were used on testing glpk; see https://oeis.org/A265032/a265032.html .


Best regards,

Andrew Makhorin



On Tue, 2022-07-05 at 10:38 +0930, Prabhu Manyem wrote:
> I think you will find this interesting..  GLPK has been very useful,
> very helpful with this research.. Thank you!
> 
> https://arxiv.org/abs/2206.12531  (older version)
> 
> (newer version)
> https://www.researchgate.net/publication/361555319_Maximum_independent
> _set_stable_set_problem_A_mathematical_programming_model_with_valid_in
> equalities_and_computational_testing/stats
> 
> Abstract:
> This paper deals with the maximum independent set (M.I.S.) problem,
> also known as the stable set problem.  The basic mathematical
> programming model that captures this problem is an Integer Program
> (I.P.) with zero-one variables and only the edge inequalities.  We
> present an enhanced model by adding a polynomial number of linear
> constraints, known as valid inequalities; this new model is still
> polynomial in the number of vertices in the graph.  We carried out
> computational testing of the Linear Relaxation of the new Integer
> Program.  We tested about 5000 instances of randomly generated (and
> connected) graphs with up to 45 vertices. In each of these instances,
> the Linear Relaxation returned an optimal solution with (i) every
> variable having an integer value, and (ii) the optimal solution value
> of the Linear Relaxation was the same as that of the original (basic)
> Integer Program.  More testing is required before we can draw
> conclusions about the “likelihood” of the solvability of M.I.S. in
> polynomial time.
> 
> Best,
> 
> -pm
> 



Re: GLPK library for Dev-C++

2022-07-04 Thread Andrew Makhorin
Hi Christian,

Thank you for your interest in glpk.


On Thu, 2022-06-30 at 11:54 +0200, Christian Prins wrote:
> Dear Andrei,
> 
> I am a professor of operations research and industrial engineering at 
> the University of Technology of Troyes, France.
> 
> I love GLPK and use it for instance an LP solver in Julia. But I
> would 
> like to use it with the refactored version of Dev-C++, supervised by 
> Embarcadero the publisher of Delphi. I use this new Dev-C++ for a
> C/C++ 
> course because the IDE is much smaller than Visual Studio Code and it
> is 
> based on TDM-GCC, the Windows version of the Linux compiler GCC. Using
> a 
> maximum optimization, I found that TDM-GCC is 20% faster than Visual 
> C/C++ of Microsoft.
> https://www.embarcadero.com/free-tools/dev-cpp?aldSet=en-GB
> 
> As usual in C/C++, the problem is the makefile which can be found for 
> Windows, but only for Visual C/C++. Please do you have by chance a 
> Dev-C++ version of the GLPK library?

Currently no makefile for Dev-C/C++ is provided in the official glpk
distribution.  However, it is quite easy to compile glpk with any modern
C compiler.  To do that you need to provide access to all headers in
subdirectory glpk/src and in all its subdirectories, compile all source
files in those directories, and then run the librarian to build the
object library.  You may find the complete list of include directories
and source files needed to build the library in glpk-5.0/setup.job (it
is a plain text file).


Best regards,

Andrew Makhorin


> 
> Another way to solve the problem wuld be to make a "header only 
> library", by putting all the code in a ".h" file. This is what the 
> designers of the BOOST graph library have chosen.
> I had a look to the code of GLP but the task is not so easy : there
> are 
> many files that cannot be simply concatenated in a single larger file.
> 
> I thank you also if you have any advice or recommendations for this
> problem.
> 
> All the best,
> 
> Christian PRINS
> Professor of Operations Research
> Troyes University of Technology
> France
> 



Re: 'module' object has no attribute 'LPX'

2022-07-04 Thread Andrew Makhorin
On Mon, 2022-07-04 at 08:23 +, Alireza Asadi wrote:
> Hi Andrew,
>  
> Any update on this? Many thanks.
>  
> Alireza


Thank you for your interest in glpk.

LPX is a typedef name of the main glpk structure representing LP/MIP
problem object used in *very old* glpk versions. 

In principle, you can use the corresponding old glpk API routines by
including some additional files provided for backward compatibility;
for details please see glpk/examples/oldapi .

Please note that the python binding you are using is not part of the
official glpk distribution, and I think it is not maintained anymore for
a long time.

Try to look at https://en.wikibooks.org/wiki/GLPK/Python ; this may
help.



Best regards,

Andrew Makhorin


>  
> From: Alireza Asadi 
> Sent: Thursday, June 30, 2022 7:52 PM
> To: Andrew Makhorin 
> Cc: help-glpk@gnu.org
> Subject: Re: 'module' object has no attribute 'LPX'
>  
> Hi Andrew,
>  
> Thanks for the reply. I just tried to test glpk as in screenshot but
> it crashed right at the beginning when creating an empty model as
> follows:
> Note: attached is a python file and I changed the extension to txt to
> be able to send via email.
>  
> 
>  
> Best regards,
> Alireza
>  
> -Original Message-
> From: Andrew Makhorin  
> Sent: Thursday, June 30, 2022 6:48 PM
> To: Alireza Asadi 
> Cc: help-glpk@gnu.org
> Subject: [EXTERNAL] Re: 'module' object has no attribute 'LPX'
>  
> Caution! This email originated outside of FedEx. Please do not open
> attachments or click links from an unknown or suspicious origin.
>  
> On Thu, 2022-06-30 at 12:14 +, Alireza Asadi wrote:
> > Hi all,
> >  
> > Any idea how to solve this problem? I googled a lot but no luck ☹
>  
>  
> Please provide more detailed information.  Thanks.
>  
>  
> >  
> >  
> > Kind regards,
> >
> > Alireza Asadi
> >  
> >  



[Fwd: GLPK library for Dev-C++]

2022-06-30 Thread Andrew Makhorin
 Forwarded Message 
From: Christian Prins 
To: m...@gnu.org
Subject: GLPK library for Dev-C++
Date: Thu, 30 Jun 2022 11:54:03 +0200

> Dear Andrei,
> 
> I am a professor of operations research and industrial engineering at 
> the University of Technology of Troyes, France.
> 
> I love GLPK and use it for instance an LP solver in Julia. But I
> would 
> like to use it with the refactored version of Dev-C++, supervised by 
> Embarcadero the publisher of Delphi. I use this new Dev-C++ for a
> C/C++ 
> course because the IDE is much smaller than Visual Studio Code and it
> is 
> based on TDM-GCC, the Windows version of the Linux compiler GCC. Using
> a 
> maximum optimization, I found that TDM-GCC is 20% faster than Visual 
> C/C++ of Microsoft.
> https://www.embarcadero.com/free-tools/dev-cpp?aldSet=en-GB
> 
> As usual in C/C++, the problem is the makefile which can be found for 
> Windows, but only for Visual C/C++. Please do you have by chance a 
> Dev-C++ version of the GLPK library?
> 
> Another way to solve the problem wuld be to make a "header only 
> library", by putting all the code in a ".h" file. This is what the 
> designers of the BOOST graph library have chosen.
> I had a look to the code of GLP but the task is not so easy : there
> are 
> many files that cannot be simply concatenated in a single larger file.
> 
> I thank you also if you have any advice or recommendations for this
> problem.
> 
> All the best,
> 
> Christian PRINS
> Professor of Operations Research
> Troyes University of Technology
> France
> 



Re: 'module' object has no attribute 'LPX'

2022-06-30 Thread Andrew Makhorin
On Thu, 2022-06-30 at 12:14 +, Alireza Asadi wrote:
> Hi all,
>  
> Any idea how to solve this problem? I googled a lot but no luck ☹


Please provide more detailed information.  Thanks.


>  
>  
> Kind regards,
> 
> Alireza Asadi
>  
>  



[Fwd: GLPK Linear Programming solver]

2022-06-28 Thread Andrew Makhorin
 Forwarded Message 
From: Prabhu Manyem 
To: Andrew Makhorin , Neill Clift 
Subject: GLPK Linear Programming solver
Date: Tue, 28 Jun 2022 14:39:01 +0930

> Hello,
> 
> About the GLPK Linear Programming solver 5.0, running Linear
> Programming models:
> 
> For some instances, when I run the solver from inside a C program,
> using the statement
>   glp_simplex(mis1, NULL),
> I get a solution which is fully Integer... For every variable, I
> obtain an integer value.
> 
> However, when I run the same model in Linux command line, using the
> command
> glpsol --nomip --simplex --lp Max_Clique_model.lp
> I get an optimal solution with the SAME objective function value, but
> now, some variables are NOT integers... I get a fractional solution.
> 
> Why the difference between the 2 methods?
> How to fix this problem for the command line execution of GLPK?
> 
> Thank you very much for your help.
> 
> Dr Prabhu Manyem
> Retired Professor of Applied Mathematics
> Nanchang Institute of Technology
> 



Re: Removing Redundant Constraints in LP

2022-06-14 Thread Andrew Makhorin
On Tue, 2022-06-14 at 09:58 +0930, Prabhu Manyem wrote:
> Hello,
> 
> I am a retired professor in optimisation.
> 
> I would like to contribute my software to the GLPK project... This is
> for removing redundant constraints in LP and obtaining a new LP where
> redundancy is much less.. I have placed all files in a directory of my
> Google drive:
> 
> https://drive.google.com/drive/folders/14dBPUaA0DuFYA0gfhz0_45AmCssXpb
> ur?usp=sharing
> 
> I have written as much details as possible in the file READ_ME.txt.
> 
> Hope this can be packaged into GLPK.. Please let me know how to
> proceed further.. Thank you.

Thank you for your interest in glpk.

Removing redundant constraints as well as many other transformations are
implemented in the LP/MIP preprocessor included in the glpk package.  If
you are interested in details you may read comments to the corresponding
routines (see glpk/src/npp/*.c).


Best regards,

Andrew Makhorin


> 
> Dr Prabhu Manyem,
> Retired Professor of Applied Mathematics,
> Adelaide Australia
> 



[Fwd: GUSEK exercise review support request]

2022-06-04 Thread Andrew Makhorin
 Forwarded Message 

Date: Fri, 3 Jun 2022 16:46:42 -0500
Subject: GUSEK exercise review support request
To: m...@gnu.org
From: Román Leonardo Rodriguez Florián 
> Kind regards Andrew,
> 
> I hope you are very well, I would like to ask for your support, if you
> can help me by reviewing the GUSEK exercise that I am sending you
> attached, I think I am indexing wrong.
> 
> Reading model section from A_mixture_problem(ALGEBRAICO).mod...
> A_mixture_problem(ALGEBRAIC).mod:23: syntax error in literal set
> Context: i ] ; subject to REQ_MIN_SEM { i in seeds } : sum { i in
> MathProg model processing error
> 
> 
> I remain attentive to your concerns and comments,
> 
> LEONARDO RODRIGUEZ FLORIAN
> rleonardorodrig...@gmail.com
> Phone: 2656737
> Cell: 3505137069
> WhatsApp: 3054422705
> Skype: leonardorodriguez
> 
> 

Un_problema_de_mezclas(ALGEBRAICO).mod
Description: MPEG movie


Re: GLPK Dualprices

2022-05-29 Thread Andrew Makhorin
On Sun, 2022-05-29 at 18:42 +0200, Harald Mumm wrote:
> Hi Andrew,
> 
> thank you very much for your help, but I could solve my problem in
> the 
> meantime alone.
> 
> Instead of glp_simplex I use now glp_exact and all dual prices are
> the 
> same as in CPLEX
> 
> for all my examples.

You shouldn't expect this even on using the same package on the same
platform. The solver may report different optimal solutions depending,
say, on the order of variables and constraints in your LP. All optimal
solutions are considered equivalent, so the only what matters is that
the solution found is optimal.


> 
> Best regards
> 
> Harald
> 
> Am 29.05.2022 um 18:36 schrieb Andrew Makhorin:
> > Hi Harald,
> > 
> > 
> > On Sun, 2022-05-29 at 08:39 +0200, Harald Mumm wrote:
> > > Hallo Andrew,
> > > 
> > > is it possible, that GLPK sometimes calculates wrong dual prices?
> > > 
> > > I send you an example  in the attachment,  where CPLEX calculates
> > > 
> > > other dual prices than GLPK.
> > 
> > Please note that LP may have multiple optimal solutions (in
> > degenerate
> > cases). This means that some constraint which happen to be active at
> > one
> > optimum point may be inactive at other optimum point.
> > 
> > I solved your LP with glpsol:
> > 
> > 
> > GLPSOL--GLPK LP/MIP Solver 5.0
> > Parameter(s) specified in the command line:
> >   --lp masterg.lp
> > Reading problem data from 'masterg.lp'...
> > 46 rows, 17 columns, 62 non-zeros
> > 77 lines were read
> > GLPK Simplex Optimizer 5.0
> > 46 rows, 17 columns, 62 non-zeros
> > Preprocessing...
> > ~ 0: obj =   3.52776e+03  infeas =  0.000e+00
> > OPTIMAL SOLUTION FOUND BY LP PREPROCESSOR
> > Time used:   0.0 secs
> > Memory used: 0.0 Mb (45669 bytes)
> > 
> > 
> > Since the optimal objective value is the same as for cplex, there is
> > no
> > error. You also may see this from KKT optimality conditions:
> > 
> > 
> > Karush-Kuhn-Tucker optimality conditions:
> > 
> > KKT.PE: max.abs.err = 0.00e+00 on row 0
> >  max.rel.err = 0.00e+00 on row 0
> >  High quality
> > 
> > KKT.PB: max.abs.err = 0.00e+00 on row 0
> >  max.rel.err = 0.00e+00 on row 0
> >  High quality
> > 
> > KKT.DE: max.abs.err = 0.00e+00 on column 0
> >  max.rel.err = 0.00e+00 on column 0
> >  High quality
> > 
> > KKT.DB: max.abs.err = 0.00e+00 on row 0
> >  max.rel.err = 0.00e+00 on row 0
> >  High quality
> > 
> > 
> > Best,
> > 
> > Andrew Makhorin
> > 
> > 
> > > Sincerely yours
> > > 
> > > Harald, University of Applied Sciences, Wismar  Germany
> > > 
> > > 
> > > PS CPLEX Dualprices:
> > > 
> > > Dual simplex - Optimal:  Objective =  3.527760e+03
> > > Solution time =    0.02 sec.  Iterations = 0 (0)
> > > Deterministic time = 0.02 ticks  (1.47 ticks/sec)
> > > 
> > > CPLEX> display solution dual *
> > > Constraint Name Dual Price
> > > c1  141.55
> > > c2  330.53
> > > c3  318.28
> > > c5  201.94
> > > c7  237.01
> > > c8  283.71
> > > c9  143.44
> > > c10 221.82
> > > c11 130.99
> > > c12 210.35
> > > c13 205.53
> > > c14 175.15
> > > c15 231.34
> > > c17 155.25
> > > c21 192.06
> > > c25 204.17
> > > c41 144.64
> > > All other dual prices matching '*' are 0.
> > > 
> > > PS GLPK Dualprices
> > > 
> > > c1 = 0.0
> > > c2 = 0.0
> > > c3 = 0.0
> > > c4 = 0.0
> > > c5 = 0.0
> > > c6 = 0.0
> > > c7 = 0.0
> > > c8 = 0.0
> > > c9 = 0.0
> > > c10 = 0.0
> > > c11 = 0.0
> > > c12 = 0.0
> > > c13 = 0.0
> > > c14 = 0.0
> > > c15 = 0.0
> > > c16 = 0.0
> > > c17 = 0.0
> > > c18 = 0.0
> > > c19 = 0.0
> > > c20 = 0.0
> > > c21 = 0.0
> > > c22 = 0.0
> > > c23 = 0.0
> > > c24 = 0.0
> > > c25 = 0.0
> > > c26 = 0.0
> > > c27 = 0.0
> > > c28 = 0.0
> > > c29 = 0.0
> > > c30 = 0.0
> > > c31 = 0.0
> > > c32 = 0.0
> > > c33 = 0.0
> > > c34 = 0.0
> > > c35 = 0.0
> > > c36 = 0.0
> > > c37 = 0.0
> > > c38 = 0.0
> > > c39 = 0.0
> > > c40 = 0.0
> > > c41 = 0.0
> > > c42 = 0.0
> > > c43 = 0.0
> > > c44 = 0.0
> > > c45 = 0.0
> > > c46 = 330.53
> > > 
> 
> 



[Fwd: Re: GLPK Dualprices]

2022-05-29 Thread Andrew Makhorin
 Forwarded Message 
From: Andrew Makhorin 
To: Harald Mumm 
Subject: Re: GLPK Dualprices
Date: Sun, 29 May 2022 19:36:20 +0300

> Hi Harald,
> 
> 
> On Sun, 2022-05-29 at 08:39 +0200, Harald Mumm wrote:
> > Hallo Andrew,
> > 
> > is it possible, that GLPK sometimes calculates wrong dual prices?
> > 
> > I send you an example  in the attachment,  where CPLEX calculates
> > 
> > other dual prices than GLPK.
> 
> Please note that LP may have multiple optimal solutions (in degenerate
> cases). This means that some constraint which happen to be active at
> one
> optimum point may be inactive at other optimum point.
> 
> I solved your LP with glpsol:
> 
> 
> GLPSOL--GLPK LP/MIP Solver 5.0
> Parameter(s) specified in the command line:
>  --lp masterg.lp
> Reading problem data from 'masterg.lp'...
> 46 rows, 17 columns, 62 non-zeros
> 77 lines were read
> GLPK Simplex Optimizer 5.0
> 46 rows, 17 columns, 62 non-zeros
> Preprocessing...
> ~ 0: obj =   3.52776e+03  infeas =  0.000e+00
> OPTIMAL SOLUTION FOUND BY LP PREPROCESSOR
> Time used:   0.0 secs
> Memory used: 0.0 Mb (45669 bytes)
> 
> 
> Since the optimal objective value is the same as for cplex, there is
> no
> error. You also may see this from KKT optimality conditions:
> 
> 
> Karush-Kuhn-Tucker optimality conditions:
> 
> KKT.PE: max.abs.err = 0.00e+00 on row 0
> max.rel.err = 0.00e+00 on row 0
> High quality
> 
> KKT.PB: max.abs.err = 0.00e+00 on row 0
> max.rel.err = 0.00e+00 on row 0
> High quality
> 
> KKT.DE: max.abs.err = 0.00e+00 on column 0
> max.rel.err = 0.00e+00 on column 0
> High quality
> 
> KKT.DB: max.abs.err = 0.00e+00 on row 0
> max.rel.err = 0.00e+00 on row 0
> High quality
> 
> 
> Best,
> 
> Andrew Makhorin
> 
> 
> > 
> > Sincerely yours
> > 
> > Harald, University of Applied Sciences, Wismar  Germany
> > 
> > 
> > PS CPLEX Dualprices:
> > 
> > Dual simplex - Optimal:  Objective =  3.527760e+03
> > Solution time =    0.02 sec.  Iterations = 0 (0)
> > Deterministic time = 0.02 ticks  (1.47 ticks/sec)
> > 
> > CPLEX> display solution dual *
> > Constraint Name Dual Price
> > c1  141.55
> > c2  330.53
> > c3  318.28
> > c5  201.94
> > c7  237.01
> > c8  283.71
> > c9  143.44
> > c10 221.82
> > c11 130.99
> > c12 210.35
> > c13 205.53
> > c14 175.15
> > c15 231.34
> > c17 155.25
> > c21 192.06
> > c25 204.17
> > c41 144.64
> > All other dual prices matching '*' are 0.
> > 
> > PS GLPK Dualprices
> > 
> > c1 = 0.0
> > c2 = 0.0
> > c3 = 0.0
> > c4 = 0.0
> > c5 = 0.0
> > c6 = 0.0
> > c7 = 0.0
> > c8 = 0.0
> > c9 = 0.0
> > c10 = 0.0
> > c11 = 0.0
> > c12 = 0.0
> > c13 = 0.0
> > c14 = 0.0
> > c15 = 0.0
> > c16 = 0.0
> > c17 = 0.0
> > c18 = 0.0
> > c19 = 0.0
> > c20 = 0.0
> > c21 = 0.0
> > c22 = 0.0
> > c23 = 0.0
> > c24 = 0.0
> > c25 = 0.0
> > c26 = 0.0
> > c27 = 0.0
> > c28 = 0.0
> > c29 = 0.0
> > c30 = 0.0
> > c31 = 0.0
> > c32 = 0.0
> > c33 = 0.0
> > c34 = 0.0
> > c35 = 0.0
> > c36 = 0.0
> > c37 = 0.0
> > c38 = 0.0
> > c39 = 0.0
> > c40 = 0.0
> > c41 = 0.0
> > c42 = 0.0
> > c43 = 0.0
> > c44 = 0.0
> > c45 = 0.0
> > c46 = 330.53



[Fwd: GLPK Dualprices]

2022-05-29 Thread Andrew Makhorin
 Forwarded Message 
From: Harald Mumm 
To: m...@gnu.org
Subject: GLPK Dualprices
Date: Sun, 29 May 2022 08:39:28 +0200

> Hallo Andrew,
> 
> is it possible, that GLPK sometimes calculates wrong dual prices?
> 
> I send you an example  in the attachment,  where CPLEX calculates
> 
> other dual prices than GLPK.
> 
> Sincerely yours
> 
> Harald, University of Applied Sciences, Wismar  Germany
> 
> 
> PS CPLEX Dualprices:
> 
> Dual simplex - Optimal:  Objective =  3.527760e+03
> Solution time =    0.02 sec.  Iterations = 0 (0)
> Deterministic time = 0.02 ticks  (1.47 ticks/sec)
> 
> CPLEX> display solution dual *
> Constraint Name Dual Price
> c1  141.55
> c2  330.53
> c3  318.28
> c5  201.94
> c7  237.01
> c8  283.71
> c9  143.44
> c10 221.82
> c11 130.99
> c12 210.35
> c13 205.53
> c14 175.15
> c15 231.34
> c17 155.25
> c21 192.06
> c25 204.17
> c41 144.64
> All other dual prices matching '*' are 0.
> 
> PS GLPK Dualprices
> 
> c1 = 0.0
> c2 = 0.0
> c3 = 0.0
> c4 = 0.0
> c5 = 0.0
> c6 = 0.0
> c7 = 0.0
> c8 = 0.0
> c9 = 0.0
> c10 = 0.0
> c11 = 0.0
> c12 = 0.0
> c13 = 0.0
> c14 = 0.0
> c15 = 0.0
> c16 = 0.0
> c17 = 0.0
> c18 = 0.0
> c19 = 0.0
> c20 = 0.0
> c21 = 0.0
> c22 = 0.0
> c23 = 0.0
> c24 = 0.0
> c25 = 0.0
> c26 = 0.0
> c27 = 0.0
> c28 = 0.0
> c29 = 0.0
> c30 = 0.0
> c31 = 0.0
> c32 = 0.0
> c33 = 0.0
> c34 = 0.0
> c35 = 0.0
> c36 = 0.0
> c37 = 0.0
> c38 = 0.0
> c39 = 0.0
> c40 = 0.0
> c41 = 0.0
> c42 = 0.0
> c43 = 0.0
> c44 = 0.0
> c45 = 0.0
> c46 = 330.53
> \* Problem: myProblem *\

Minimize
 obj: + 141.55 x1 + 330.53 x2 + 283.71 x3 + 130.99 x4 + 143.44 x5
 + 144.64 x6 + 205.53 x7 + 237.01 x8 + 221.82 x9 + 210.35 x10
 + 204.17 x11 + 231.34 x12 + 192.06 x13 + 155.25 x14 + 201.94 x15
 + 175.15 x16 + 318.28 x17

Subject To
 c1: + x1 = 1
 c2: + x2 = 1
 c3: + x17 = 1
 c4: + x17 = 1
 c5: + x15 = 1
 c6: + x17 = 1
 c7: + x8 = 1
 c8: + x3 = 1
 c9: + x5 = 1
 c10: + x9 = 1
 c11: + x4 = 1
 c12: + x10 = 1
 c13: + x7 = 1
 c14: + x16 = 1
 c15: + x12 = 1
 c16: + x2 = 1
 c17: + x14 = 1
 c18: + x12 = 1
 c19: + x15 = 1
 c20: + x10 = 1
 c21: + x13 = 1
 c22: + x8 = 1
 c23: + x7 = 1
 c24: + x1 = 1
 c25: + x11 = 1
 c26: + x9 = 1
 c27: + x8 = 1
 c28: + x14 = 1
 c29: + x3 = 1
 c30: + x16 = 1
 c31: + x14 = 1
 c32: + x2 = 1
 c33: + x5 = 1
 c34: + x9 = 1
 c35: + x16 = 1
 c36: + x11 = 1
 c37: + x10 = 1
 c38: + x2 = 1
 c39: + x1 = 1
 c40: + x12 = 1
 c41: + x6 = 1
 c42: + x6 = 1
 c43: + x13 = 1
 c44: + x4 = 1
 c45: + x7 = 1
 c46: + x17 + x16 + x15 + x14 + x13 + x12 + x11 + x10 + x9 + x8 + x7
 + x6 + x5 + x4 + x3 + x2 + x1 = 17

Bounds
 0 <= x1 <= 1
 0 <= x2 <= 1
 0 <= x3 <= 1
 0 <= x4 <= 1
 0 <= x5 <= 1
 0 <= x6 <= 1
 0 <= x7 <= 1
 0 <= x8 <= 1
 0 <= x9 <= 1
 0 <= x10 <= 1
 0 <= x11 <= 1
 0 <= x12 <= 1
 0 <= x13 <= 1
 0 <= x14 <= 1
 0 <= x15 <= 1
 0 <= x16 <= 1
 0 <= x17 <= 1

End


Re: GLPK memory problem

2022-05-04 Thread Andrew Makhorin
On Tue, 2022-05-03 at 13:29 +0200, Domingo Alvarez Duarte wrote:
> Maybe there is a mistake on the previous reply, GLPK is 32/64 bits 
> depending on the compilation/platform/OS on 64 bits operating systems
> it 
> can allocated more than 4GB of memory.


I meant that for indexing arrays glpk routines use variables of type 
int; since int is a 32-bit quantity even in the LP64 programming model,
it is impossible to work with arrays having more than 2^32 elements.
Sorry for misunderstanding.


> 
> Can you use gdb to see how much memory was attempted to allocate ?
> 
> 
> On 3/5/22 13:11, Andrew Makhorin wrote:
> > On Tue, 2022-05-03 at 06:38 +, Georgios Avgerinopoulos wrote:
> > > Hey Community!
> > >   
> > > Just ran into the following problem
> > >   
> > > 
> > >   
> > > glp_alloc: no memory available
> > > Error detected in file ..\src\env\alloc.c at line 91
> > >   
> > > We've got plenty of memory (both RAM and hard drive).
> > >   
> > > Any tips?
> > 
> > GLPK is a 32-bit software, so the addressing memory is limited to 4
> > Gb.
> > 
> > 
> > >   
> > > Best,
> > > Georgios
> > >   
> > > +=+
> > > This email is confidential and may be privileged. If you have
> > > received
> > > it in error, please notify us immediately, delete the email, and
> > > do
> > > not
> > > copy it, disclose its contents or use it for any purpose.
> > > +=+
> 
> 



Re: GLPK memory problem

2022-05-03 Thread Andrew Makhorin
On Tue, 2022-05-03 at 06:38 +, Georgios Avgerinopoulos wrote:
> Hey Community!
>  
> Just ran into the following problem
>  
> 
>  
> glp_alloc: no memory available
> Error detected in file ..\src\env\alloc.c at line 91
>  
> We've got plenty of memory (both RAM and hard drive).
>  
> Any tips?

GLPK is a 32-bit software, so the addressing memory is limited to 4 Gb.


>  
> Best,
> Georgios
>  
> +=+
> This email is confidential and may be privileged. If you have
> received 
> it in error, please notify us immediately, delete the email, and do
> not 
> copy it, disclose its contents or use it for any purpose.
> +=+



[Fwd: Discussion on GLPK]

2022-04-19 Thread Andrew Makhorin
 Forwarded Message 
Date: Tue, 19 Apr 2022 10:00:54 +0800Subject: Discussion on GLPKTo: help
-glpk@gnu.orgFrom: jimingyue <20s103...@stu.hit.edu.cn>Dear developer,
Hope you are well!
Recently, I use GLPK to solve a LP problem in my graduation project. My
coefficient matrix is very large so that there is a bug
“glp_load_matrix: ne=1889848940; too many constraint coefficients”. I
google this hint and find GLPK requires the size of coefficient matrix
is less than 5.  So I have two questions as follows,
1. Why the size is required less than 5?
2. If I cannot limit the size within 5, is there some way to
solve my LP problem using GLPK? If the answer is yes, do I need to
modify any code? ? If the answer is no, could you give me some advices
to solve my problem?
Looking forward to your reply!
Really appreciate your help!
Best regards,
Mingyue Ji


[Fwd: identifying infeasible problem without using the LP presolver]

2022-03-21 Thread Andrew Makhorin
 Forwarded Message 
From: Will Tipton 
To: help-glpk@gnu.org
Cc: John Rice 
Subject: identifying infeasible problem without using the LP presolver
Date: Mon, 21 Mar 2022 11:15:44 -0400

> Hi help-glpk,
> 
> We're using GLPK's simplex algorithm to solve some medium-sized lp
> problems (hundreds of variables and constraints). We've found that the
> presolver produces bad solutions, and we suspect that it's due to
> numerical issues, since the constraints may be near-degenerate in many
> cases.
> 
> Running without the presolver usually works great. However, we can't
> rely on the results in this case, because the simplex algorithm
> returns an OK error code even when it fails to find a feasible
> solution.
> 
> So:
> How hard would it be to get errors in case there is no feasible
> solution when not using the presolver?
> Any tips on debugging presolver stability problems?
> Thanks in advance,
> Will



[Fwd: gmpl question]

2021-12-17 Thread Andrew Makhorin
 Forwarded Message 
From: Davor Ocelic 
To: m...@gnu.org
Subject: gmpl question
Date: Fri, 17 Dec 2021 10:07:38 +0100

Heya,

I would appreciate minimal help with gmpl if you could:

In the glpk example `assign.mod`, the constraint is that
an agent can have only one task assigned:

s.t. phi{i in I}: sum{j in J} x[i,j] <= 1;
/* each agent can perform at most one task */

I would need to change this rule so that an agent doesn't
have a limit on number of tasks, but all tasks need to be
distributed among a limited number of agents. (For example,
distribute the 8 tasks in the example to 4 agents).

Could you help me with the syntax for that?

Thank you kindly,
Davor




Re: GLPK won't load its own exported MPS file

2021-11-01 Thread Andrew Makhorin
On Mon, 2021-11-01 at 11:47 +, Sierra Ansuas, Juan Pablo wrote:
> Hello,
>  
> I am trying to write a MPS file and then load it but I appear to be
> doing something wrong.
>  
> 1.   glp_write_mps(prob, GLP_MPS_FILE,NULL, “file.mps”);
> 2.   glp_read_mps(prob, GLP_MPS_FILE, NULL, “file.mps”);
>  
> But it’s complaining about “file.mps:5404: row '_BND_' multiply
> specified”

Most probably your program assigned duplicate names to rows/columns. 
Glp_write_mps doesn't check this while glp_read_mps does.





>  
> Thank you very much.
>  
> Regards,
> Juan Pablo
> La información contenida en este mensaje y en cualquier archivo
> adjunto, es confidencial y está dirigido únicamente al destinatario
> del mensaje. Si Ud. no es el destinatario correcto por favor notifique
> al remitente respondiendo este mensaje y elimine inmediatamente de su
> sistema el e-mail y los posibles archivos adjuntos. Está prohibida
> cualquier utilización, difusión o copia de este e-mail por cualquier
> persona o entidad que no sean las especificas destinatarias del
> mensaje. UTE no acepta ninguna responsabilidad con respecto a
> cualquier comunicación que haya sido emitida incumpliendo nuestra
> Política de Seguridad de la Información, así como lo previsto en la
> Ley 18.331 de Protección de Datos Personales y Ley 18381 de Acceso a
> la Información Pública



[Fwd: Re: Simplifications de glpsol]

2021-10-10 Thread Andrew Makhorin
 Forwarded Message 

Date: Sun, 10 Oct 2021 13:58:47 +0200
Subject: Re: Simplifications de glpsol
To: help-glpk@gnu.org
From: guy chevalier 
> I translate my precedent email in English :Good morning, 
> 
> I have a constraint x+y+z<=2 in glpsol model and I would like to know
> if glpsol deduce from others constraints that x=y it replaces my
> contraint by 2*x+z<=2 or not. If yes, is there an option for inhibit
> this process.
> 
> Thank you for your answer. 
> Le dim. 10 oct. 2021 à 11:56, guy chevalier  com> a écrit :
> > Bonjour,
> > J'ai une contrainte x+y+z<=2 dans un modèle et je voudrais savoir si
> > glpsol détecte que si x=y par déduction sur les autres contraintes
> > du modèle,  il remplace cette contrainte par 2*x+z<=2.
> > Si oui peut-on désactiver ce processus ?
> > 
> > À l'avance merci. 
> > 
> 
> 

[Fwd: Guidance for import data in gusek from excel table]

2021-09-27 Thread Andrew Makhorin
 Forwarded Message 

Date: Mon, 27 Sep 2021 19:33:19 -0300
Subject: Guidance for import data in gusek from excel table
To: help-glpk@gnu.org
From: Sagarkumar Patel 
> Hello Team,
> I wrote down a program for my final year project. The program works
> perfectly but I want to make sure that it will read the data from an
> excel file so every time I don't have to copy data from excel to
> gusek. But I don't know how to do it.
> 
> Could you please help me with this?
> 
> Regards,
> Sagar Patel
> 

[Fwd: Presolve]

2021-09-22 Thread Andrew Makhorin
 Forwarded Message 

Date: Wed, 22 Sep 2021 18:16:56 +
Subject: Presolve
To: help-glpk@gnu.org 
From: Javad Ahmadi 
> 
> 
> 
> 
> 
> 
> 
> 
> Does GLPK provide access or output the pre-solve model?
> If so please advise.
>  
> Regards, J. Ahmadi
>  
>  
> 
> 
> 
> 
> 
> Nothing in this message is intended to constitute an electronic
> signature unless a specific statement to the contrary is included in
> this message.
> 
> 
> 
> 
> Confidentiality Note: This message is intended only for the person or
> entity to which it is addressed. It may contain confidential and/or
> privileged material. Any review, transmission, dissemination or other
> use, or taking of any action in reliance upon this
>  message by persons or entities other than the intended recipient is
> prohibited and may be unlawful. If you received this message in error,
> please contact the sender and delete it from your computer.
> 
> 
> 

[Fwd: Feeding an initial feasible solution to GLPK for MILP in CVXPy]

2021-09-09 Thread Andrew Makhorin
 Forwarded Message 

Date: Thu, 9 Sep 2021 15:49:30 +
Subject: Feeding an initial feasible solution to GLPK for  MILP in CVXPy
To: help-glpk@gnu.org 
From: "Vasebi, Saeed [JJCUS]" 
> 
> 
> 
> 
> 
> 
> 
> 
> Hi all,
>  
> I have a MILP problem in GLPK, using CVXPy library. GLPK quickly finds
> a primary solution (optimal but not integer). But when GLPK switches
> to branch-and-cut to find an optimal integer solution, it moves very
> slowly. The main reason is
>  that GLPK does not find any feasible integer solution after many
> iterations (see the below log). I can use a simple heuristic algorithm
> to find an initial feasible and integer solution, which can help GLPK
> to quickly eliminate non-optimal branches. I am wondering
>  if there is any way to feed this initial feasible integer solution to
> GLPK, or its objective value?  
>  
> Thanks in advance for your time and kind reply.
> Sid
>  
>  
> [2021/09/08-22:33:43.822] - + 23315: mip = not found yet >= 
> -4.226425346e+08    (3161; 0)
> [2021/09/08-22:33:49.082] - + 23327: mip = not found yet >= 
> -4.226425346e+08    (3173; 0)
> [2021/09/08-22:33:54.333] - + 23339: mip = not found yet >= 
> -4.226425346e+08    (3185; 0)
> [2021/09/08-22:33:59.576] - + 23351: mip = not found yet >= 
> -4.226425346e+08    (3197; 0)
> [2021/09/08-22:34:04.615] - + 23364: mip = not found yet >= 
> -4.226425346e+08    (3209; 0)
> [2021/09/08-22:34:09.624] - + 23379: mip =     not found yet >= 
> -4.226425346e+08    (3221; 0)
> [2021/09/08-22:34:14.758] - + 23400: mip = not found yet >= 
> -4.226425346e+08    (3233; 0)
> [2021/09/08-22:34:20.118] - + 23417: mip = not found yet >= 
> -4.226425346e+08    (3246; 0)
>  
> 
> 
> 
> 

[Fwd: help for gusek]

2021-07-15 Thread Andrew Makhorin
 Forwarded Message 

Date: Thu, 15 Jul 2021 13:27:24 +0200
Subject: help for gusek
To: help-glpk@gnu.org
From: Adrien T 
> Hello,
> 
> I would like to use the Gusek solver to optimize a problem but in
> order to avoid a too long calculation I would like to be able to stop
> the calculation at 1% of the optimum do you know how?
> 
> ty
> Adrien
>  
>   
>   
>   Garanti sans virus. www.avast.com   
>   
> 
> 
> 

[Fwd: help for glpk]

2021-06-27 Thread Andrew Makhorin
 Forwarded Message 
From: yege...@sina.com
Reply-to: yege...@sina.com
To: mao 
Subject: help for glpk
Date: Sun, 27 Jun 2021 11:57:36 +0800

> Hi Andrew,
>   How are you? Sorry for bother you. I have some questions about
> glpk,I will be very appreciated if I can get some help from you.
>   I want solve a large scale LP problem,about 20 variables and 600
> constrains like a <= Ax <= b , and I tried glpk to solve it . It
> spends about 1ms to solve my prolem in my PC,very fast.
> But,it still does not satisfy my need, I wonder if there is optimizer
> possibility for the performence. I hope the problem can be solve
> within 100~200us.
>         The constrian max is a sparse matrix,like form:
>   X  X  X
>   X  X  X
>   ... ...  ...
>   X  X  X
>       X  X  X
>       X  X  X
>       ... ...  ...
>       X  X  X 
>       X  X  X
>       X  X  X
>        ... ...  ...
>        X  X  X 
>          ... ...  ...
> 
>   I wonder if GLPK will do some optimize for this kind of problem?
> look forward to your reply. thanks a lot.



[Fwd: Constraint not respected]

2021-06-22 Thread Andrew Makhorin
 Forwarded Message 

Date: Tue, 22 Jun 2021 09:25:01 +0200
Subject: Constraint not respected
To: help-glpk@gnu.org
From: Gioia Lorusso 
> Hi GLPK team,I am using GLPK and I am struggling in understanding why
> an upper bound constraint is not respected. 
> I have submitted a question on Stack Overflow but I was not able to
> find an answer. This is my question https://stackoverflow.com/question
> s/67982099/glpk-upper-bound-constraint-does-not-work-properly , I
> reported there my problem details and the GLPK output. Could you check
> it and possibly help me in understanding why the constraint c1 is not
> respected? Is there any kind of "relaxation" that I can avoid/forbid?
> Thanks a lot in advance for your help, 
> Regards,
> 
> 
> 
> -- 
> 
> 
> Gioia Lorusso
> Lead Backend Developer | Italy
> e: g.loru...@tuotempo.com
> w: http://www.tuotempo.com
> 

[Fwd: Include Examples in Documentation Showing Usage]

2021-06-09 Thread Andrew Makhorin
 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 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: The notes in English?

2021-06-05 Thread Andrew Makhorin
On Sat, 2021-06-05 at 12:16 +0200, Tadeus Prastowo wrote:
> Hello,
> 
> After downloading GLPK 5.0 tarball, I see some PDF notes written in
> Russian in the directory ./glpk-5.0/doc/notes.
> 
> By any chance, are the English translations of the PDF notes available
> somewhere?

AFAIK google has such a service, which is freely available.


> 
> Thank you.
> 



Re: Solver delivers wrong answer when 2 constraints are close

2021-03-04 Thread Andrew Makhorin
On Thu, 2021-03-04 at 17:47 +0100, Heinrich Schuchardt wrote:
> 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?


Both 1e-3 and 1e-5 are good enough.

If the result is sensitive to such small deviations, this only tells
that the model is badly formulated.


> 
> 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;/
> > > > *
> > > > *
> > > > 

Re: [Fwd: What is this format?]

2021-01-26 Thread Andrew Makhorin
On Tue, 2021-01-26 at 16:36 +0100, Alexandre Garreau wrote:
> Le mardi 26 janvier 2021, 16:12:24 CET Domingo Alvarez Duarte a écrit
> :
> > Where is GLPK 6.0 available ?
> > 
> > It's the first time I hear of it, and it's not available at
> > https://ftp.gnu.org/gnu/glpk/ .
> 
> Mine is below 5.0 (I use Debian stable), and the last release is 5.0,
> from 
> a few month ago… so I guess it’s a typo and it’s about 5.0
> 
> 

Sure, I meant 5.0.



Re: [Fwd: What is this format?]

2021-01-26 Thread Andrew Makhorin
On Tue, 2021-01-26 at 16:12 +0100, Domingo Alvarez Duarte wrote:
> Where is GLPK 6.0 available ?


Sorry, I meant 5.0 :)


> 
> It's the first time I hear of it, and it's not available at 
> https://ftp.gnu.org/gnu/glpk/ .
> 
> On 26/1/21 15:57, Andrew Makhorin wrote:
> > On Tue, 2021-01-26 at 13:33 +0100, Domingo Alvarez Duarte wrote:
> > > It seems to be a cplex OPL format.
> > > After manually convert it to GMPL (see bellow) I'm getting a
> > > segfault
> > 
> > This bug has been fixed in glpk 6.0.
> > 
> > FYI: https://lists.gnu.org/archive/html/bug-glpk/2020-07/msg9.ht
> > ml
> > 
> > 
> > 
> > 
> > > with ubuntu 18.04 glpk distribution:
> > > 
> > > glpsol -m cplex2mpl.mod
> > > GLPSOL: GLPK LP/MIP Solver, v4.65
> > > Parameter(s) specified in the command line:
> > >   -m cplex2mpl.mod
> > > Reading model section from cplex2mpl.mod...
> > > Reading data section from cplex2mpl.mod...
> > > 73 lines were read
> > > Generating result...
> > > Generating cstTemps...
> > > Generating cstPlanches...
> > > Model has been successfully generated
> > > GLPK Integer Optimizer, v4.65
> > > 3 rows, 5 columns, 15 non-zeros
> > > 5 integer variables, none of which are binary
> > > Preprocessing...
> > > 1 row, 0 columns, 0 non-zeros
> > > 0 integer variables, none of which are binary
> > > Scaling...
> > >   A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio = 
> > > 1.000e+00
> > > Problem data seem to be well scaled
> > > Solving LP relaxation...
> > > GLPK Simplex Optimizer, v4.65
> > > 1 row, 0 columns, 0 non-zeros
> > > ~ 0: obj =   1.49100e+02  infeas =  0.000e+00
> > > OPTIMAL SOLUTION FOUND
> > > Integer optimization begins...
> > > glp_add_cols: ncs = 0; invalid number of columns
> > > Error detected in file api/prob1.c at line 362
> > > Aborted (core dumped)
> > > 
> > > But with my fork at https://github.com/mingodad/GLPK it seems to
> > > work:
> > > 
> > > glpsol5 -m cplex2mpl.mod
> > > GLPSOL: GLPK LP/MIP Solver, v4.65, glp_double size 8
> > > Parameter(s) specified in the command line:
> > >   -m cplex2mpl.mod
> > > Reading model section from cplex2mpl.mod...
> > > 73 lines were read
> > > 73 lines were read
> > > Generating result...
> > > Generating cstTemps...
> > > Generating cstPlanches...
> > > Model has been successfully generated
> > > GLPK Integer Optimizer, v4.65
> > > 3 rows, 5 columns, 15 non-zeros
> > > 5 integer variables, none of which are binary
> > > Preprocessing...
> > > 1 row, 0 columns, 0 non-zeros
> > > 0 integer variables, none of which are binary
> > > Scaling...
> > >   A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio = 
> > > 1.000e+00
> > > Problem data seem to be well scaled
> > > Solving LP relaxation...
> > > GLPK Simplex Optimizer, v4.65
> > > 1 row, 0 columns, 0 non-zeros
> > > ~ 0: obj =   1.49100e+02  infeas =  0.000e+00
> > > OPTIMAL SOLUTION FOUND
> > > Integer optimization begins...
> > > Long-step dual simplex will be used
> > > + 0: mip = not found yet <=  +inf    (1;
> > > 0)
> > > + 0: >>>>>   1.49100e+02 <=   1.49100e+02   0.0% (1;
> > > 0)
> > > + 0: mip =   1.49100e+02 <= tree is empty   0.0% (0;
> > > 1)
> > > INTEGER OPTIMAL SOLUTION FOUND
> > > Time used:   0.0 secs
> > > Memory used: 0.1 Mb (118279 bytes)
> > > Il faut fabriquer :
> > > 1.00 objet(s) 1
> > > 1.00 objet(s) 2
> > > 1.00 objet(s) 3
> > > 1.00 objet(s) 4
> > > 1.00 objet(s) 5
> > > Il faut fabriquer :149.10
> > > Model has been successfully processed
> > > 
> > > Manually converting to GMPL could be something like this:
> > > 
> > > param N integer;
> > > param D;
> > > param dureeJournee integer;
> > > param planchesJournee integer;
> > > set objets := {1..N};
> > > param planches{objets} integer;
> > > param duree{i in objets} := planches[i] / D;
> > > param profit{objets};
> > > 
> > > var aFabriquer{objets} , >= 1, integer;
> > > 
> > > maximize result: sum{o in objets} profit[o]*aFabrique

Re: [Fwd: What is this format?]

2021-01-26 Thread Andrew Makhorin
On Tue, 2021-01-26 at 13:33 +0100, Domingo Alvarez Duarte wrote:
> It seems to be a cplex OPL format.
> After manually convert it to GMPL (see bellow) I'm getting a segfault 

This bug has been fixed in glpk 6.0.

FYI: https://lists.gnu.org/archive/html/bug-glpk/2020-07/msg9.html




> with ubuntu 18.04 glpk distribution:
> 
> glpsol -m cplex2mpl.mod
> GLPSOL: GLPK LP/MIP Solver, v4.65
> Parameter(s) specified in the command line:
>  -m cplex2mpl.mod
> Reading model section from cplex2mpl.mod...
> Reading data section from cplex2mpl.mod...
> 73 lines were read
> Generating result...
> Generating cstTemps...
> Generating cstPlanches...
> Model has been successfully generated
> GLPK Integer Optimizer, v4.65
> 3 rows, 5 columns, 15 non-zeros
> 5 integer variables, none of which are binary
> Preprocessing...
> 1 row, 0 columns, 0 non-zeros
> 0 integer variables, none of which are binary
> Scaling...
>  A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
> Problem data seem to be well scaled
> Solving LP relaxation...
> GLPK Simplex Optimizer, v4.65
> 1 row, 0 columns, 0 non-zeros
> ~ 0: obj =   1.49100e+02  infeas =  0.000e+00
> OPTIMAL SOLUTION FOUND
> Integer optimization begins...
> glp_add_cols: ncs = 0; invalid number of columns
> Error detected in file api/prob1.c at line 362
> Aborted (core dumped)
> 
> But with my fork at https://github.com/mingodad/GLPK it seems to work:
> 
> glpsol5 -m cplex2mpl.mod
> GLPSOL: GLPK LP/MIP Solver, v4.65, glp_double size 8
> Parameter(s) specified in the command line:
>  -m cplex2mpl.mod
> Reading model section from cplex2mpl.mod...
> 73 lines were read
> 73 lines were read
> Generating result...
> Generating cstTemps...
> Generating cstPlanches...
> Model has been successfully generated
> GLPK Integer Optimizer, v4.65
> 3 rows, 5 columns, 15 non-zeros
> 5 integer variables, none of which are binary
> Preprocessing...
> 1 row, 0 columns, 0 non-zeros
> 0 integer variables, none of which are binary
> Scaling...
>  A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
> Problem data seem to be well scaled
> Solving LP relaxation...
> GLPK Simplex Optimizer, v4.65
> 1 row, 0 columns, 0 non-zeros
> ~ 0: obj =   1.49100e+02  infeas =  0.000e+00
> OPTIMAL SOLUTION FOUND
> Integer optimization begins...
> Long-step dual simplex will be used
> + 0: mip = not found yet <=  +inf    (1; 0)
> + 0: >>>>>   1.49100e+02 <=   1.49100e+02   0.0% (1; 0)
> + 0: mip =   1.49100e+02 <= tree is empty   0.0% (0; 1)
> INTEGER OPTIMAL SOLUTION FOUND
> Time used:   0.0 secs
> Memory used: 0.1 Mb (118279 bytes)
> Il faut fabriquer :
> 1.00 objet(s) 1
> 1.00 objet(s) 2
> 1.00 objet(s) 3
> 1.00 objet(s) 4
> 1.00 objet(s) 5
> Il faut fabriquer :149.10
> Model has been successfully processed
> 
> Manually converting to GMPL could be something like this:
> 
> param N integer;
> param D;
> param dureeJournee integer;
> param planchesJournee integer;
> set objets := {1..N};
> param planches{objets} integer;
> param duree{i in objets} := planches[i] / D;
> param profit{objets};
> 
> var aFabriquer{objets} , >= 1, integer;
> 
> maximize result: sum{o in objets} profit[o]*aFabriquer[o];
> 
> s.t. cstTemps: sum{o in objets} duree[o]*aFabriquer[o] <=
> dureeJournee;
> cstPlanches: sum{o in objets} planches[o]*aFabriquer[o] <=
> planchesJournee;
> # une contrainte en plus: chaque objet est au moins fabriqu´e en 1
> exemplaire
> #auMoins1: forall(o in objets) aFabriquer[o] >= 1;
> 
> solve;
> 
> #display duree, planches, profit;
> printf "Il faut fabriquer :\n";
> printf{i in objets} "%f objet(s) %d\n", aFabriquer[i], i;
> printf "Il faut fabriquer :%f\n", result;
> 
> data;
> 
> param N := 5;
> param D := 3.4;
> param dureeJournee := 8;
> param planchesJournee := 40;
> param planches := 1 4, 2 5, 3 8, 4 3, 5 7;
> param profit := 1 12.6, 2 45.0, 3 8.0, 4 76.0, 5 7.5;
> 
> end;
> 
> On 26/1/21 12:00, Andrew Makhorin wrote:
> >  Forwarded Message 
> > From: Alexandre Garreau 
> > To: help-glpk@gnu.org
> > Subject: What is this format?
> > Date: Tue, 26 Jan 2021 11:46:03 +0100
> > 
> > Hello,
> > 
> > In my university, they use cplex for teaching linear programming,
> > and
> > I’d 
> > like not to install anything proprietary on my computer, but I have
> > to 
> > figure out how to deal with the files given while only doc for
> > cplex,
> >

[Fwd: What is this format?]

2021-01-26 Thread Andrew Makhorin
 Forwarded Message 
From: Alexandre Garreau 
To: help-glpk@gnu.org
Subject: What is this format?
Date: Tue, 26 Jan 2021 11:46:03 +0100

Hello,

In my university, they use cplex for teaching linear programming, and
I’d 
like not to install anything proprietary on my computer, but I have to 
figure out how to deal with the files given while only doc for cplex,
which 
I don’t have and never used…  Do you know what format this is? it uses 
“.mod” as an extension, apparently that’s what glpk uses for its own 
format… but in this case, it’s not isn’t it? I thought maybe free mps,
but 
reading it with --freemps doesn’t work either.  Here I attach a sample 
file, with the various errors I get:

$ glpsol --freemps charpentier1.mod 
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --freemps charpentier1.mod
Reading problem data from 'charpentier1.mod'...
charpentier1.mod:1: invalid indicator record
MPS file processing error
$ glpsol --glp charpentier1.mod
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --glp charpentier1.mod
Reading problem data from 'charpentier1.mod'...
charpentier1.mod:1: error: line designator missing or invalid
GLPK LP/MIP file processing error
$ glpsol --math charpentier1.mod
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --math charpentier1.mod
Reading model section from charpentier1.mod...
charpentier1.mod:1: syntax error in model section
Context:/
MathProg model processing error
$ glpsol --lp charpentier1.mod 
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --lp charpentier1.mod
Reading problem data from 'charpentier1.mod'...
charpentier1.mod:1: 'minimize' or 'maximize' keyword missing
CPLEX LP file processing error
$ glpsol --freemps -m charpentier1.mod 
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --freemps -m charpentier1.mod
Reading model section from charpentier1.mod...
charpentier1.mod:1: syntax error in model section
Context:/
MathProg model processing error
$ glpsol --glp -m charpentier1.mod 
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --glp -m charpentier1.mod
Reading model section from charpentier1.mod...
charpentier1.mod:1: syntax error in model section
Context:/
MathProg model processing error
$ glpsol --math -m charpentier1.mod 
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --math -m charpentier1.mod
Reading model section from charpentier1.mod...
charpentier1.mod:1: syntax error in model section
Context:/
MathProg model processing error
$ glpsol --lp -m charpentier1.mod 
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --lp -m charpentier1.mod
Reading model section from charpentier1.mod...
charpentier1.mod:1: syntax error in model section
Context:/
MathProg model processing error

charpentier1.mod
Description: audio/mod


[Fwd: GLPK usage for Eclipse C++ project]

2021-01-06 Thread Andrew Makhorin
 Forwarded Message 
From: Mahmut Yavuzer 
To: help-glpk@gnu.org 
Subject: GLPK usage for Eclipse C++ project
Date: Wed, 6 Jan 2021 14:31:28 +

Hi,
 
I have downloaded glpk-4.65 unpacked to the directory C:\progs\glpk-
4.65.
I have added environment variable C:\progs\glpk-4.65\w64.
 
 
I have also tried a Visual Studio project as explained on https://en.wik
ibooks.org/wiki/GLPK/Windows_executables#Building_a_C_program_using_the_
GLPK_library
 
I have tried the following code which is listed in the gmpl manuel. But
it is erroring as
 
“ Description  Resource Location  Path  
Type
C:\workspace\ATM\Debug/../AtmOrnek.cpp:19: undefined reference to
`glp_set_prob_name'   ATM  
C/C++ Problem “
 
Similar error on visual studio.
 
I can run command “glpsol –model myModel.mod”.
 
Could you please provide installation manuel or step by step
instructions for Eclipse CDT IDE.
 
Thanks
 
 
#include 
#include 
#include "glpk.h"
 
int main(void)
{
glp_prob *lp;
int ia[1+1000], ja[1+1000];
double ar[1+1000], z, x1, x2, x3;
lp = glp_create_prob();
glp_set_prob_name(lp, "sample");
glp_set_obj_dir(lp, GLP_MAX);
glp_add_rows(lp, 3);
glp_set_row_name(lp, 1, "p");
glp_set_row_bnds(lp, 1, GLP_UP, 0.0, 100.0);
glp_set_row_name(lp, 2, "q");
glp_set_row_bnds(lp, 2, GLP_UP, 0.0, 600.0);
glp_set_row_name(lp, 3, "r");
glp_set_row_bnds(lp, 3, GLP_UP, 0.0, 300.0);
glp_add_cols(lp, 3);
glp_set_col_name(lp, 1, "x1");
glp_set_col_bnds(lp, 1, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, 1, 10.0);
glp_set_col_name(lp, 2, "x2");
glp_set_col_bnds(lp, 2, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, 2, 6.0);
glp_set_col_name(lp, 3, "x3");
glp_set_col_bnds(lp, 3, GLP_LO, 0.0, 0.0);
glp_set_obj_coef(lp, 3, 4.0);
ia[1] = 1, ja[1] = 1, ar[1] = 1.0; /* a[1,1] = 1 */
ia[2] = 1, ja[2] = 2, ar[2] = 1.0; /* a[1,2] = 1 */
ia[3] = 1, ja[3] = 3, ar[3] = 1.0; /* a[1,3] = 1 */
ia[4] = 2, ja[4] = 1, ar[4] = 10.0; /* a[2,1] = 10 */
ia[5] = 3, ja[5] = 1, ar[5] = 2.0; /* a[3,1] = 2 */
ia[6] = 2, ja[6] = 2, ar[6] = 4.0; /* a[2,2] = 4 */
ia[7] = 3, ja[7] = 2, ar[7] = 2.0; /* a[3,2] = 2 */
ia[8] = 2, ja[8] = 3, ar[8] = 5.0; /* a[2,3] = 5 */
ia[9] = 3, ja[9] = 3, ar[9] = 6.0; /* a[3,3] = 6 */
glp_load_matrix(lp, 9, ia, ja, ar);
glp_simplex(lp, NULL);
z = glp_get_obj_val(lp);
x1 = glp_get_col_prim(lp, 1);
x2 = glp_get_col_prim(lp, 2);
 
  x3 = glp_get_col_prim(lp, 3);
printf("\nz = %g; x1 = %g; x2 = %g; x3 = %g\n",
z, x1, x2, x3);
glp_delete_prob(lp);
return 0;
}
Mahmut Yavuzer
Uzman Mühendis



T +90 312 265 0290 / 6428
www.karel.com.tr

Bu e-posta işbu bağlantıyı kullanarak erişebileceğiniz koşullara
tabidir: 
http://www.karel.com.tr/eposta-hukuki-sartlari 



[Fwd: Question for infeasible LP problem]

2021-01-04 Thread Andrew Makhorin
 Forwarded Message 

Date: Mon, 4 Jan 2021 23:23:17 +
Subject: Question for infeasible LP problem
To: help-glpk@gnu.org 
From: "Du, Jeanette" 
> 
> 
> 
> 
> 
> 
> 
> 
> 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
>  
>  
> 
> The information transmitted in this e-mail is for the exclusive use of
> the person or entity to which it is addressed and may contain legally
> privileged or confidential information. If you are not the intended
> recipient of this e-mail,
>  you are prohibited from reading, printing, duplicating, disseminating
> or otherwise using or acting in reliance upon this information. If you
> have received this information in error, please notify the sender at
> Freddie Mac immediately, delete this information
>  from your computer and destroy all copies of the information.
> 
> 
> 

Re: glpk 5.0 release information

2020-12-20 Thread Andrew Makhorin
On Wed, 2020-12-16 at 19:54 +0100, Domingo Alvarez Duarte wrote:
> It's there on the commit messages.but here they are too:
> 
> https://lists.gnu.org/archive/html/bug-glpk/2020-07/msg9.html

This bug was fixed.

> 
> https://lists.gnu.org/archive/html/bug-glpk/2019-07/msg0.html

This bug is not fixed yet, because both ssx_chuzc and ssx_chuzr will be
replaced by new versions.

> 
> This one 
> https://github.com/mingodad/GLPK/commit/c7abf466f0e31b3eeb1cf1bfd2b7c0
> dc8e05edad 
> apparently I've got a the mailing list link wrongly.
> 
> Cheers !
> 
> On 16/12/20 18:48, Andrew Makhorin wrote:
> > On Wed, 2020-12-16 at 16:59 +0100, Domingo Alvarez Duarte wrote:
> > > It seems that the problems reported on the mailing list and it's
> > > fixes
> > > are not in this release:
> > > 
> > > https://github.com/mingodad/GLPK/commit/6c9c1de01e10a99de89a94746b
> > > ad65
> > > 6dcc4f9838
> > > 
> > > https://github.com/mingodad/GLPK/commit/356faa9710ec7375e49615bd79
> > > 4258
> > > c914b9ae63
> > > 
> > > https://github.com/mingodad/GLPK/commit/c7abf466f0e31b3eeb1cf1bfd2
> > > b7c0
> > > dc8e05edad
> > > 
> > > I'm missing something here ?
> > 
> > Sorry. IIRC you suggested a lot of changes. Could you please remind
> > the
> > bug reports fixed by the changes above? Thank you.
> > 
> > 
> > Andrew Makhorin
> > 
> 
> 



Re: glpk 5.0 release information

2020-12-16 Thread Andrew Makhorin
On Wed, 2020-12-16 at 16:59 +0100, Domingo Alvarez Duarte wrote:
> It seems that the problems reported on the mailing list and it's
> fixes 
> are not in this release:
> 
> https://github.com/mingodad/GLPK/commit/6c9c1de01e10a99de89a94746bad65
> 6dcc4f9838
> 
> https://github.com/mingodad/GLPK/commit/356faa9710ec7375e49615bd794258
> c914b9ae63
> 
> https://github.com/mingodad/GLPK/commit/c7abf466f0e31b3eeb1cf1bfd2b7c0
> dc8e05edad
> 
> I'm missing something here ?


Sorry. IIRC you suggested a lot of changes. Could you please remind the
bug reports fixed by the changes above? Thank you.


Andrew Makhorin




Re: MathProg grammar in EBNF

2020-12-02 Thread Andrew Makhorin
On Wed, 2020-12-02 at 11:27 -0300, Germán Ferrari wrote:
> Hi.
> 
> I couldn't find the MathProg grammar in EBNF 

You can find all the grammar productions actually used by parsing
routines in comments to these routines; 

see glpk/src/mpl/mpl1.c and mpl2.c.

For example:

/*--
-- object_reference - parse reference to named object.
--
-- This routine parses primary expression using the syntax:
--
--  ::= 
--  ::= 
--  ::=  [  ]
--  ::= 
--  ::=  [  ]
--  ::=  
--  ::=  [  ]
--  
--  ::=  
--  ::=  [  ]
--  
--  ::= 
--  ::= 
--  ::= 
--  ::= 
--  ::= 
--  ::=  | .lb | .ub | .status | .val | .dual */

> so I created one. It only covers the declaration statements. Maybe
> it's useful to somebody else.

Thank you.

> 
> Any comments welcome. 

I'd like to note that if you enclose non-terminals in < and >, then
terminal symbols are not needed to be enclosed in quotes.

> 
> Thank you.
> 
> Regards,
> Germán.



Re: Help: Switch constraints on or off

2020-11-24 Thread Andrew Makhorin
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
> 
> 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: Change Path Input/Output file

2020-11-24 Thread Andrew Makhorin
On Tue, 2020-11-24 at 19:11 +, Manuel Castro wrote:
> Hi there,
> 
> I am currently using gusek as an IDE to model and run GLPK.
> I use the following statement to read from CSV file.
> 
> table tab_plant IN "CSV" "plants.csv" : I <- [plant], a ~ capacity;
> 
> This assumes that the file is placed in the same directory where the
> glpk solver is.
> How can I place my CSV file in a different directory and tell glpk to
> read it from there? How do I add the path on my model syntax? 

Conventions are the same as in C programs. You can write

"../foo/plants.csv"

or

MYDIR & "/plants.csv"

where MYDIR is a symbolic parameter declared like this:

param MYDIR, symbolic, := "../foo"


> 
> Many thanks in advance for your help. It's really appreciated.
> 
> Kind regards,
> Manuel. 
> 



[Fwd: 4.60 script not working in 4.65]

2020-11-10 Thread Andrew Makhorin
 Forwarded Message 
From: Diederik Veenendaal 
To: help-glpk@gnu.org
Subject: 4.60 script not working in 4.65
Date: Tue, 10 Nov 2020 09:28:13 +0100

> Dear Andrew,
> Thank you for providing GLPK. I'm trying to share a knapsack ILP
> script that works on my computer with someone else, but it fails on
> his computer.
> We're both running GLPK through CVXOPT, installed via Anaconda.
> However, I'm using v4.60, and he has installed v4.65. I'm unable to
> install an older version of GLPK through Anaconda. 
> I'm not sure where to even begin to look, because I don't understand
> if the problem is with my script, with CVXOPT or with GLPK.
> I hope the problem is familiar, or that you can point me in some
> possible directions.
> Kind regards,
> Diederik
> The script runs identical until an LP solution is found, but then
> deviates.
> My computer:
> OPTIMAL LP SOLUTION FOUND
> Integer optimization begins...
> +    12: mip = not found yet >=  -inf    (1; 0)
> Solution found by heuristic: -1500
> Solution found by heuristic: -1560
> Solution found by heuristic: -1570
> Solution found by heuristic: -1610
> Solution found by heuristic: -1620
> +   185: mip = -1.62000e+003 >= tree is empty   0.0% (0; 205)
> INTEGER OPTIMAL SOLUTION FOUND
> His computer.
> OPTIMAL LP SOLUTION FOUND
> Integer optimization begins...
> Long-step dual simplex will be used
> + 0: mip = not found yet >=  -inf    (1; 0)
> + 0: >  0.0e+000 >=  0.0e+000   0.0% (1; 0)
> + 0: mip =  0.0e+000 >= tree is empty   0.0% (0; 1)
> INTEGER OPTIMAL SOLUTION FOUND
> Wrong parameter 1 in LAPACKE_cgtsv_work
> Wrong parameter 1 in LAPACKE_cgtsv_work
> Wrong parameter 1 in LAPACKE_cggesx_work
> Wrong parameter 1 in LAPACKE_cggesx_work
> Wrong parameter 1 in LAPACKE_cggesx_work



[Fwd: Portable version]

2020-11-02 Thread 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



[Fwd: Help w. Constraint Please]

2020-10-24 Thread Andrew Makhorin
 Forwarded Message 
From: Manuel Castro 
To: help-glpk@gnu.org
Subject: Help w. Constraint Please
Date: Sat, 24 Oct 2020 09:02:40 -

> Hi there,
> 
> I would be thankful if you could help me in clarifying my questions
> below.
> I really appreciate your support. Many thanks in advance.
> 
> Constraint:
> subject to linctr19 {i in 1..365}:
> sum{j in (i - 1) * 48 + 1..(i * 48)} FlexibleLoadEfficiency *
> FlexibleLoadIncrease[j] - FlexibleLoadDecrease[j] = 0;
> 
> Error:
> \AppData\Local\Temp\SolverStudio 2i2iz0tk\model.txt:139: j not defined
> Context: ...cy * FlexibleLoadIncrease [ j ] - FlexibleLoadDecrease [ j
> ]
> MathProg model processing error
> 
> What I am trying to achieve:
> My index "i" represents a day. So I will have 365 days in total (i.e.
> 1 year). I want the constraint to be evaluated on a daily basis.
> My FlexibleLoadIncrease and FlexibleLoadDecrease decision variables
> will be arrays of 17520 elements each. This means I will have a
> representation of 1 full year on 30min basis. So each day is
> represented by 48 time periods.
> 
> Coming back to my contraint, I want to assess it on a daily basis and
> for each day I want to make the sum of the 48 half hour periods. Thus,
> for day i=1, I will have the sum of j from 1 to 48, for day i=2, I
> will have the sum of j from 49 to 96, for day i=3, I will have the sum
> of j from 97 to 144 and so on... I am struggling to represent this in
> GMPL.
> 
> I had this constraint in a different language which was "mosel" from
> Fico XPRESS. There I represented it as follow and works well:
> forall (i in 1.. 365) do
> sum (j in (i - 1) * 48 + 1..(i * 48)) (FlexibleLoadEfficiency *
> FlexibleLoadIncrease(j) - FlexibleLoadDecrease(j)) = 0
> sum (j in (i - 1) * 48 + 1..(i * 48)) (FlexibleLoadIncrease(j) -
> FlexibleLoadEnergyRating(j) * LoadPowerProfile(i)) <= 0
> end-do
> 
> How do I translate this into GMPL syntax??
> Many thanks for your help in advance. It's really appreciated.
> 
> Kind regards,
> Manuel.



[Fwd: Help please]

2020-10-17 Thread Andrew Makhorin
 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], <=
> FlexibleLoadEnergyRating * LoadPowerProfile[j];
> 
> 
> 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-27 Thread Andrew Makhorin
On Sun, 2020-09-27 at 11:32 +0200, Manuel Muñoz Márquez wrote:
> I agree with you, Andrew, but the problem is when the output is not a
> real number.
> 
> Suppose that you have to decide which of the project that are planning
> a big company will be done in the next year. Little difference in
> computation may lead to a solutions that are far enough one from the
> other providing very different sets of projects to be done. Is this
> admissible? Is this desirable?

If the instance has a unique optimum, only it will be reported on any
platform; however, the solution may slightly differs on different
platforms, but only within a tolerance. The case you're talking about
may happen only if the instance has multiple optima. In this case on one
platform the solver may report one optimal solution while on other
platform another, completely different optimal solution. But since all
these solutions are optimal, they all are *equivalent* to each other, 
so you can choose any of them. If, nevertheless, you think that some
optimal solution is not that you expect, this may only mean that you
missed some essential constraints.

> 
> So on Monday, Wednesday, and Friday that you work on your laptop you
> said that "Project A" should be done, but on Tuesday, Thursday, that
> your work on your supercomputer cluster you said that "Project A", of
> course, should no be done.
> 
> I'm not speaking if that is possible or not, I known that in the
> general case it is not, but for me it is a desirable behavior, and I
> think that the software should be as close to that behavior as
> possible.

> 
> El sáb, 26-09-2020 a las 15:40 +0300, Andrew Makhorin escribió:
> > 
> > In case of TeX it is important to provide identical output on any
> > platform, and to attain this Don implemented all calculations using
> > rational arithmetic. Though this approach can be used to solve, say,
> > linear algebra problems, it is impractical in general case. A
> > desirable
> > behavior of a computer program that solves a problem with a
> > numerical
> > method is to provide the result with sufficient accuracy for a
> > reasonable time, not more. Engineers and scientists (unlike
> > mathematicians and maybe accountants) as a rule are not interested
> > in
> > more than 5-6 correct decimal places in numerical results.
> > 
> > 
> > 
> > 
> 
> 



[Fwd: Re: Solver performance solving examples/life_goe.mod]

2020-09-26 Thread Andrew Makhorin
 Forwarded Message 
From: Jeffrey Kantor 
To: Chris Matrakidis 
Cc: Domingo Alvarez Duarte , help-glpk@gnu.org 
Subject: Re: Solver performance solving examples/life_goe.mod
Date: Sat, 26 Sep 2020 10:23:18 -0400

> Will there be a point where the GLPK package will be opened for
> collaborative development using, say, GitHub?
> 
> > On Sep 26, 2020, at 10:20 AM, Chris Matrakidis 
> > wrote:
> > 
> > I made some performance improving patches a few years ago. You can
> > find them in: https://github.com/cmatraki/GLPK
> > 
> > Best Regards,
> > 
> > Chris Matrakidis
> > 
> > On Sat, 26 Sep 2020 at 14:54, Domingo Alvarez Duarte  > .com> wrote:
> > > Hello !
> > > 
> > > Testing GLPK I left it solving examples/lie_goe.mod for more than
> > > 2 
> > > hours and it didn't found a solution (wasm and native) then I
> > > stopped 
> > > then and tried with cplex/gurobi/xpress/scip all of then gives a 
> > > solution instantly (except scip that takes 3s).
> > > 
> > > The difference is so big, have someone managed through command
> > > line 
> > > options or other means managed to get a solution quickly with
> > > glpsol ?
> > > 
> > > Any idea of how to improve GLPK to not be so behind ?
> > > 
> > > Cheers !
> > > 
> > > 
> > > 
> 
> 



Re: GLPSOL in webassemby faster than native ?

2020-09-26 Thread Andrew Makhorin
On Sat, 2020-09-26 at 09:51 +0200, Manuel Muñoz Márquez wrote:
> > Why do you want glpk to produce absolutely identical results on
> > different platforms? This has no practical sense. 
> > 
> 
> I think this is a desirable behavior. If your are solving a real
> problem it look very weird if you provides a solution using your
> computer and when you put in the user web server the system provides
> other.
> 
> Another point, is that if the calculation, and so the time required,
> depends on the platform there is no reliable way to compare "my
> results" with previous research.
> 
> Some systems, as LaTeX, work in that way. The result doesn't depend
> even the floating computation capabilities of the system CPU.
> 

In case of TeX it is important to provide identical output on any
platform, and to attain this Don implemented all calculations using
rational arithmetic. Though this approach can be used to solve, say,
linear algebra problems, it is impractical in general case. A desirable
behavior of a computer program that solves a problem with a numerical
method is to provide the result with sufficient accuracy for a
reasonable time, not more. Engineers and scientists (unlike
mathematicians and maybe accountants) as a rule are not interested in
more than 5-6 correct decimal places in numerical results.







Re: Solver performance solving examples/life_goe.mod

2020-09-26 Thread Andrew Makhorin
On Sat, 2020-09-26 at 13:54 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> Testing GLPK I left it solving examples/lie_goe.mod for more than 2 
> hours and it didn't found a solution (wasm and native) then I stopped 
> then and tried with cplex/gurobi/xpress/scip all of then gives a 
> solution instantly (except scip that takes 3s).
> 
> The difference is so big, have someone managed through command line 
> options or other means managed to get a solution quickly with glpsol ?
> 
> Any idea of how to improve GLPK to not be so behind ?

Hire 100 top-class specialists in integer programming and combinatorial
optimization, and give them 10 (or better 20) years. )))

If seriously, I think that gurobi (as well as cplex) solves many
combinatorial instances with hybrid methods other than pure branch-and-
cut. For example, glpk/examples/pbn.mod is very hard for b, but can be
relatively easily solved with a SAT solver.

> 
> Cheers !
> 
> 
> 



Re: GLPSOL in webassemby faster than native ?

2020-09-25 Thread Andrew Makhorin
> Something doesn't match for me, because I'm compiling GLPK/glpsol
> with and without optmization and get the same reported cuts:
> 
> Cuts on level 0: gmi = 5; mir = 44; cov = 20; clq = 3;  !! *
> the same
> =
> Cuts on level 0: gmi = 5; mir = 44; cov = 20; clq = 3;  * 
> the same
> =
> Cuts on level 0: gmi = 10; mir = 28; cov = 33; clq = 3; !*
> not the same
> =
> 

Why do you want glpk to produce absolutely identical results on
different platforms? This has no practical sense. 



Re: GLPSOL in webassemby faster than native ?

2020-09-25 Thread Andrew Makhorin
On Fri, 2020-09-25 at 10:04 +0200, Domingo Alvarez Duarte wrote:
> Hello Michael !
> 
> Thank you for reply !
> 
> I'll take into account the use of possible wider float format for 
> intermediary values using something like your suggestion of
> redefinable 
> type like "glp_double_t" (actually in gcc 9 in linux x86 "double_t"
> and 
> "double" are equal).
> 
> But also leave the possibility of have it working (somehow) with 
> float32, float64, float80, float128, ... everywhere.
> 
> Again help/suggestions/comments are welcome !
> 

Changing all doubles everywhere with long ones is not needed. 64-bit
double provides about 16 decimal places that is more than sufficient in
most cases. The only place where this might be crucial is linear algebra
routines (for example, on computing scalar products). However, it would
be better to use something like BLAS for this purpose.



Re: GLPSOL in webassemby faster than native ?

2020-09-22 Thread Andrew Makhorin
On Tue, 2020-09-22 at 15:53 +0200, Domingo Alvarez Duarte wrote:
> Hello again !
> 
> On an Android phone arm7 32bits Nexux-5 with chrome browser (wasm) 
> solving the "hashi.mod" with "--cuts" takes 98s and without it 909s, 
> using glpsol native compiled within termux takes 497s with "--cuts"
> and 
> without it 925s.


What does "native" mean? Just changing, for example, optimization level
of the compiler may essentially change the set of generated cuts and
thus the solution time.


> 
> Arm7 32bits Nexus-5:
> 
>  wasm "--cuts -m hashi.mod" -> 98s
> 
>  wasm " -m hashi.mod" -> 909s
> 
>  native "--cuts -m hashi.mod" -> 497s
> 
>  native " -m hashi.mod" -> 925s
> 
> 
> Laptop Linux 64bits I7:
> 
>  wasm "--cuts -m hashi.mod" -> 8s
> 
>  wasm " -m hashi.mod" -> 142s
> 
>  native "--cuts -m hashi.mod" -> 73s
> 
>  native " -m hashi.mod" -> 55s
> 
> 
> On arm7 "--cuts" improves the performance in both wasm and native.
> 
> On x86_64 "--cuts" improves in wasm but degrade in native.
> 
> I hope this could give hints to improve GLPK solver performance by 
> inspecting the decision's criteria and eventually find a better ones.
> 
> Anyone can give any idea with this data ?
> 
> Cheers !
> 
> On 21/9/20 17:11, Andrew Makhorin wrote:
> > On Mon, 2020-09-21 at 16:09 +0200, Domingo Alvarez Duarte wrote:
> > > Hello Andrew !
> > > 
> > > Are you saying that floating point calculations are more
> > > efficient/precise in webassembly ?
> > 
> > No. I meant that due to floating-point computations running the same
> > computer program with the same data as a rule produces different
> > results
> > on different platforms.
> > 
> > > Cheers !
> > > 
> > > On 21/9/20 15:08, Andrew Makhorin wrote:
> > > > > Does someone can give a possible explanation ?
> > > > 
> > > > floating-point computations
> 
> 



Re: GLPSOL in webassemby faster than native ?

2020-09-21 Thread Andrew Makhorin
On Mon, 2020-09-21 at 16:09 +0200, Domingo Alvarez Duarte wrote:
> Hello Andrew !
> 
> Are you saying that floating point calculations are more 
> efficient/precise in webassembly ?

No. I meant that due to floating-point computations running the same
computer program with the same data as a rule produces different results
on different platforms.

> 
> Cheers !
> 
> On 21/9/20 15:08, Andrew Makhorin wrote:
> > > Does someone can give a possible explanation ?
> > 
> > floating-point computations
> 
> 



Re: GLPSOL in webassemby faster than native ?

2020-09-21 Thread Andrew Makhorin
> Does someone can give a possible explanation ?

floating-point computations



Re: [Help-glpk] Operand following / has invalid type

2020-09-09 Thread Andrew Makhorin
On Wed, 2020-09-09 at 18:17 -0300, yami...@cock.li wrote:
> Hey,
> 
> I'm trying to make a program that populates a binary matrix keeping
> as 
> many blank lines as possible, e.g.
> 
> > 00|
> > 11|
> > 10|
> 
> instead of
> 
> > 10|
> > 10|
> > 10|
> 
> 
> Since I know the sum of the lines won't be too big I decided to use
> an 
> approach based on division, but I'm getting a "operand following /
> has 
> invalid type" error.
> 
> /* binary matrix */
> var m{x in X, y in Y} binary;
> /* minimizes total (sum of line)^-1, a full line is better than two 
> half-full lines*/
> minimize maxEmpty: sum{x in X} 1/(1 + sum{y in Y} m[x,y]);
> 
> I made a few tests and some constraints, I'm pretty sure it's not a 
> problem with the sets, the matrix, or a typo.
> If I had to guess I'd say the error is being caused by the nested
> sums, 
> but I couldn't find much on that.
> 
> Can this be fixed in any way?
> Thanks.
> 
> 

In constraints and objectives you can divide only by a constant
expression. In your case you divide by a linear form that leads to a
non-linear objective function, which is not allowed. Probably you need
to reformulate your model.



Re: Adding if/then/else statement to GMPL

2020-08-29 Thread Andrew Makhorin
On Sat, 2020-08-29 at 15:29 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> With this commit I'm close for a proof of concept of GMPL with multi 
> problem, multi solve, repeat and let statements.
> 
> The let needs work for the dependence hell when update a parameter.
> 
> The multi solve statements is implemented as calling a user provided 
> callaback (see in examples/glpsol.c for a crude example).
> 
> https://github.com/mingodad/GLPK/commit/65655c05fc8e315b3e43b98a1f2324
> 66614a0b46
> 
> It compiles and run examples/cut2.mod on an infinite loop due to 
> problems with propagation of updates with 'let' statement.
> 
> Ideally it should be compatible with existing models (not yet fully 
> implemented/checked).
> 
> Any comment/suggestion/help is welcome !

What about this:

   ...
   var z;
   ...
   if (z >= 0)
  s.t. foo: sum{j in J} x[j] >= 0;
   else
  s.t. bar: sum{j in J} x[j] <= 1;
   ...
   solve;
   ...

;)

> 
> Cheers !
> 
> 



Re: GMPL/GLPK display objective function value

2020-08-28 Thread Andrew Makhorin
> While trying to implement multi solve statements I found that in GMPL
> the display of an objective function after solving do not show the
> optimal value. 

BTW, glpsol warns about that:

[...]
38 lines were read
Generating Reduced_Cost...
Generating Width_Limit...
Model has been successfully generated
glp_mpl_build_prob: row Reduced_Cost; constant term 1 ignored
[...]



Re: GMPL/GLPK display objective function value

2020-08-28 Thread Andrew Makhorin
> While trying to implement multi solve statements I found that in GMPL 
> the display of an objective function after solving do not show the 
> optimal value.

Please see
http://en.wikibooks.org/wiki/GLPK/Troubleshooting#Objective_shift_term_ignored_when_exported





Re: Adding scoped local set/param declaration to GMPL

2020-08-25 Thread Andrew Makhorin
On Tue, 2020-08-25 at 22:12 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> I'm experimenting with allow local set/param declarations inside
> scoped 
> blocks (for/if/then/else), it's the base to possibly experiment
> further 
> with problem/callback/function declarations you can see/experiment
> with 
> it in this branch https://github.com/mingodad/GLPK/tree/local-set-para
> m 
> , look at 
> https://github.com/mingodad/GLPK/blob/local-set-param/examples/shikaku
> -if.mod 
> and 
> https://github.com/mingodad/GLPK/blob/local-set-param/examples/test-if
> .mod 
> to see it's usage.
> 
> 
> 
> for{i in 1..4} {
>  printf "now we are at %d\n", i;
>  if i mod 2 = 0 then { #assert when missing "= 0"
>  param lp := i+10;
>  set ls := {1..i+1};
>  printf "nested if lp = %d\n", lp;
>  display ls;
>  }
>  param lp := i+20;
>  set ls := {1..i+2};
>  printf "nested for lp = %d\n", lp;
>  display ls;
> }
> 
> 
> 
> Any comment/suggestion is welcome !
> 
> Cheers !
> 
> 
> 

I guess the next step will be implementation of classes? ;)




Re: Adding if/then/else statement to GMPL

2020-08-24 Thread Andrew Makhorin
> Probably something like MPL (Math Programming
> Language) developed by G.Dantzig in 70's is what you would like to
> have;
> see https://dl.acm.org/doi/10.1145/800184.810495 .
> 

I've got a scanned copy of this Tech. Report (May 1968, 92 pages); so if
someone is interested, I can post it via e-mail.



[Fwd: Re: Adding if/then/else statement to GMPL]

2020-08-24 Thread Andrew Makhorin
 Forwarded Message 
From: Jeffrey Kantor 
To: Andrew Makhorin 
Cc: "Meketon, Marc" , Domingo Alvarez
Duarte , help-glpk@gnu.org 
Subject: Re: Adding if/then/else statement to GMPL
Date: Mon, 24 Aug 2020 12:38:42 -0500

> Respectfully, and I very much appreciate the careful design of GMPL
> and its utility for creating ‘beautiful’ models, I have to disagree.
> What is being proposed, I think, is not a general purpose programming
> language, but rather extensions to GMPL making it more suitable to
> expressing well accepted models for important OR applications. Stock
> cutting is one example, but there are many others.
> 
> GMPL is very well suited to documenting models and applications,
> especially for teaching and education. They’re short, to the point,
> and above all, largely self-documenting. Extending the language should
> and could maintain these attributes. zWithout these extensions, I fear
> that GMPL will whither on the vine in favor of precisely what you
> describe … modeling tools embedded in higher level languages like
> Python and Julia.
> 
> My hope is the GMPL v2 would, like GMPL v1, something that, once
> created, stays fixed for decades. This is the advantage of a reference
> language for representing models, a role for which GMPL has been
> successful.  Models embedded in Python, Julia, etc, typically require
> additional maintanece as the languages and extensive libraries evolve.
> With GMPL one doesn’t have to worry about that. 
> 
> 
> > On Aug 24, 2020, at 12:17 PM, Andrew Makhorin  wrote:
> > 
> > On Mon, 2020-08-24 at 14:00 +, Meketon, Marc wrote:
> > > I've always felt that GMPL needed if-then-else, for-loops, 'let'
> > > statements and the ability to re-solve to be a true modeling
> > > language.  And Andrew has always disagreed.
> > > 
> > > Many of the models that I create ultimately are 'iterative' where
> > > I
> > > need to take the results of one model and use it to setup another
> > > model.  To me, that is also modeling.  GMPL doesn't have it.
> > > 
> > > So often, I use GMPL for an initial model - it is a wonderful
> > > language, and I find it faster to code than alternatives.  But
> > > then
> > > when I 'get it right' I have to re-code it in PYOMO or PULP or
> > > write
> > > directly to an 'lp' file within a Python or C# or other language
> > > script.
> > > 
> > > Having the ability to run, adjust variables, add/take away
> > > constraints, re-run would be extremely useful, and make GMPL more
> > > of a
> > > one-stop modeling language.
> > > 
> > 
> > I agree that programming features like "goto" (as well as its
> > structured
> > versions) sometimes are necessary, but in my opinion it should be
> > another language. Probably something like MPL (Math Programming
> > Language) developed by G.Dantzig in 70's is what you would like to
> > have;
> > see https://dl.acm.org/doi/10.1145/800184.810495 .
> > The initial design of AMPL, which GNU MathProg is based on, is not
> > suitable to make AMPL a full-featured programming language, and in
> > my
> > opinion all further additions just broke the design being
> > incompatible
> > with it.
> > 
> > On the other hand, developing and implementing yet another (even
> > domain-specific) programming language is not a good idea. I think
> > that
> > modeling features might be built *over* an appropriate programming
> > language. A good example of such approach is the GNU LilyPond (a
> > music
> > engraving program; see https://lilypond.org/ ), where the domain-
> > specific part is built over the Scheme programming language (a
> > dialect
> > of Lisp): in normal circumstances the user writes all things with
> > domain-specific constructions, but if something unusual is needed,
> > he/she may write things on a lower level directly in Scheme.
> > 
> > 
> > Andrew Makhorin
> 
> 



Re: Adding if/then/else statement to GMPL

2020-08-24 Thread Andrew Makhorin
On Mon, 2020-08-24 at 14:00 +, Meketon, Marc wrote:
> I've always felt that GMPL needed if-then-else, for-loops, 'let'
> statements and the ability to re-solve to be a true modeling
> language.  And Andrew has always disagreed.
> 
> Many of the models that I create ultimately are 'iterative' where I
> need to take the results of one model and use it to setup another
> model.  To me, that is also modeling.  GMPL doesn't have it.
> 
> So often, I use GMPL for an initial model - it is a wonderful
> language, and I find it faster to code than alternatives.  But then
> when I 'get it right' I have to re-code it in PYOMO or PULP or write
> directly to an 'lp' file within a Python or C# or other language
> script.
> 
> Having the ability to run, adjust variables, add/take away
> constraints, re-run would be extremely useful, and make GMPL more of a
> one-stop modeling language.
> 

I agree that programming features like "goto" (as well as its structured
versions) sometimes are necessary, but in my opinion it should be
another language. Probably something like MPL (Math Programming
Language) developed by G.Dantzig in 70's is what you would like to have;
see https://dl.acm.org/doi/10.1145/800184.810495 .
The initial design of AMPL, which GNU MathProg is based on, is not
suitable to make AMPL a full-featured programming language, and in my
opinion all further additions just broke the design being incompatible
with it.

On the other hand, developing and implementing yet another (even
domain-specific) programming language is not a good idea. I think that
modeling features might be built *over* an appropriate programming
language. A good example of such approach is the GNU LilyPond (a music
engraving program; see https://lilypond.org/ ), where the domain-
specific part is built over the Scheme programming language (a dialect
of Lisp): in normal circumstances the user writes all things with
domain-specific constructions, but if something unusual is needed,
he/she may write things on a lower level directly in Scheme.


Andrew Makhorin




[Fwd: Re: Adding if/then/else statement to GMPL]

2020-08-24 Thread Andrew Makhorin
 Forwarded Message 
From: Jeffrey Kantor 
To: "Meketon, Marc" 
Cc: Andrew Makhorin , Domingo Alvarez Duarte , help-glpk@gnu.org 
Subject: Re: Adding if/then/else statement to GMPL
Date: Mon, 24 Aug 2020 09:54:33 -0500

> This would be another vote for extending GMPL to include features to
> support the iterative use of LP’s. As is stands, GMPL is a sweet
> little modeling tool … a well-crafted application is small work of art
> that is generally clear and unambiguous. One mark fo a good model is
> the ability to go back years later and instantly recall the logic
> behind the model. 
> 
> There are so many more applications where iteration is a natural part
> of the modeling. Stocking cutting, for example. Stochastic
> programming. With these features, GMPL could continue to be a useful
> tool for developing and documenting models and MILP applications.
> Without these features, tools like PULP and Pyomo become the lingua
> franca of the field.
> 
> > On Aug 24, 2020, at 9:00 AM, Meketon, Marc via Users list for GLPK
> > (GNU Linear Programming Kit)  wrote:
> > 
> > I've always felt that GMPL needed if-then-else, for-loops, 'let'
> > statements and the ability to re-solve to be a true modeling
> > language.  And Andrew has always disagreed.
> > 
> > Many of the models that I create ultimately are 'iterative' where I
> > need to take the results of one model and use it to setup another
> > model.  To me, that is also modeling.  GMPL doesn't have it.
> > 
> > So often, I use GMPL for an initial model - it is a wonderful
> > language, and I find it faster to code than alternatives.  But then
> > when I 'get it right' I have to re-code it in PYOMO or PULP or write
> > directly to an 'lp' file within a Python or C# or other language
> > script.
> > 
> > Having the ability to run, adjust variables, add/take away
> > constraints, re-run would be extremely useful, and make GMPL more of
> > a one-stop modeling language.
> > 
> > -Original Message-
> > From: Help-glpk  > org> On Behalf Of Andrew Makhorin
> > Sent: Sunday, August 23, 2020 2:56 PM
> > To: Domingo Alvarez Duarte ; help-glpk@gnu.org
> > Subject: Re: Adding if/then/else statement to GMPL
> > 
> > On Sun, 2020-08-23 at 15:36 +0200, Domingo Alvarez Duarte wrote:
> > > Hello !
> > > 
> > > Also I've added the break/continue statements here
> > > https://github.com/mingodad/GLPK/commit/9d70a37b16bd377722eeb3880f
> > > cf86
> > > bb3b812118
> > > 
> > > 
> > > Again any comment/suggestion is welcome !
> > > 
> > > Cheers !
> > > 
> > > 
> > > 
> > 
> > Please note that GNU MathProg is a *modeling* language; it is not a
> > general-purpose programming language. If you need to produce a non-
> > trivial solution report (since all such-like statements are allowed
> > only on the post-solving stage), it would be more practical to write
> > the solution to a temporary file and then process it with a separate
> > program.
> > 
> > 
> > 
> > 
> > 
> > This e-mail and any attachments may be confidential or legally
> > privileged. If you received this message in error or are not the
> > intended recipient, you should destroy the e-mail message and any
> > attachments or copies, and you are prohibited from retaining,
> > distributing, disclosing or using any information contained herein.
> > Please inform us of the erroneous delivery by return e-mail. Thank
> > you for your cooperation.
> 
> 



Re: Adding if/then/else statement to GMPL

2020-08-23 Thread Andrew Makhorin
On Sun, 2020-08-23 at 15:36 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> Also I've added the break/continue statements here 
> https://github.com/mingodad/GLPK/commit/9d70a37b16bd377722eeb3880fcf86
> bb3b812118 
> 
> 
> Again any comment/suggestion is welcome !
> 
> Cheers !
> 
> 
> 

Please note that GNU MathProg is a *modeling* language; it is not 
a general-purpose programming language. If you need to produce a
non-trivial solution report (since all such-like statements are 
allowed only on the post-solving stage), it would be more practical 
to write the solution to a temporary file and then process it with 
a separate program.





Re: Huge memory usage difference

2020-08-16 Thread Andrew Makhorin
On Sun, 2020-08-16 at 11:53 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> I just found a class of models that can exhibit a huge memory usage 
> difference depending on if we add or not add parameter missing values 
> when there is a default value declaration for then.
> 
> See this model for example 
> https://github.com/mingodad/GLPK/commit/539dd9774829dee4a0b8c8199a9d2b94a3c7d9cb:
> 
> GLPK-4.65 from pacakage manager    69.85s    3001.9 Mb    1x 1x
> 
> GLPK-4.65 with several optimizations    26.02s    1506.0 Mb 0.37x    0.5x
> 
> GLPK-4.65 prev + no param add missing    16.36s    21.2 Mb Mb 0.23x
> 0.007x
> 
> This huge difference is due to this changes 
> https://github.com/mingodad/GLPK/commit/70d4ad7e97cdb34ee6348c864bd3a941cdb0d422
>  
> .
> 
> If you have big models/data and can test then with the master branch of 
> https://github.com/mingodad/GLPK and report your results I would 
> appreciate it and hope this can lead to more performance improvements in 
> GMPL/GLPK.


It may not work correctly in some cases, because the expression 
specified in the default option may recursively refer to elements 
of the same parameter (directly or indirectly).


> 
> Notice right now the changes mainly affect GMPL model/data generation 
> not solver/solving the generated problem.
> 
> 
> 
> /usr/bin/time glpsol-from-package-manager -m mem-default.mod -d 
> mem-default.dat
> GLPSOL: GLPK LP/MIP Solver, v4.65
> Parameter(s) specified in the command line:
>   -m mem-default.mod -d mem-default.dat
> Reading model section from mem-default.mod...
> mem-default.mod:23: warning: unexpected end of file; missing end 
> statement inserted
> 23 lines were read
> Reading data section from mem-default.dat...
> mem-default.dat:32660: warning: unexpected end of file; missing end 
> statement inserted
> 32660 lines were read
> Generating omax...
> Generating c1...
> Generating c2...
> Model has been successfully generated
> GLPK Integer Optimizer, v4.65
> 13589 rows, 14037 columns, 42743 non-zeros
> 449 integer variables, all of which are binary
> Preprocessing...
> 9 constraint coefficient(s) were reduced
> 4056 rows, 4495 columns, 12792 non-zeros
> 448 integer variables, all of which are binary
> Scaling...
>   A: min|aij| =  1.310e-05  max|aij| =  2.660e+02  ratio = 2.031e+07
> GM: min|aij| =  7.228e-02  max|aij| =  1.384e+01  ratio = 1.914e+02
> EQ: min|aij| =  5.224e-03  max|aij| =  1.000e+00  ratio = 1.914e+02
> 2N: min|aij| =  2.620e-03  max|aij| =  1.750e+00  ratio = 6.679e+02
> Constructing initial basis...
> Size of triangular part is 4056
> Solving LP relaxation...
> GLPK Simplex Optimizer, v4.65
> 4056 rows, 4495 columns, 12792 non-zeros
> * 0: obj =   1.0e+00 inf =   0.000e+00 (2721)
> *  3122: obj =   5.173823646e+02 inf =   0.000e+00 (0) 3
> OPTIMAL LP SOLUTION FOUND
> Integer optimization begins...
> Long-step dual simplex will be used
> +  3122: mip = not found yet <=  +inf (1; 0)
> +  3122: >   5.173823646e+02 <= 5.173823646e+02   0.0% (1; 0)
> +  3122: mip =   5.173823646e+02 <= tree is empty   0.0% (0; 1)
> INTEGER OPTIMAL SOLUTION FOUND
> Time used:   0.3 secs
> Memory used: 3001.9 Mb (3147772544 bytes)
> 69.85user 0.88system 1:10.73elapsed 99%CPU (0avgtext+0avgdata 
> 3083108maxresident)k
> 0inputs+0outputs (0major+770102minor)pagefaults 0swaps
> 
> 
> 
> 
> 
> /usr/bin/time myglpsol-with-several-optmizations -m mem-default.mod -d 
> mem-default.dat
> GLPSOL: GLPK LP/MIP Solver, v4.65
> Parameter(s) specified in the command line:
>   -m mem-default.mod -d mem-default.dat
> Reading model section from mem-default.mod...
> mem-default.mod:23: warning: unexpected end of file; missing end 
> statement inserted
> 23 lines were read
> Reading data section from mem-default.dat...
> mem-default.dat:32660: warning: unexpected end of file; missing end 
> statement inserted
> 32660 lines were read
> Generating omax...
> Generating c1...
> Generating c2...
> Model has been successfully generated
> GLPK Integer Optimizer, v4.65
> 13589 rows, 14037 columns, 42743 non-zeros
> 449 integer variables, all of which are binary
> Preprocessing...
> 9 constraint coefficient(s) were reduced
> 4056 rows, 4495 columns, 12792 non-zeros
> 448 integer variables, all of which are binary
> Scaling...
>   A: min|aij| =  1.310e-05  max|aij| =  2.660e+02  ratio = 2.031e+07
> GM: min|aij| =  7.228e-02  max|aij| =  1.384e+01  ratio = 1.914e+02
> EQ: min|aij| =  5.224e-03  max|aij| =  1.000e+00  ratio = 1.914e+02
> 2N: min|aij| =  2.620e-03  max|aij| =  1.750e+00  ratio = 6.679e+02
> Constructing initial basis...
> Size of triangular part is 4056
> Solving LP relaxation...
> GLPK Simplex Optimizer, v4.65
> 4056 rows, 4495 columns, 12792 non-zeros
> * 0: obj =   1.0e+00 inf =   0.000e+00 (2721)
> *  3122: obj =   5.173823646e+02 inf =   0.000e+00 (0) 3
> OPTIMAL LP SOLUTION FOUND
> Integer optimization begins...
> Long-step dual simplex will be used
> +  3122: mip = 

Re: AVL tree silently accept duplicate keys

2020-08-10 Thread Andrew Makhorin
On Mon, 2020-08-10 at 14:28 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> Replacing usages of AVL tree by SplayTree I found that AVL tree
> silently 
> accepts duplicate keys on "avl_insert_node" see example bellow, there
> is 
> only one way to find by key "avl_find_node" which make it prone to
> write 
> incorrect code:
> 

AVL routines are not intended to be used on API level. Formally, these
routines are not available to the user.

Both AVL and splay trees take logarithmic time, so there is not much
sense to use the latter. To really reduce the search time it would be
better to use hashing.


PS: Please post messages not related to bug reports to help-glpk rather
than to bug-glpk. Thanks.


> 
> 
> #include 
> #include 
> #include "avl.h"
> 
> int main(int argc, char *argv[])
> {
>  AVL *tree = avl_create_tree(avl_strcmp, NULL);
>  AVLNODE *node1 = avl_insert_node(tree, "one");
>  printf("node1 = %p\n", node1);
>  AVLNODE *node2 = avl_insert_node(tree, "one");
>  printf("node2 = %p\n", node2);
>  AVLNODE *node3 = avl_insert_node(tree, "one");
>  printf("node3 = %p\n", node3);
>  AVLNODE *node = avl_find_node(tree, "one");
>  printf("node = %p\n", node);
>  avl_delete_node(tree, node1);
>  node = avl_find_node(tree, "one");
>  printf("node = %p\n", node);
>  avl_delete_node(tree, node2);
>  node = avl_find_node(tree, "one");
>  printf("node = %p\n", node);
>  avl_delete_tree(tree);
>  return 0;
> }
> 
> 
> 
> Build:
> 
> 
> 
> gcc -g -o test-avl test-avl.c -I../src/misc -I../src
> ../src/.libs/libglpk.a
> 
> 
> 
> Output:
> 
> =
> 
> ./test-avl
> node1 = 0x55f599e6d908
> node2 = 0x55f599e6d940
> node3 = 0x55f599e6d978
> node = 0x55f599e6d940
> node = 0x55f599e6d940
> node = 0x55f599e6d978
> 
> =
> 
> Cheers !
> 
> 
> 



Re: Is this code correct in the GMPL implementation ?

2020-08-01 Thread Andrew Makhorin
On Sat, 2020-08-01 at 11:26 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> This is my fourth time trying to replace the actual TUPLE struct 
> representation https://github.com/mingodad/GLPK/tree/new-tuple and
> I'm 
> struggling again in understand/rewrite some parts of the code,
> mainly 
> src/mpl/mpl3.c::saturate_set and other places.
> 
> I'm asking for help to try to fix/rewrite the missing pieces on it,
> I 
> hope that this changes once corrected would give a reduction in
> memory 
> usage and probably execution time for GMPL.
> 
> Thank you in advance for any help you can give !
> 
> Cheers !


Please note that using nanbox makes the code non-portable. 
The ANSI C Standard (ANSI/ISO 9899-1990 aka C89), which glpk conforms
to, says nothing about representation of floating-point objects.








Re: Help - GLPK - "Time used" in millisecond ?

2020-07-28 Thread Andrew Makhorin
On Tue, 2020-07-28 at 20:58 +0530, Biplab Kanti Sen wrote:
> Thanks for your kind response. Is it possible to get the exact time
> in millisecond ? Is there any wayout to change the format spec "%.1f"
> ? I need to know the exact time required for solving the problem. I
> need this value for a research publication where I am going to
> mention GLPK as a tool used for my research work. 
> 

See file glpk/examples/glpsol.c, lines 1429-1430:

  xprintf("Time used:   %.1f secs\n", glp_difftime(glp_time(),
 start));

Please note, however, that a small solution time (less than a second)
displayed by glpsol may be inappropriate for your purpose. In such
cases I'd recommend just to say that the solution time was less than a
second on a such-and-such processor.



Re: Help - GLPK - "Time used" in millisecond ?

2020-07-28 Thread Andrew Makhorin
On Tue, 2020-07-28 at 19:48 +0530, Biplab Kanti Sen wrote:
> Sir/Madam,
> 
> I am Biplab kanti sen, would like to state you that, I use GLPK to
> solve linear programs. I found that, one of my program is
> successfully running, but the execution time is showing as "Time
> used: 0.0 sec". Is there any provision to get this "Time used" in
> millisecond ?  I have attached an output file for your reference.
> Waiting for your kings reply.


This time is displayed in seconds using the format spec "%.1f", so
"0.0 sec" means that the solution time is less than 0.05 seconds.


> 
> Thanking you
> Biplab kanti sen



Re: Excessive copies of set elements in GMPL

2020-07-25 Thread Andrew Makhorin
On Fri, 2020-07-24 at 13:04 -0500, Michael Hennebry wrote:
> On Fri, 24 Jul 2020, Andrew Makhorin wrote:
> 
> > The issue can be illustrated by the following example:
> > 
> >  for (i = 0; i < 100; i++)
> >  for (j = 0; j < 100; j++)
> >  for (k = 0; k < 100; k++)
> >    if (j == i+1 && j == j+2)
> >  foo(i, j, k);
> > 
> > Would you expect the C compiler to optimize this fragment in order
> > not
> > to perform obvious excessive computations?
> 
> My recollection is that gcc does make that
> kind of optimization for linear constraints.
> At the very least, most optimizing compilers
> would hoist the j==i+1 test ouside the k loop.
> That might be just enough to allow it to run in a practical amount of
> time:
> a few trillion cycles plus whatever foo requires.

Yes, recent versions of gcc include very smart optimization features,
and probably in the example above gcc would be able to eliminate loops
on j and k. In MathProg (AMPL) as well as in RDBMS the situation is a
bit easier, however, the problem has the same nature, and solving it
even in a limited number of practical cases is an extremely non-trivial 
task. I know many cases when a simple reformulation of a sql statement
significantly reduced the processing time, though modern RDBMS'es
provide very powerful features to optimize access to data tables.
(Usually formulae given in textbooks are inappropriate to be used in
real computer programs.)

> 
> That said, the coder can, as noted,
> provide equivalent code that requires no optimization.
> 



Re: Is this code correct in the GMPL implementation ?

2020-07-25 Thread Andrew Makhorin
On Sat, 2020-07-25 at 13:35 +0200, Domingo Alvarez Duarte wrote:
> Hello !
> 
> Trying to change the actual TUPLE structure by:
> 
> 
> 
> #ifndef TUPLE_SIZE_T
> #define TUPLE_SIZE_T int
> #endif
> struct TUPLE
> {
>    TUPLE_SIZE_T size;
>    TUPLE_SIZE_T refcount;
>    SYMBOL sym[1];
>    /* symbol, which the component refers to; cannot be NULL */
> };
> 
> 
> 
> I found the code bellow (in src/mpl/mpl3.c) that I'm not sure I 
> understand it,
> 
> it seems that it's only testing the last tuple against 
> "code->arg.arg.y", shouldn't it be testing inside the loop for every
> tuple ?
> 
> I would appreciate someone could help understand this code !
> 
> 
> 
> int is_member(MPL *mpl, CODE *code, const TUPLE *tuple)
> { int value;
> ...
> 
>   case O_CROSS:
>  {  int j;
>     value = is_member(mpl, code->arg.arg.x, tuple);
>     if (value)
>     {  for (j = 1; j <= code->arg.arg.x->dim; j++)
>    {  xassert(tuple != NULL);
>   tuple = tuple->next;
>    }
>    value = is_member(mpl, code->arg.arg.y, tuple);
>     }
>  }
>  break;
> 
> 
> 
> Cheers !
> 
> 
> 

The routine is_member checks if the given n-tuple (specified by
'tuple') is a member of the given set (specified by 'code'). The check
is performed recursively by traversing the set expression tree. For
example, on evaluating the condition "... (x,y) in X cross Y ..." the
routine will check that x is in X and y is in Y.






Re: Excessive copies of set elements in GMPL

2020-07-24 Thread Andrew Makhorin


> if (j == i+1 && j == j+2)
> 

Must read

  if (j == i+1 && k == j+2)




Re: Excessive copies of set elements in GMPL

2020-07-24 Thread Andrew Makhorin
On Fri, 2020-07-24 at 09:12 +0200, Domingo Alvarez Duarte wrote:
> And here is the output of the the script bellow:
> 
> Memory usage:
> 
> ubuntu glpsol package : 1,422,160 KB => 4.20s elapsed
> 
> glpk with my changes: 429,000 KB => 1.37s elapsed
> 
> 

As I explained in my previous message, the MathProg translator performs
 all computations directly as specified by corresponding expressions,
i.e. *no code optimization* is used. 

In most cases the user may perform some "optimization" replacing
non-efficient expressions by more efficient ones. For example,

  set D := { (a,b,c) in A cross B cross C : b=a+1 and c=b+2 };

can be replaced by

  set D := setof{a in A, b in B, c in C: b=a+1 and c=b+2} (a,b,c);

in order not to compute "A cross B cross C".

I agree that the translator could be more smart to recognize such
cases, but necessary analysis in a general case is a non-trivial thing,
and there was no attempt to implement anything of this kind.

The issue can be illustrated by the following example:

  for (i = 0; i < 100; i++)
  for (j = 0; j < 100; j++)
  for (k = 0; k < 100; k++)
if (j == i+1 && j == j+2)
  foo(i, j, k);

Would you expect the C compiler to optimize this fragment in order not
to perform obvious excessive computations?


Andrew Makhorin



Re: Excessive copies of set elements in GMPL

2020-07-16 Thread Andrew Makhorin


> Do you have any tests or know someone that has then and can share
> then ? 
> (Preferable in a public repository.)
> 
> 

You might try models from glpk/examples.



Re: Excessive copies of set elements in GMPL

2020-07-16 Thread Andrew Makhorin


> 
> After doing some experimentation I think I found an easy way to 
> eliminate unnecessary set copies here is a commit on 
> https://github.com/mingodad/GLPK/commit/6f3da6ab31ca8d710f706f60635e5
> b17cf2ded40, 
> also see bellow, glpsol now uses 1/3 of the memory and is slight
> faster:

Please note that in the MathProg translator there are two ways used to
pass array objects: by reference, when no copy is created, and by
value, when a copy is created. In the latter case it is assumed that
the routine may change the object passed (directly or indirectly), so
I'm not sure that your approach based on using reference counts will
work correctly in a general case.



Re: Excessive copies of set elements in GMPL

2020-07-16 Thread Andrew Makhorin


> Trying to improve GLPK/GMPL 

It is a non-trivial task.

The MathProg translator included in glpk was implemented in a 
non-efficient way, because there was no intention to process models 
of huge size (so this allowed essentially reducing implementation
efforts).

The key idea to translate MathProg (or AMPL) models much more
efficiently is to avoid using "direct" representation of sets and
arrays and implement all operations in a way similar to one used 
in relational database management systems.

> I can see that GMPL model generation is 
> making an excessive number of set element copies (see bellow).

Please note that most of the copies might be temporary quantities 
that exist (allocated in the memory) only during evaluation of the
(sub)expressions involving these quantities.


Best regards,

Andrew Makhorin



[Fwd: installation help]

2020-07-15 Thread Andrew Makhorin
 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’:
> 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’:
> src/c/glpk_wrap.c:18713: warning: cast to pointer from integer of
> different size
> make[2]: *** [all] Error 1
> make[2]: Leaving directory `/storage2/APPS/MOST/libglpk-java-
> 1.12.0/swig'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/storage2/APPS/MOST/libglpk-java-1.12.0'
> make: *** [all] Error 2
>  

[Fwd: Need help in Fixing GUSEK Code]

2020-04-10 Thread Andrew Makhorin
 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];
> Executing AMPL.
> 
> If anyone can help me, really appreciate your help in this regard.
> 
> Thank You,
> 
> Best Regards,
> 
> Sahani 
> 
> 



Re: glp ios heur sol

2020-03-04 Thread Andrew Makhorin
On Wed, 2020-03-04 at 15:29 +0100, Jacopo Pierotti (Optimisation)
wrote:
> Dear Mao,
> 
>  my name is Jacopo Pierotti and I am a PhD candidate in
> Optimization.
> 
> I'm writing you because I am working on heuristic solutions for MILP.
> To 
> test my algorithm, I would like to know what kind of heuristic is
> GLPN 
> using. In the documentation, you explain that 'glp ios heur
> sol—provide 
> solution found by heuristic'. I am interested in knowing how this 
> heuristic works.

glp_ios_heur_sol doesn't implement any heuristics. It is an interface
between the glpk mip solver and the heuristic routine provided by the
user. For more details please see the glpk reference manual.


> 
> Clearly, if my project works and I obtain nice results, I'll share
> my 
> code with you.
> 
> Bests,
> 
> Jacopo
> 
> 



[Fwd: Intellij syntax highlighting]

2020-02-12 Thread Andrew Makhorin
 Forwarded Message 
From: Jonas Stenberg 
To: help-glpk@gnu.org 
Subject: Intellij syntax highlighting
Date: Wed, 12 Feb 2020 13:56:25 +

> In case anyone is interested: I have created a config file that
> brings 
> syntax highlighting for GLPK model files to Intellij.
> 
> https://github.com/stenix71/intellij-glpk
> 
> 



further plans about glpk

2020-02-04 Thread Andrew Makhorin
Hi Heinrich,

> @Андрей
> There hasn't been any GLPK release since two years. What are your
> plans?

Currently I'm going to transfer the copyright under which glpk is
distributed to the Free Software Foundation (FSF). I will continue
maintaining glpk (and maybe you and Chris also could help with this),
however I will be unable to work on it at least to the end of this
year.

Best regards,

Andrew Makhorin

> 
> Best regards
> 
> Heinrich
> 



[Fwd: Fyi: this list, help-glpk, just had it's subject [tag] and footer removed]

2019-10-28 Thread Andrew Makhorin
 Forwarded Message 
From: sysad...@gnu.org
To: help-glpk@gnu.org
Subject: Fyi: this list, help-glpk, just had it's subject [tag] and
footer removed
Date: Thu, 24 Oct 2019 16:17:36 -0400

The Free Software Foundation has changed the GNU Mailman settings on
this list. The short version is that any subject prefix or message
footer has been removed, allowing us to turn off DMARC from munging.
Any list administrator for this list is free to change these settings
back, instructions are below.

The change is to better deal with increased adoption of the DMARC email
standard. The default Mailman settings were causing messages sent from
users with strict DMARC policy domains like yahoo.com to be rejected
when sent to list subscribers by Mailman. See the end of this email for
a technical overview of DMARC and DKIM. There are two main ways to fix
the issue by changing Mailman list settings.

The first option, and the preferable way for discussion lists, is what
we call the "unmodified message fix." There are Mailman list settings
which modify the messages by adding a subject prefix (e.g. [list-name])
or a footer. Modifying the message breaks DKIM message signatures and
thus DMARC, so we just turn those off. Many lists are already this way
and there is no change for them. Instead of using the subject prefix to
identify a list, subscribers should use the List-Id, To, and Cc
headers.
List footer information can also be be put in the welcome email to
subscribers and the list information page by list administrators.

We changed the default for new lists to send unmodified messages, and
are now updating existing discussion lists to the new default. We
emailed all list administrators and moderators and Savannah group
admins
to allow them to opt in to the alternate fix before we made this
change. However, not all lists had a valid administrator contact.

The second option is for lists which want or need to continue to modify
the message, for example with subject prefix or footer settings. In
this
case we turn on a Mailman list setting called dmarc_moderation_action:
"Munge From". With this, if a strict DMARC sender sends to the list, we
alter the headers of that message like so:

A message sent to the list:

From: Anne Example Person 

Is modified by Mailman and sent to subscribers as:

From: Anne Example Person via Alist 
Reply-To: Anne Example Person 

Without going into all of the details, here's a few points about why we
concluded the unmodified message fix is better for discussion
lists. Email clients don't all treat munged messages the same way as
unmunged, and humans read these headers so it can confuse people,
causing messages not to be sent to the expected recipients. GNU Mailman
has an option to do "Munge From" always, but does not recommend using
it[1]. While we're not bound by what others do, it's worth noting that
other very large free software communities like Debian GNU/Linux have
adopted the unmodified message fix[2]. The unmodified messages fix
avoids breaking DKIM cryptographic signatures, which show the message
was authorized by the signing domain and seems like a generally good
security practice. Tools to manage patches, for example patchew, use
the
from field and are tripped up by from munging.

For any Mailman list administrator who wants to change or look over the
relevant settings: The dmarc_moderation_action setting is under
"Privacy
Options" subsection "Sender Filters". The only options that should be
selected are "Accept" or "Munge From", along with corresponding changes
to the subject_prefix option under "General Options", and msg_footer is
under "Non-digest options".

If no list administrators or moderators are around for this list,
anyone
should feel free to try to track them down or figure out who should
become one and explain in detail by replying to sysad...@gnu.org.
Please
be patient, this process may take several weeks.

Please send any questions that should be public to mail...@gnu.org. For
private ones, just reply to sysad...@gnu.org.

For the general announcement of these changes, please read
https://lists.gnu.org/archive/html/savannah-hackers-public/2019-06/msg0
0018.html
and
https://lists.gnu.org/archive/html/savannah-hackers-public/2019-09/msg0
0016.html


A short DMARC technical overview:

DMARC policy is a DNS txt record at a _dmarc subdomain. For example:

$ host -t txt _dmarc.yahoo.com
_dmarc.yahoo.com descriptive text "v=DMARC1; p=reject; pct=100;
rua=mailto:address@hidden;;;

The only important thing there for our purpose is p=reject. p=reject
means that conforming mail servers that receive mail with a from header
of *@yahoo.com will reject that email unless it was either 1. sent from
Yahoo's email servers, or 2. its DKIM signature is verified. A DKIM
signature[5] is a public key cryptographic signature of the email body
and some headers included in the message header "DKIM-Signature". A
verified DKIM signature means that email body and signed headers have
not 

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

2019-04-07 Thread Andrew Makhorin
 Forwarded Message 
From: Reza Rafiee 
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
>  

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


[Help-glpk] [Fwd: Project development]

2019-04-02 Thread Andrew Makhorin
 Forwarded Message 
From: Marc Garcia 
To: help-glpk@gnu.org
Subject: Project development
Date: Tue, 2 Apr 2019 12:02:16 +0100

Hi there,

I'd like to get involved with glpk development, and I found the
information on the website: https://www.gnu.org/software/glpk/ but I'm
used to tools like GitHub, and I don't see how to get started.

Are contributions to the code encouraged? If that's the case, is there
a github repo (or similar) somewhere, or am I expected to download the
latest tar.gz, and send a diff with my changes to the email addresses
mentioned in the website?

I'm happy to help with setting up a repo if there is not one, and there
is interest, just let me know.

Cheers!

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


[Help-glpk] [Fwd: Install problem]

2018-07-18 Thread Andrew Makhorin
 Forwarded Message 
From: Wang, Pengli 
To: help-glpk@gnu.org 
Subject: Install problem
Date: Tue, 17 Jul 2018 21:29:15 +

Hello!

When I try to install the glpk, the cmd said:

C:\Users\wangp>gpg --keyserver keys.gnupg.net --recv-keys 5981E818
gpg: requesting key 5981E818 from hkp server keys.gnupg.net
gpg: key 5981E818: "Andrew Makhorin " not changed
gpg: Total number processed: 1
gpg:  unchanged: 1


C:\Users\wangp>gpg --verify glpk-4.32.tar.gz.sig
gpg: can't open `glpk-4.32.tar.gz.sig'
gpg: verify signatures failed: file open error
Would you mind to give me some suggestions? 

Regards,

Pengli





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


  1   2   3   4   5   6   7   8   9   10   >