I need to implement an if-statement as a constraint. But, my code continuously gives an error.
'open_house[i]' is a binary variable (1 means 'open' and 0 means 'not open').
'people_to_house[j,i]' is also a binary variable (if person-j is assigned to house-i, then it is 1, otherwise 0)
I want to make 'open_house[i]' equal to 1, if (in every house) the sum of the number of people who are assigned to that house is at least 1. In other words, if there is at least 1 person who is assigned to a house, then we decide to open that house.
The following AMPL code gives me a syntax error. How do you write if-then statements within 'subject to'?
subject to
if (open {i in house}: sum {j in people} people_to_house[j,i] >= 1) then open_house[i] = 1;