I'm relatively new to R and try to find a faster way for my problem. I want to do some constraint programming and I have lists, that contains all possible values for each variable. In order to find a feasible solution, I have to do some cuts, which I realize with a lot of loops at the moment. I hope there is a way to do something like "lapply", but I also need to know the related value of another list and don't know, how to do this.
Here's an example:
y=rep(list(rep(list(c(0, 1)), N)), S);
job=-1:J
job=rep(list(rep(list(rep(list(job), J)), N)), S)
for (s in 1:S){
for (n in 1:N){
if (length(y[[s]][[n]])==1 && y[[s]][[n]]==0){
job[[s]][[n]]=rep(list(-1), J);
}
}
}
There are more of these for-loops following and I know that there will be no changes at the beginnig, because y[[s]][[n]] has length 2, but this will be changed during the next steps.
I hope you understand my problem and thank you for answering!