For a linear optimization problem I want to include a dataframe (d\_ij) which has binary variables,
1 if customer i is located within the assignable distance of facility j, 0 otherwise. So unless d\_ij = 1, the customer cannot be assigned to a facility.
To create the model, I have introduced a binary variable X\_ij (for customers) and Y\_j (for the facilities)

The dataframe is constructed as follows:

```
#creating distance function
e <- function(i, j) {
  customer <- data[i, ]
  facility <- facility_locations[j, ]
  (sqrt((customer$x - facility$x)^2 + (customer$y - facility$y)^2))
}

#with ifelse function, we model if the distance between consumer and facility is smaller than z =1, 0 otherwise

deltaframe <- data.frame(
  customer=data$ID,
 "j1" =ifelse(e(data$ID, facility_locations$ID==1)<z,1,0),
 "j2" =ifelse(e(data$ID, facility_locations$ID==2)<z,1,0),
 "j3" =ifelse(e(data$ID, facility_locations$ID==3)<z,1,0),
 "j4" =ifelse(e(data$ID, facility_locations$ID==4)<z,1,0),
 "j5" =ifelse(e(data$ID, facility_locations$ID==5)<z,1,0),
 "j6" =ifelse(e(data$ID, facility_locations$ID==6)<z,1,0),
 "j7" =ifelse(e(data$ID, facility_locations$ID==7)<z,1,0),
 "j8" =ifelse(e(data$ID, facility_locations$ID==8)<z,1,0),
 "j9" =ifelse(e(data$ID, facility_locations$ID==9)<z,1,0),
 "j10" =ifelse(e(data$ID, facility_locations$ID==10)<z,1,0),
 "j11" =ifelse(e(data$ID, facility_locations$ID==11)<z,1,0),
 "j12" =ifelse(e(data$ID, facility_locations$ID==12)<z,1,0),
 "j13" =ifelse(e(data$ID, facility_locations$ID==13)<z,1,0),
 "j14" =ifelse(e(data$ID, facility_locations$ID==14)<z,1,0),
 "j15" =ifelse(e(data$ID, facility_locations$ID==15)<z,1,0),
 "j16" =ifelse(e(data$ID, facility_locations$ID==16)<z,1,0),
 "j17" =ifelse(e(data$ID, facility_locations$ID==17)<z,1,0),
 "j18" =ifelse(e(data$ID, facility_locations$ID==18)<z,1,0),
 "j19" =ifelse(e(data$ID, facility_locations$ID==19)<z,1,0),
 "j20" =ifelse(e(data$ID, facility_locations$ID==20)<z,1,0)
)

```

Here z is a parameter, set to be the maximum distance a customer is willing to travel.

The constraint I try to model is
$x\_{ij} <= d\_{ij} \* y\_j $ for all i and for all j

However, I do not know how to include this in r