package no.uis.ux.cipsi.net.monitoringbalancing.solver.move.factory;

import java.util.ArrayList;
import java.util.List;

import no.uis.ux.cipsi.net.monitoringbalancing.domain.MonitoringBalance;
import no.uis.ux.cipsi.net.monitoringbalancing.domain.MonitoringHost;
import no.uis.ux.cipsi.net.monitoringbalancing.domain.Node;
import no.uis.ux.cipsi.net.monitoringbalancing.domain.Switch;
import no.uis.ux.cipsi.net.monitoringbalancing.domain.TrafficFlow;
import no.uis.ux.cipsi.net.monitoringbalancing.domain.WeightedLink;
import no.uis.ux.cipsi.net.monitoringbalancing.solver.move.MonitoringChangeMove;

import org.optaplanner.core.impl.heuristic.move.Move;
import org.optaplanner.core.impl.heuristic.selector.move.factory.MoveListFactory;

import edu.uci.ics.jung.graph.Graph;

public class MonitoringChangeMoveFactory implements MoveListFactory<MonitoringBalance> {

    @Override
    public List<? extends Move> createMoveList(MonitoringBalance solution) {
        List<Move> moveList = new ArrayList<Move>();
        List<Switch> monitoringSwitches = solution.getMonitoringSwitches();
        List<MonitoringHost> monitoringHosts = solution.getMonitoringHosts();
        Graph<Node, WeightedLink> topology = solution.getTopology();
        for (MonitoringHost monitoringHost : monitoringHosts) {
            for (Switch monitoringSwitch : monitoringSwitches) {
                for (TrafficFlow trafficFlow : solution.getTrafficFlows()) {
                    if (trafficFlow.getOnPathMonitoringSwitches().contains(monitoringSwitch)){
                        // System.out.println("MonitoringChangeMoveFactory " + trafficFlow + " " + monitoringSwitch + " " + monitoringHost);
                        moveList.add(new MonitoringChangeMove(topology, trafficFlow, monitoringSwitch, monitoringHost));
                    }
                }
            }
        }

        return moveList;
    }

}

@@ -1246,55 +1246,60 @@
 or (
-MonitoringHost monitoringHost : monitoringHosts
+TrafficFlow trafficFlow : solution.getTrafficFlows()
 ) %7B%0A
@@ -1388,60 +1388,55 @@
 or (
-TrafficFlow trafficFlow : solution.getTrafficFlows()
+MonitoringHost monitoringHost : monitoringHosts
 ) %7B%0A

Change the order of generated moves flow->sw->host