Hi! I’m starting to use AMPL in my research project and I’m still learning about it.

The problem that i have had solving my model with cplexamp is the following: Error executing “solve” command: error processing constraint EACH_RESOURCE[‘K1’]: can’t convert ‘K1’ to a number.

And the part of the .mod file that causes it is the following: set J; set K; subject to EACH_RESOURCE {k in K}: 1 = sum{j in J} k;

I’ve read that maybe is a problem about the declaration of sets, but I’m confused and a little bit lost to be honest.

The “sum” operator can only be applied to numbers. So your immediate problem is that you have written “sum {j in J} k” where k is not a number. Specifically, the message "can’t convert ‘K1’ to a number" suggests that k is equal to the character string “K1”. (Since you defined {k in K}, it must be that “K1” is a member of your set K.)

However, you have a more serious problem, that the expression for your EACH_RESOURCE constraints does not have any variables in it. So you need to give more thought to what this constraint is really supposed to be saying, and what variables should appear in it.