1% opt_load_balancing Routing split from a source to a fast and a slow PS
2% server minimizing end-to-end response time (theory fast fraction ~0.743).
3% Mirrors opt_load_balancing.py.
5model = Network(
'LoadBalance');
6source = Source(model,
'S');
7fast = Queue(model,
'Fast', SchedStrategy.PS);
8slow = Queue(model,
'Slow', SchedStrategy.PS);
9sink = Sink(model,
'K');
10jobs = OpenClass(model,
'Jobs');
11source.setArrival(jobs, Exp(2.0));
12fast.setService(jobs, Exp(4.0));
13slow.setService(jobs, Exp(2.5));
14model.addLink(source, fast);
15model.addLink(source, slow);
16model.addLink(fast, sink);
17model.addLink(slow, sink);
19problem = opt.OptimizationProblem(model);
20problem.addVariable(opt.RoutingProbabilities(jobs, source, {fast, slow}));
21problem.setObjective(opt.MinimizeSystemResponseTime(jobs));
23options = opt.LineOptSolverOptions(); options.setSeed(42); options.setMaxIterations(60);
24result = problem.solve(options);
26probs = result.getVariableValue(
'Jobs_routing_from_S');
27fprintf(
'Fraction to Fast: %.3f (theory: 0.743)\n', probs(1));
28fprintf(
'Fraction to Slow: %.3f\n', probs(2));