## 4 Enhanced Objective Function for Routing in Agricultural Low-Power and Lossy Network
### Scalable Context-Aware Objective Function with Composite Routing Metrics
#### 4.2.3 Context-Aware Objective Function Design  
The RPAL model can capture the targeted attributes of node state, link quality, and indications of connectivity intermittence in an A-LLNs scenario. Essentially, SCAOF gives a fundamental rule that defines how to use context-aware information to calculate rank and preferred parent selection. Thus, SCAOF can manage the initial construction and occasional updating of a RPAL DODAG tree. It is particularly designed by composite routing metric/constraints and this is a highly scalable and flexible approach. Therefore, SCAOF is able to employ standardized MrhOF in a more context-aware manner. A routing topology is expected to assign a more important role to the nodes that can positively reply to the requests from an A-LLN application, through using link-quality-aware and energy-aware metrics to avoid the dangerous nodes to forward sensory data, and improving the network energy balance. SCAOF adopts accumulation, estimation, and prediction techniques over the context from A-LLN sensor nodes to calculate the Instantaneous Suitability _ISi_ of a node \(i\) and decides whether to select this node as a parent based on its survivability in the current RPAL DODAG topology. The survivability can be represented by residual energy, link quality, connectivity (duty-cycle), robustness and available information resource of this optional parent. Furthermore, to fulfill the support of the functions and requirements of wireless multi-media sensor network [37; 66] (WMSN), we propose to use a lexical approach to contain two lexical elements, and the second part is an additive metric composition function, to express the combination of above metrics/constraints:  
\[\text{(Link Color Object,<($\alpha_{1}*$ETX)+($\alpha_{2}*$RE)>$)} \tag{2}\]  
This expression currently only supports the IEEE 802.15.4 low-power communication medium. A-LLN sensor nodes will select their parents with appropriate Link Color Object (LCO), and then, the primary routing metrics ETX and Remaining Energy (RE) will work in the additive manner, for ensuring the QoS and network lifetime requirements. A-LLN sensor nodes will calculate their attributes locally and exchange them via DIOs. Then, each node computes the suitability weights of its neighbors respectively, and decides which one can be the preferred parent. Two LCO rules are defined: to be used as a constraint or as a recorded metric. LCO will bring more flexibility to this metric/constraint composition. We use it to mark whether an endpoint can be a parent or a path is appropriate to forward data packets. As the existence of the first lexical element, the receivers who hear the DIO carrying a LCO will firstly inspect its content. A viable solution of this inspection process is to determine if the suitability values are within the tolerated difference rather than beyond the defined thresholds between two optional nodes or paths. Thus, the first part of the \(IS_{i}\) result can be obtained from the metric/constraint indicated by the counters and \"I\" flag in LCO:  
\[\mathrm{p}_{\mathrm{pref}}(n)=p\in P_{n}|\mathrm{min}[rank(n,p)] \tag{3}\] \[rank(n,p)=rank\left(p,p_{pref}(p)\right)+\alpha_{1}ETX(n,p)+ \alpha_{2}RE(n) \tag{4}\]  
For the second lexical metric, its suitability equation is similar to the aggregation rule of the additive routing metrics, and its results correspond to their weight parameters, which are also the main factors in the rank calculation of SCAOF. Recalling the aforementioned applicability analysis, precision agriculture applications focus particularly on prolonging network lifetime more than maintaining the link reliability. Thus, the parameters \(\alpha_{1}\) and \(\alpha_{2}\) here are (0.4, 0.6) or (0.3, 0.7) which will be more fit for PA applications and represent that the A-LLN sensor nodes tend to choose their parents with more residual energy. A generalized method of rank calculation is illustrated in Equations (3) and (4). It should be noted that different applications have various QoS and constraint requirements.