List the all predecessor and all successor of a tak

Problems with modeling
Post Reply
nilma
User
User
Posts: 1
Joined: 7 years ago

List the all predecessor and all successor of a tak

Post by nilma »

Hi.. i have a precedence diagram of task and i want to list all predecessor and all successor of a task.

here is my data set is GAMS

Sets
I Tasks /i1*i12/

Alias
(I,ai,bi)

Precedence(ai,bi) Precedence Relation /i1.i4, i2.i5, i3.i6, i4.i7, i5.i7, i5.i8, i5.i9, i6.i9, i7.i10, i8.i10, i9.i11, i11.i12/

from this precedence relation, i can get the immediate predecessor from ai, but how can i list out all predecessor and all successor.

let say, i want all predecessor for task i7.. then the all predecessor is i1,i4, and i5. i need to list out all predecessor for each task.
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: List the all predecessor and all successor of a tak

Post by bussieck »

You need to implement some graph search algorithm like BFS or DFS in GAMS to do this. This is clearly possible (see https://www.gams.com/latest/gamslib_ml/ ... b_lop.html) but requires some skill in GAMS programming because the data structures that work best for BFS (and other graph search algorithms) don't exist in GAMS. You can fake these with sets and parameters as done in the example but not very elegantly.

-Michael
Post Reply