[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Excessive copies of set elements in GMPL
From: |
Andrew Makhorin |
Subject: |
Re: Excessive copies of set elements in GMPL |
Date: |
Fri, 24 Jul 2020 14:45:42 +0300 |
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 < 1000000; i++)
for (j = 0; j < 1000000; j++)
for (k = 0; k < 1000000; 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, (continued)
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/16
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/16
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/16
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/17
- Re: Excessive copies of set elements in GMPL, Michael Hennebry, 2020/07/21
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/21
- Re: Excessive copies of set elements in GMPL, Michael Hennebry, 2020/07/23
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL,
Andrew Makhorin <=
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/24
- Is this code correct in the GMPL implementation ?, Domingo Alvarez Duarte, 2020/07/25
- Re: Is this code correct in the GMPL implementation ?, Andrew Makhorin, 2020/07/25
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Michael Hennebry, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/25