help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] [Fwd: Implementation problems]


From: glpk xypron
Subject: Re: [Help-glpk] [Fwd: Implementation problems]
Date: Fri, 31 Aug 2012 07:34:20 +0200

Hello Sasch,

GLPK can solve linear optimization problems of type
min{ c^T x; A x <= b} 
Cf. http://en.wikipedia.org/wiki/Linear_programming

It is required that matrix A and vector b are constant.

You try to switch on and of some equations depending on a variable.
This is possible as follows:

s.t. c1{t in Zeiten, c in Krane, i in Aktionen[c]}
X[c,i] + M1 * b[c,i,t] >= x[c,t] >= X[c,i] - M2 * b[c,i,t];

Here b[c,i,t] are binary variables. Of cause you will need additional
constraints to force b[c,i,t] to model continuous time streams.

M1 and M2 should be chosen as small as possible.

abs() is a nonlinear function. Hence the following constraint cannot
exist in a linear program:
s.t. Sicherheitsabstand{c == "G", i in Aktionen, t in {S[i]..S[i]+P["g",i]}} : 
abs(x["K",t]-x["G",t]) >= D
Try to replace the constraint by two linear inequalities using a binary
variable describing if crane K is left or right of crane G.

Best regards

Xypron

-------- Original-Nachricht --------
> Datum: Thu, 30 Aug 2012 23:10:39 +0200
> Betreff: Re: [Help-glpk] [Fwd: Implementation problems]

> Hello Xypron,
> 
> thank you for your prompt reply. I am afraid, that I can't follow
> completely. Can you elaborate?
> 
> Thank you
> Sascha
> 
> 
> 2012/8/30 glpk xypron <address@hidden>
> 
> > Hello Sascha,
> >
> > variables cannot be used to define which row of the problem exists.
> >
> > s.t. Position{c in Krane, i in Aktionen[c], t in
> > {S[c,i]..(S[c,i]+P[c,i])}} : x[c,t] = X[c,i];
> >
> > You could replace S[c,i] by binary variables and use a big M approach.
> >
> > Best regards
> >
> > Xypron
> >
> > > -------- Forwarded Message --------
> > > Subject: Implementation problems
> > > Date: Thu, 30 Aug 2012 03:30:13 +0200
> > >
> > > Hi,
> > >
> > >
> > >
> > >
> > > I am trying to implement a model that is only given to me in a
> > > conceptual form in GUSEK using GLPK.
> > > When I try to solve the following model, I receive an error message
> > > concerning an operand with invalid type.
> > > I was wondering if someone could give me a pointer on how to fix this.
> I
> > > am rather new to GUSEK and GLPK
> > > and your help is highly appreciated.
> > >
> > >
> > > Kind regards.
> > >
> > >
> > >
> > >
> > > Model:
> > >
> > >
> > > set Krane;
> > > set Aktionen {c in Krane};
> > > set Zeiten;
> > >
> > >
> > > param P {c in Krane, i in Aktionen[c]};
> > > param D;
> > > param L;
> > > param X {c in Krane, i in Aktionen[c]};
> > > param V {c in Krane};
> > >
> > >
> > > var S {c in Krane, i in Aktionen[c]} >= 0, integer;
> > > var x {c in Krane, t in Zeiten} >= 0, integer;
> > >
> > >
> > > minimize z: sum{c in Krane} S[c,card(Aktionen[c])];
> > >
> > >
> > > s.t. Reihenfolge{c in Krane, i in {1..card(Aktionen[c])-1}} : S[c,i] +
> > > P[c,i] <= S[c,i+1];
> > > s.t. Position{c in Krane, i in Aktionen[c], t in
> > > {S[c,i]..(S[c,i]+P[c,i])}} : x[c,t] = X[c,i];
> > > s.t. Geschwindigkeit1{t in Zeiten, c in Krane} : x[c,t] - V[c] <=
> x[c,t
> > > +1]
> > > s.t. Geschwindigkeit2 {t in Zeiten, c in Krane} : x[c,t] + V[c] >=
> x[c,t
> > > +1]
> > > s.t. Sicherheitsabstand{c == "G", i in Aktionen, t in
> > > {S[i]..S[i]+P["g",i]}} : abs(x["K",t]-x["G",t]) >= D
> > > s.t. Startposition{c in Krane} : x[c,0] == X[c,0]
> > > s.t. max_Position{t in Zeiten, c in Krane} : x[c,t] <= L
> > > s.t. min_Position{t in Zeiten, c in Krane} : x[c,t] >= 0
> > >
> > >
> > >
> > >
> > >
> > >
> > > data;
> > >
> > >
> > > set Krane := "K" "G";
> > > set Aktionen :=
> > > "K" 1 2 3 4 5 6 7 8 9 10 11 12
> > > "G" 1 2 3 4 5 6 7 8 9 10 11 12;
> > > set Zeiten := {0..900}
> > > param P: 1 2 3 4 5 6 7 8 9 10 11 12:=
> > > "K" 20 20 20 20 20 20 20 20 20 20 20 20
> > > "G" 20 20 20 20 20 20 20 20 20 20 20 20;
> > > param D := 5;
> > > param L := 81;
> > > param X: 1 2 3 4 5 6 7 8 9 10 11 12:=
> > > "K" 2 10 9 14 9 14 9 3 80 6 40 2
> > > "G" 79 5 1 77 77 3 40 41 40 39 80 30;
> > > param V:=
> > > "K" (1/5)
> > > "G" (1/5);
> > > end;
> > >
> > >
> > > Error:
> > > GLPSOL: GLPK LP/MIP Solver, v4.45
> > > Parameter(s) specified in the command line:
> > >  --check --cover --clique --gomory --mir -m Dorndorf.mod
> > > Reading model section from Dorndorf.mod...
> > > Dorndorf.mod:26: operand preceding .. has invalid type
> > > Context: ...n { c in Krane , i in Aktionen [ c ] , t in { S [ c , i ]
> ..
> > > MathProg model processing error
> > > >Exit code: 1    Time: 0.212
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Help-glpk mailing list
> > > address@hidden
> > > https://lists.gnu.org/mailman/listinfo/help-glpk
> >



reply via email to

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