Browse Source

BaseLine GroupNode Option

Tom Troppmann 5 years ago
parent
commit
673c2f4a79
1 changed files with 28 additions and 3 deletions
  1. 28 3
      src/exampleAlgorithms/BaseLine.java

+ 28 - 3
src/exampleAlgorithms/BaseLine.java

@@ -70,6 +70,7 @@ public class BaseLine implements Algorithm {
 	private HashMap<Integer, AccessWrapper> access;
 	private List<Boolean> initialState;
 	private List<HolonSwitch> switchList;
+	private List<HolonObject> objectList;
 	
 	//Gui Part:
 	private Control  control;
@@ -123,7 +124,29 @@ public class BaseLine implements Algorithm {
 		parameterPanel.add(showDiagnosticsLabel);		
 	
 		
+		JPanel borderPanel = new JPanel(null);
+		borderPanel.setBounds(200, 85, 185, 50);
+		borderPanel.setBorder(BorderFactory.createTitledBorder(""));
+		parameterPanel.add(borderPanel);	
 		
+		JLabel showGroupNodeLabel = new JLabel("Use Group Node:");
+		showGroupNodeLabel.setBounds(10, 1, 170, 20);
+		borderPanel.add(showGroupNodeLabel);	
+		
+		JButton selectGroupNodeButton = new JButton("Select GroupNode");
+		selectGroupNodeButton.setEnabled(false);
+		selectGroupNodeButton.setBounds(10, 25, 165, 20);
+		selectGroupNodeButton.addActionListener(actionEvent -> selectGroupNode());
+		borderPanel.add(selectGroupNodeButton);	
+		
+		JCheckBox useGroupNodeCheckBox = new JCheckBox();
+		useGroupNodeCheckBox.setSelected(false);
+		useGroupNodeCheckBox.setBounds(155, 1, 25, 20);
+		useGroupNodeCheckBox.addActionListener(actionEvent -> {
+			useGroupNode = useGroupNodeCheckBox.isSelected();
+			selectGroupNodeButton.setEnabled(useGroupNode);
+		});
+		borderPanel.add(useGroupNodeCheckBox);
 		
 		
 		JCheckBox switchesCheckBox = new JCheckBox();
@@ -298,11 +321,11 @@ public class BaseLine implements Algorithm {
 			for(int inAktiveCount = 0;inAktiveCount <= consumerWihtMaxNumberElements; inAktiveCount++) {
 				println("inAktiveCount:" + inAktiveCount);
 				final int inAktiveCountFinal = inAktiveCount;
-				List<HolonObject> conList = Stream.concat(net.getConsumerList().stream(), net.getConsumerSelfSuppliedList().stream()).map(con -> con.getModel()).filter(object -> (object.getNumberOfInActiveElements() == inAktiveCountFinal)).collect(Collectors.toList());
+				List<HolonObject> conList = Stream.concat(net.getConsumerList().stream(), net.getConsumerSelfSuppliedList().stream()).map(con -> con.getModel()).filter(object -> objectList.contains(object)).filter(object -> (object.getNumberOfInActiveElements() == inAktiveCountFinal)).collect(Collectors.toList());
 				conList.sort((a,b) -> Float.compare(a.getMaximumConsumingElementEnergy(actualIteration), b.getMaximumConsumingElementEnergy(actualIteration)));
 				consumer:
 				for(HolonObject con: conList) {
-					println("Consumer" + con);
+					//println("Consumer" + con);
 					List<HolonElement> sortedElementList = con.getElements().stream().filter(ele -> ele.isActive() && ele.isConsumer()).sorted((a,b) -> -Float.compare(-a.getEnergyAtTimeStep(actualIteration), -b.getEnergyAtTimeStep(actualIteration))).collect(Collectors.toList());
 					for(HolonElement element: sortedElementList) {
 						float elementConsumption = -element.getEnergyAtTimeStep(actualIteration);
@@ -343,7 +366,8 @@ public class BaseLine implements Algorithm {
 	 */
 	private List<Boolean> extractPositionAndAccess() {
 		Model model = control.getModel();
-		switchList = new ArrayList<HolonSwitch>(); 
+		switchList = new ArrayList<HolonSwitch>();
+		objectList = new ArrayList<HolonObject>();
 		initialState = new ArrayList<Boolean>(); 
 		access= new HashMap<Integer, AccessWrapper>();
 		rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getCurIteration());
@@ -362,6 +386,7 @@ public class BaseLine implements Algorithm {
 					positionToInit.add(hE.isActive());
 					access.put(positionToInit.size() - 1 , new AccessWrapper(hE));
 				}
+				objectList.add((HolonObject) aCps);
 			}
 			else if (aCps instanceof HolonSwitch) {
 				HolonSwitch sw = (HolonSwitch) aCps;