bug-glpk
[Top][All Lists]
Advanced

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

[Bug-glpk] lpx_write_lp


From: Bernhard Schmidt
Subject: [Bug-glpk] lpx_write_lp
Date: Tue, 23 Sep 2003 17:33:12 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.0.2) Gecko/20030208 Netscape/7.02

Probably
char *set = "!\"#$%&()/,.;address@hidden'{}|~";   /* may appear in names */
(line 206 of glplpx.c of GLPK 4.1)
should be replaced by
char *set = "!\"#$%&()/,.;address@hidden'{}|~[]";   /* may appear in names */

Otherwise it happens often that original names of columns and rows
defined in GNU MathProg files can not be written into CPLEX LP files.
These names often contain "[" and "]" because of indexing.

Example:

#include <stdio.h>
#include <stdlib.h>
#include "glpk.h"
int main(void)
{ LPX *lp; lp=lpx_read_model("c:\\Maschinen.mod",NULL,NULL); //Replace "c:\\Maschinen.mod" by appropriate path on your machine
   lpx_set_int_parm(lp,LPX_K_LPTORIG,1);
   lpx_write_lpt(lp,"c:\\Maschinen.lp");
          //Replace "c:\\Maschinen.lp" by appropriate path on your machine
return 0; }

The file Machinen.mod is attached.

Bernhard Schmidt


# Ein Maschinenbelegungsproblem
#
# Für eine Reihe zur Verfügung stehender Maschinen sollen die Mengen der zu
# fertigenden Teile berechnet werden. Dabei sind beschränkte
# Maschinenkapazitäten und zu produzierende Höchstmengen zu berücksichtigen.
# Ziel ist, den Gewinn zu maximieren.

set MASCHINEN;
/* zur Verfügung stehende Maschinen */

set PRODUKTE;
/* zu fertigende Produkte */

/* Parameter */

param t{p in PRODUKTE, m in MASCHINEN};
/* Anzahl der Zeiteinheiten, die zum fertigen des Produkts p auf der Maschine
   m benötigt werden */

param T{m in MASCHINEN};
/* Anzahl Zeiteinheiten, die die Maschine m einsatzbereit ist */

param M{p in PRODUKTE};
/* Maximale Stückzahl, die vom Produkt p verkauft werden kann */

param g{p in PRODUKTE};
/* Gewinn beim Verkauf eines Exemplars des Produkt p */


/* Variablen */

var x{p in PRODUKTE, m in MASCHINEN} integer >= 0;
/* Anzahl der Produkte vom Typ p, die auf der Maschine m gefertigt werden */


/* Zielfunktion */

maximize Gewinn: sum{p in PRODUKTE, m in MASCHINEN} g[p] * x[p,m];
/* Gesamtgewinn soll möglichst groß werden */

/* Restriktionen */

s.t. Bestand{m in MASCHINEN}: sum{p in PRODUKTE} t[p,m] * x[p,m] <= T[m];
/* Maximale Betriebszeit einer Maschine im Betrachtungszeitraum */

s.t. MaxMenge{p in PRODUKTE}: sum{m in MASCHINEN} x[p,m] <= M[p];
/* Maximale Menge eines Produkts, die verkauft werden kann */



data;

set MASCHINEN := M1 M2 M3;

set PRODUKTE := P1 P2 P3 P4;


param t :         M1   M2   M3 :=
           P1     10   12   15
           P2     25   30   30
           P3     35   33   40
           P4     40   50   50
                   ;

param T := M1     2400
           M2     2200
           M3     2000
           ;

param M := 
           P1     100
           P2     130
           P3     35000
           P4     40000
                   ;

param g := 
           P1     2.00
           P2     4.50
           P3     5.00
           P4     7.00
                   ;


end;

reply via email to

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