jeudi 7 mai 2020

GLPK break in for cycle

I would like to write a condition in for cycle after the solve command in GPLK. The if statement should either print something and break or pass. And if it is last iteration of for cycle print something anyway.

#some program with vars x[i, j] 

solve;
for {i in Vertices}
{
    for {j in Vertices: j <= i}
    {
       if (x[j, i] = 1) then printf ("v_%d %d \n", i, j) break;
       printf (if (i = j) then "v_%d %d \n" else ""), i, j;
    }
}

The problem is that I don't know if there is any kind of break because I haven't find it and there is problem even in this line:

if (x[j, i] = 1) then printf ("v_%d %d \n", i, j);
invalid use of reserved keyword if

What am I doing wrong? Or there is no option to write such a if and printf something in there?

Aucun commentaire:

Enregistrer un commentaire