# Artificial Intelligence Control Logic in Next-Generation Programmable Networks
## 2 Problem Description  
The work has been done in the scope of FlexNet project, where Open Network Operating System (ONOS) controller has been used to control SDN. In ONOS, the concept of intents is used. An intent express a willingness to send a specific amount of data through a network [27]. In the considered architecture, for each registered intent, a pair of paths is computed. The paths are computed immediately after an intent is registered, and the process can take up to a couple of seconds. Then, when a network is in operational state, the AI module described in this paper selects one path from these precomputed paths for each intent. The selection itself has to be fast and prone to the unexpected behaviour of network links and intents. In other words, we face the problem of optimal switching of intents between two previously computed paths. The switching is performed based on an output of an artificial neural network that has been trained to recognize situations and states of the network requiring switching from one path to another. Consider the following sets:  
* edges
* intents
* paths for intent \(i\in\mathcal{I}\)
* edges used on path \(p\in\mathcal{P}\)  
Each intent has its volume defined for each moment in time in the considered time horizon \(<0;T>\). However, the volume is not known in advance. Intents have to be assigned to available paths in a way that minimizes the congestion resulting from the limited capacity of the edges. The volume and the capacities are expressed using the following constants:  
* volume of intent \(i\in\mathcal{I}\) at time \(t\in<0;T>\)
* capacity on edge \(e\in\mathcal{E}\)  
The assignment and the congestion are expressed using the following variables:  
* equals the path intent \(i\in\mathcal{I}\) uses at time \(t\in<0;T>\)
* volume intent \(i\in\mathcal{I}\) is actually sending at time \(t\in<0;T>\) due to congestion  
We express congestion using the following function that depends on the network, loads, and selected routes:  
\[y_{it}= \begin{cases}v_{it}&\forall e\in\mathcal{E}_{x_{it}}\ \sum_{j^{\prime}\in \mathcal{E}_{x_{j}t}}v_{it}\leq c_{e}\\ C(\mathbf{x_{t}},i)&\text{otherwise}\end{cases} \ \ \forall i\in\mathcal{I},\ \forall t\in<0;T>\]  
where \(C(\mathbf{x_{t}},i)\) is a non-trivial function that depends on the network, its current state, and an utilized congestion avoidance algorithm. The actual optimization problem we are solving is as follows:  
\[\max\int_{0}^{T}\sum_{i\in\mathcal{I}}y_{it}\]We notice that even a formally defined problem with unrealistically constant and predictable behaviour of intents and state of links is _NP_-hard, because we can reduce the satisfiability problem (SAT) [28] to it. Therefore, we decided first to decompose the problem to alleviate the computational complexity and second to use artificial neural networks to cope with unexpected behaviour of intents and links. The decomposition consists of considering each intent independently. The considered artificial neural network knows neither an exact topology of SDN nor volumes and paths of all intents. Instead, it is fed with the view of SDN from a point of view of a single intent that consists of the detailed information about the considered intent and the aggregated information about other intents in the vicinity. We developed a system whose conceptual model is presented in Figure 1. First, it collects information about intents registered in ONOS using Intent Monitor and Reroute (IMR) service and standard ONOS API. Then, it collects information about traffic in a network using ifstat, which is an open-source, interface statistics collecting tool that is available in almost all Linux machines. In the next step, it combines this knowledge and creates observations for a randomly selected group of registered intent independently. The computed observations for each selected intent independently enter a neural network that returns two values associated with expected values of q-functions for two possible actions: doing nothing or switching to another path.