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 (TrafficFlow trafficFlow : solution.getTrafficFlows()) {
            for (Switch monitoringSwitch : monitoringSwitches) {
                for (MonitoringHost monitoringHost : monitoringHosts) {
                    //                    System.out.println("MonitoringChangeMoveFactory " + trafficFlow + " " + monitoringSwitch + " " + monitoringHost);
                    moveList.add(new MonitoringChangeMove(topology, trafficFlow, monitoringSwitch, monitoringHost));
                }
            }
        }

        return moveList;

        //        List<CloudComputer> cloudComputerList = cloudBalance.getComputerList();
        //        for (CloudProcess cloudProcess : cloudBalance.getProcessList()) {
        //            for (CloudComputer cloudComputer : cloudComputerList) {
        //                moveList.add(new CloudComputerChangeMove(cloudProcess, cloudComputer));
        //            }
        //        }
        //        return moveList;
    }

}

@@ -115,16 +115,84 @@
 .List;%0A%0A
+import no.uis.ux.cipsi.net.monitoringbalancing.app.TopologyManager;%0A
 import n
@@ -1301,81 +1301,8 @@
 ();%0A
-        for (TrafficFlow trafficFlow : solution.getTrafficFlows()) %7B%0A    
     
@@ -1366,28 +1366,24 @@
             
-    
 for (Monitor
@@ -1438,31 +1438,207 @@
             
-    // 
+for (TrafficFlow trafficFlow : solution.getTrafficFlows()) %7B%0A                    if (TopologyManager.isSwitchOnPath(solution.getTopology(), trafficFlow.getPath(), monitoringSwitch))%7B%0A
             
@@ -1643,16 +1643,24 @@
         
+      //
  System.
@@ -1778,32 +1778,36 @@
                 
+    
 moveList.add(new
@@ -1883,24 +1883,46 @@
 ringHost));%0A
+                    %7D%0A
             

Change the order of created Moves such that all flows will be assigned with a prelimenary monitoring switch host pair that is valid.