Optimizing Network Throughput with Net2Plan and IPOPT

Classified in Design and Engineering

Written on in English with a size of 3.25 KB

Configuring Source Routing and Initializing Routes

To begin, we set the routing type to source routing and clear any existing routes from the design. We then calculate the shortest path for each demand based on the number of traversed links.

/* Set the routing type to source routing */
netPlan.setRoutingType(RoutingType.SOURCE_ROUTING);

/* Remove all the routes in the input design */
netPlan.removeAllRoutes();

/* Create one route for each demand, with the shortest path in number of traversed links */
for (Demand d : netPlan.getDemands()) {
    List<Link> shortestPath = GraphUtils.getShortestPath(netPlan.getNodes(), netPlan.getLinks(), d.getIngressNode(), d.getEgressNode(), null);
    if (shortestPath.isEmpty()) {
        throw new Net2PlanException("A TCP connection cannot be established: the network is not connected");
    }
    netPlan.addRoute(d, 0, 0, shortestPath, null);
}

Defining the Optimization Problem

Next, we initialize the OptimizationProblem object and define the decision variables. We also compute the coefficients for the objective function using the worst-case propagation time.

/* Create the OptimizationProblem object */
OptimizationProblem op = new OptimizationProblem();

/* Add the decision variables of the problem */
final int D = netPlan.getNumberOfDemands();
op.addDecisionVariable("h_d", false, new int[] {1, D}, 0, Double.MAX_VALUE);

/* Compute the vector with the z_d coefficients for the objective function */
final double[] propDelay_d = netPlan.getVectorDemandWorseCasePropagationTimeInMs().toArray();
double[] z_d = new double[D];
for (int d = 0; d < D; d++) {
    z_d[d] = -3 / (2 * Math.pow(propDelay_d[d] * 2, 2));
}
op.setInputParameter("z_d", z_d, "row");

Setting Objective Functions and Constraints

We define the objective to maximize the utility function and add constraints to ensure that the traffic does not exceed the link capacity.

/* Set the objective function */
op.setObjectiveFunction("maximize", "sum (z_d ./ h_d)");

/* Add the link capacity constraints */
for (Link e : netPlan.getLinks()) {
    op.setInputParameter("P_e", NetPlan.getIndexes(e.getTraversingRoutes()), "row");
    op.setInputParameter("u_e", e.getCapacity());
    op.addConstraint("sum(h_d(P_e)) <= u_e");
}

Solving and Applying the Optimal Solution

Finally, we execute the IPOPT solver. If an optimal solution is found, we update the network plan with the carried and offered traffic values.

/* Call the solver */
op.solve("ipopt");

/* If the solver could not find an optimal solution, raise an exception */
if (!op.solutionIsOptimal()) {
    throw new Net2PlanException("An optimal solution was not found");
}

double[] h_d = op.getPrimalSolution("h_d").to1DArray();

/* Save the solution in the netPlan object */
for (Route r : netPlan.getRoutes()) {
    final double traf = h_d[r.getIndex()];
    r.setCarriedTraffic(traf, traf);
    r.getDemand().setOfferedTraffic(traf);
}

return "Ok! Total throughput: " + netPlan.getDemandTotalOfferedTraffic(); // This is the message that will be shown on the screen at the end of the algorithm
}

Related entries: