Re: Multi problems in GMPL
Domingo Alvarez Duarte <[email protected]> Thu, 27 Aug 2020 00:01:30 +0200
| Newsgroups | gmane.comp.gnu.glpk |
|---|---|
| Message-ID | <[email protected]> |
Hello !
Meanwhile I implemented only the parsing/display of problem statement
like ampl but without domains.
https://github.com/mingodad/GLPK/blob/local-set-param/examples/cut2.mod
Output:
====
./glpsol --genonly -m cut2.mod
>./glpsol --genonly -m cut2.mod
GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
--genonly -m cut2.mod
Reading model section from cut2.mod...
Reading data section from cut2.mod...
107 lines were read
Checking (line 14)...
Generating Number...
Generating Fill...
Generating Reduced_Cost...
Generating Width_Limit...
Display statement at line 39
problem Cutting_Opt: Cut, Number, Fill;
problem Pattern_Gen: Use, Reduced_Cost, Width_Limit;
problem Mix: Cut, Reduced_Cost;
Model has been successfully generated
>Exit code: 0
====
Cheers !
On 26/8/20 19:57, Domingo Alvarez Duarte wrote:
> Hello !
>
> Thinking in how to have multiple problem in GMPL I'm asking for other
> user opinions about how that could be expressed, one example can be
> like the one bellow where we have common elements and namespaced
> problems.
>
> If you have any other idea that you want to share let me know !
>
> ====
>
> param roll_width;
> set WIDTHS;
>
> problem Cutting_Opt {
> # ----------------------------------------
> param nPAT integer >= 0, default 0;
> set PATTERNS := 1..nPAT;
> param orders {WIDTHS} > 0;
> param nbr {WIDTHS,PATTERNS} integer >= 0;
>
> check {j in PATTERNS}: sum {i in WIDTHS} i * nbr[i,j] <= roll_width;
>
> var Cut {PATTERNS} integer >= 0;
>
> minimize Number: sum {j in PATTERNS} Cut[j];
>
> subject to Fill {i in WIDTHS}:
> sum {j in PATTERNS} nbr[i,j] * Cut[j] >= orders[i];
> }
>
> problem Pattern_Gen {
> # ----------------------------------------
> param price {WIDTHS} default 0;
>
> var Use {WIDTHS} integer >= 0;
>
> minimize Reduced_Cost:
> 1 - sum {i in WIDTHS} price[i] * Use[i];
>
> subject to Width_Limit:
> sum {i in WIDTHS} i * Use[i] <= roll_width;
> }
> solve Cutting_Opt;
> solve Pattern_Gen;
>
> ====
>
> Cheers !
>