Solved

# How to get a variable range subset of a set?

• 8 replies
• 152 views • Enthusiast
• 9 replies

Hi,

I am working on a project of delivery planning.

In my model i have a constraint which defines the Unavailability of a vehicle for some time due to maintenance or already on a delivery. The Time a vehicle becomes unavailable is a parameter.

the constraint is :

Here,

X_v,t → indicator variable for maintenance(whether need to go for maintenance)

S(v) → time required for maintenance of vehicle v

status_v,t → indicator variable for availability of vehicle v on day t

I am unable to write it in AIMMS. how to get the range of tau ?

i was able to get the range for a single value parameter h using SubRange function

tau in SubRange(T, t, t + h)

but for a parameter set S SubRange is not working. Writing S(v) in place of single valued parameter giving me  this error

*There is a mismatch in the master sets of set "T" and domain set "S" in the first argument of the call to intrinsic function "SubRange".

• what could be a possible solution for writing this constraint if S(v) is a parameter Set?
• what if S(v) is a variable set?
icon

Best answer by deannezhang 21 January 2021, 07:39

View original

### 8 replies

Userlevel 4 +1

Instead of using a set with index, i.e. S(v), the convention is to use numerical value, i.e. maintenance_length(v), which indicates the length of maintenance period of v. Then since the period is an ordered set,  condition below will do the same

t<=tau<=t+maintenance_length(v)

Userlevel 4 +1 no, not really. t<= tau <= t+maintenance_length(v)  is not working.

ploblem is occuring when t+maintenance_length(v) is larger than last element of TimePeriod Set, where t is an index of Timeperiod. Instead of using a set with index, i.e. S(v), the convention is to use numerical value, i.e. maintenance_length(v), which indicates the length of maintenance period of v. Then since the period is an ordered set,  condition below will do the same

t<=tau<=t+maintenance_length(v)

t<= tau <= t+maintenance_length(v)  is working partially.

ploblem is occuring when t+maintenance_length(v) is larger than last element of TimePeriod Set, where t is an index of Timeperiod.

Userlevel 4 +1

what problem do you encounter? I would have a look if you share it here. what problem do you encounter? I would have a look if you share it here.

it was giving erroneous result, not as I expected.

But i was able to fix it by slightly modifying your approach.

i rewrote the condition as, t <= tau <= t + min{ maintenance_length(v), (Last(Timeperiod) - t) }

and now its giving expected result.

Thanks for helping me to resolve this issue.

Userlevel 4 +1

if tau is an index of set TimePeriod, the min function tau <= t +  maintenance_length(v) should work, since it won’t go over the bound. I don’t know why it doesn’t work in your case, but I’m glad you make it work.