# Step 12: Compile the grid search model: compile_model(grid_search_model)
#### 2.4.3 Optimal Route  
In the given context, a set \(X\) is provided which contains prohibited routes. A route \((v_{1},\ldots,v_{l})\) is considered avoided from set \(A\) if none of its subroutes \(\left(v_{i},\ldots,v_{j}\right)\) are included in set \(A\), for any pair \(i\) and \(j\) where \(1\leq i<j\leq l\). When discussing the shortest route that avoids set \(A\), a route \(P\) from \(s\) to \(t\) is considered the shortest if the distance traveled along route \(P\) is the shortest among all routes that avoid set \(A\) when traveling from \(s\) to \(t\). In the specific case where set \(A\) is equal to set \(X\), which represents all the forbidden routes in the graph, the term \"exception avoiding\" is used instead of \"\(X\)-avoiding\" in this context. It is also crucial to ensure that the request point does not fall on any prohibited route. Each vehicle used in this model will strictly avoid traveling through any of the forbidden routes, adhering to the imposed restrictions and constraints. Notation:  
\(R\): Set of resources used  
C: Set of customers  
\(X\): Set of forbidden route  
Variables:  
\(\ddagger_{1}(D)\): Cost and time of arc \((i,j)\)  
\(x_{ij}\): Binary variable indicating whether arc \((i,j)\) is used in the route or not \(d^{+}(i)\): The set of arcs comes out of vertex \(i\)  
\(d^{-}(i)\): The set of arcs enters node \(i\)  
\(T^{r}_{ij}\): The time required to travel from node \(j\) to node \(i\) uses resource \(r\)  
\(a^{r}_{i}\) and \(b^{r}_{i}\): The initial time limit and the final time limit to start the journey from node \(i\) using resources \(r\). Formulation  
\[\min\sum\limits_{(i,j)\in A;(i,j)\
otin}P_{1}x_{ij} \tag{7}\]  
Subject to:  
\[\sum\limits_{(s,j)\in d^{+}(i)}x_{ij}=1\forall i\in C,i\
otin X \tag{8}\]  
\[\sum\limits_{(s,j)\in d^{-}(i)}x_{ij}=\sum\limits_{(s,j)\in d^{+}(i)}x_{ij}i \
otin X,\forall i\
otin V \tag{9}\]  
\[\sum\limits_{(s,j)\in d^{-}(i)}\left(T^{r}_{ji}+t^{r}_{ji}x_{ij}\right)\leq \sum\limits_{(s,j)\in d^{+}(i)}T^{r}_{ji}i\
otin X,\forall r\in R,\forall i\in C \tag{10}\]  
\[a^{r}_{i}x_{ij}\leq T^{r}_{ji}\leq b^{r}_{i}x_{ij}(i,j)\
otin X,\forall r\in R,\forall(i,j)\in A \tag{11}\]  
\[T^{r}_{ij}\geq 0(i,j)\
otin X,\forall r\in R,\forall(i,j)\in A \tag{12}\]  
\[x_{ij}\in\{0,1\}(i,j)\
otin X,\forall(i,j)\in A \tag{13}\]  
Constraint (8) ensures that each demand point is visited exactly once in the transportation route. Constraint (9) maintains flow balance by ensuring that the number of outgoing arcs at each node is equal to the number of incoming arcs. Constraint (10) imposes a time limit, stating that the travel time from node \(j\) to node \(i\) using resource \(r\) cannot exceed the travel time from node \(i\) to node \(j\). Constraints (11) specify the start and end times that must be adhered to for transportation activities. Constraint (12) sets a minimum value of 0 for the set time, indicating that transportation activities cannot occur before time 0. Constraint (13) is a binary decision variable, taking on values of 0 or 1, and is used to include or exclude certain variables or conditions in the model. Where \(\sharp_{1}(D)\) is bi-objective, defined as:  
\[\sharp_{1}(D)=\{w,h\} \tag{14}\]  
\[w=\sum\limits_{j\in C_{2}}\sum\limits_{k=1}^{K}t_{jk} \tag{15}\]  
\[ \begin{array}{c}h=\sum\limits_{i\in C_{1}}SC_{i}x_{i}+UC\sum\limits_{a\in C }\sum\limits_{b\in C}\sum\limits_{k=1}^{K}Len_{ab}\sharp_{abk}+\sum\limits_{i \in C_{1}}\sum\limits_{k=1}^{K}FC_{k}y_{ik}\\ +pdemand\sum\limits_{j\in C_{2}}max\{D_{j}-q_{j},0\}+p^{supply}\sum\limits_{j \in C_{2}}max\{q_{j}-D_{j},0\}\end{array}  \tag{16}\]  
Equation (14) introduces two objective functions: the minimization of the total system cost \((h)\) and the minimization of the time \((w)\) taken for vehicles to reach the demand points. The total system cost includes various components such as the cost of establishing a DC, fixed vehicle operating costs, vehicle travel costs, and penalties for shortages and excess supply.