I am facing problems generating a loop in Ruby that is to be pushed to a GAMS include file. It should display each tuple of a c(i,j) vector, for all i and j, i. e.
Parameter c(i,j) /
c('i1','j1')=[value];
c('i1','j2')=[value];
.
.
.
c('iI','jJ')=[value];
/
The problem is, that there are three entities to fetch data from, so that I struggle to identify the respective distance between warehouses and clients. This is the loop so far:
printf(f, "Parameter c(i,j) / \n")
@warehouses.each { |wh| printf(f, "c('i" + wh.id.to_s + "',") +
@clients.each { |cl| printf(f, "'j" + cl.id.to_s + "')=") +
@transquans.distance.to_s(@warehouses, @clients) + "; \n"
}
}
The structure behind that is uploaded here.
The error message returned is like this: “undefined method `distance’ for nil:NilClass”.
It’s solved by now!