help-glpk
[Top][All Lists]
Advanced

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

Re: Solver delivers wrong answer when 2 constraints are close


From: Domingo Alvarez Duarte
Subject: Re: Solver delivers wrong answer when 2 constraints are close
Date: Fri, 5 Mar 2021 11:39:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Using LP_SOLVE as solver with glpsol (experimental) also produce the stated expected value for "min_bound = 1e-09":

====

glpsol --lpsolve -m test_1e_4_2.mod
GLPSOL: GLPK LP/MIP Solver, v4.65-ex, glp_double size 8
Parameter(s) specified in the command line:
 --lpsolve -m test_1e_4_2.mod
Reading model section from test_1e_4_2.mod...
15 lines were read
test_1e_4_2.mod:19: warning: unexpected end of file; missing end statement inserted
19 lines were read
Generating y...
Generating LIM_INF_X...
Generating PART_MIN_X...
Solve callback called

Model name:  'test_1e_4_2' - run #1   
Objective:   Minimize(y)
 
SUBMITTED
Model size:        2 constraints,       1 variables,            2 non-zeros.
Sets:                                   0 GUB,                  0 SOS.
 
Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
The primal and dual simplex pricing strategy set to 'Devex'.
 
 
Optimal solution         1.000000001 after          2 iter.

Relative numeric accuracy ||*|| = 0

 MEMO: lp_solve version 5.5.2.5 for 64 bit OS, with 64 bit REAL variables.
      In the total iteration count 2, 0 (0.0%) were bound flips.
      There were 0 refactorizations, 0 triggered by time and 0 by density.
       ... on average 2.0 major pivots per refactorization.
      The largest [LUSOL v2.2.1.0] fact(B) had 3 NZ entries, 1.0x largest basis.
      The constraint matrix inf-norm is 1, with a dynamic range of 1.
      Time to load data was 0.001 seconds, presolve used 0.000 seconds,
       ... 0.000 seconds in simplex solver, in total 0.001 seconds.
Model has been successfully processed
Display statement at line 16
min_bound = 1e-09
Display statement at line 17
x.val = 1.000000001
Model has been successfully generated

====

On 4/3/21 18:19, Thiago Neves wrote:
Thank you so much for the explanation Antti. 
You are right, this seems more like a "design flaw" than a "bug". I'm sorry for the misconception.

Why does "eps" need to be so big (1e-3)? Is there a way to set a fixed threshold in the command line (glpsol) or at least the 1e-3 part?

In the case (1), wouldn't it be better to choose max(l[q], l'[q])? 

Att,

Thiago H. Neves
(31) 98608-0666



---------- Forwarded message ---------
De: Antti Lehtila <antti.lehtila@vtt.fi>
Date: qui., 4 de mar. de 2021 às 12:44
Subject: Re: Solver delivers wrong answer when 2 constraints are close
To: <help-glpk@gnu.org>


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

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

Best,
Antti
_______________________
On 04.03.2021 11:38, Domingo Alvarez Duarte wrote:
>
> Testing this problem I discover that if we change the order of
> constraint declarations it seems to give the expected answer as stated
> by Thiago (what I think could be another bug).
>
> ====
>
> /param min_bound default 0;/
> /var x >= 0;
>
> minimize y: x;/
> *
> */*s.t. PART_MIN_X: x >= 1 + min_bound;*
> /
> /*s.t. LIM_INF_X: x >= 1;
> *
> /
> /solve;
> display min_bound;
> display x; # EXPECTED RESULT: X ==  1.0001
>
> data;
> param min_bound := 1e-4;
> end;/
>
> ====
>
> Output:
>
> ====
>
> x.val = 1.0001
>
> ====
>
> On 3/3/21 19:19, Thiago Neves wrote:
>> Hi.
>> I've found a strange behaviour in glpk which I don't know how to fix
>> nor how to contour it. It seems like GLPK can't distinguish
>> constraints that differs from about 1e-4.
>>
>> Follows simple examples that explain and reproduce the problem.**
>> *
>> *
>> *The first model gives the desired answer (x = 1.0001):*
>> /
>> param min_bound default 0;/
>> /var x >= 0;
>>
>> minimize y: x;/
>> /*
>> s.t. PART_MIN_X: x >= 1 + min_bound;*
>>
>> solve;
>> display min_bound;
>> display x; # EXPECTED RESULT: X ==  1.0001
>>
>> data;
>> param min_bound := 1e-4;
>> end;
>> /
>> /_____________________________________/
>> /OUTPUT:/
>> /x.val = 1.0001/
>> /_____________________________________ /
>>
>> *Now, if I add a second constraint "close" to the first one, the
>> solver will deliver an answer that is actually infeasible:*
>>
>> /param min_bound default 0;/
>> /var x >= 0;
>>
>> minimize y: x;/
>>
>> *s.t. LIM_INF_X: x >= 1;
>>
>> */*s.t. PART_MIN_X: x >= 1 + min_bound;*
>>
>> solve;
>> display min_bound;
>> display x; # EXPECTED RESULT: X ==  1.0001
>>
>> data;
>> param min_bound := 1e-4;
>> end;/
>> /_____________________________________/
>> /OUTPUT:/
>> x.val = 1
>> /_____________________________________ /
>>
>> *If I change the "min_bound" parameter to 1e-2, the second model
>> works as expected (x = 1.01):*
>>
>> /param min_bound default 0;/
>> /
>> /
>> /var x >= 0;
>>
>> minimize y: x;/
>> *
>> *
>> *s.t. LIM_INF_X: x >= 1;
>>
>> */*s.t. PART_MIN_X: x >= 1 + min_bound;*
>>
>> solve;/
>> /
>> display x; # EXPECTED RESULT: X ==  1.01
>>
>> data;
>> param min_bound := 1e-2;
>> end;/
>> /_____________________________________/
>> /OUTPUT:/
>> x.val = 1.01
>> /_____________________________________ /
>> /
>> /
>>
>> Att,
>>
>> *Thiago H. Neves*
>> (31) 98608-0666
>>



reply via email to

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