# [AMPL 24633] remodelation problem

Hello everyone!

I have a problem with a .mod file to solve a study case that I am approaching (using q or k in some variables). I’ll try to explain:

Initail model was (only sets and parameters to understand):

set J;
#centers for resource placement
set Q;
#resource types
set K;
#resources availables

param V {Q, K} binary;
#resource k is of type q

param S{J, K};
#value associated with hazards around j -probability that an aircraft at j will not be used by simultaneous fires (higher for lower risk regions)
param R {I, J, K};
#binary, if resource k to reach area i of placed at point j is in reach, 0 if not
#maybe not binary, just from 0 to 1. = if not reachable, 1 if reachable and withing same area, >1 ansd <0 if it is reachable but further away
param C {K} ;
#capacity of resource K

One of the constraints was defined the following way:

subject to USED {i in I}:

• W * H[i] + sum{j in J, k in K}( R[i,j, k] * x[k, j] * S[j, k] * C[k]) = TC_p[i] - TC_n[i];

The problem is that when i started working on the .dat generation I ended up with hundred of thousands of data lines, so its extremely more efficient and easier for me to programe it so that those variables are a function of Q (I have around 60 K and 5Q). So I changed the model the following way (sets remain the same):

param V {Q, K} binary;
#resource k is of type q

param S{J, Q};
#value associated with hazards around j -probability that an aircraft at j will not be used by simultaneous fires (higher for lower risk regions)
param R {I, J, Q};
#binary, if resource k to reach area i of placed at point j is in reach, 0 if not
#maybe not binary, just from 0 to 1. = if not reachable, 1 if reachable and withing same area, >1 ansd <0 if it is reachable but further away
param C {Q} ;
#capacity of resource K

subject to USED {i in I}:

• W * H[i] + sum{j in J, k in K, q in Q}( R[i, j, q] * x[k, j] * S[j, q] * C[q]) = TC_p[i] - TC_n[i]
;

The problem is that I don’t know how to use the q in the sum so that it gives me the same and correct value for target completion that I was getting with the first model.

I hope I have been capable of explain myself, and I hope that you can help me with this modelation problem.

Thank you,
Juan Antonio.

I guess each resource has one type. Then for each k in K, V[q,k] is all zeros except for a single q where it is 1. This way of representing V contains a lot of unnecessary information, and is hard to work with. Instead you could define

param V {K} in Q; # V[k] is the type of resource k

if Q is a set of numbers, or

param V {K} symbolic in Q; # V[k] is the type of resource k

if Q is a set of character strings. Then if you also have “var x {K,J} >= 0;” the constraint could be written as

subject to USED {i in I}:
- W * H[i] + sum {j in J, k in K} (R[i,j,V[k]] * x[k,j] * S[j,V[k]] * C[V[k]]) = TC_p[i] - TC_n[i];