Browse Source

Topologies

Troppmann, Tom 4 years ago
parent
commit
035416dc8f

BIN
exampleNetworks/Topologie.holon


+ 1 - 1
src/addOns/InformationPanel.java

@@ -210,7 +210,7 @@ public class InformationPanel implements AddOn {
 		amountSupplier = dState.getNetworkList().stream().map(net -> net.getAmountOfSupplier()).reduce(0, Integer::sum);
 		amountPassiv = dState.getNetworkList().stream().map(net -> net.getAmountOfPassiv()).reduce(0, Integer::sum);
 		
-		this.amountHolonObjects = amountConsumer + amountSupplier;
+		this.amountHolonObjects = amountConsumer + amountSupplier + amountPassiv;
 		int elements = 0;
 		elements += dState.getNetworkList().stream().map(net -> net.getConsumerList().stream().map(con->con.getModel().getNumberOfElements()).reduce(0, Integer::sum) ).reduce(0, Integer::sum);
 		elements += dState.getNetworkList().stream().map(net -> net.getSupplierList().stream().map(con->con.getModel().getNumberOfElements()).reduce(0, Integer::sum) ).reduce(0, Integer::sum);

+ 47 - 26
src/algorithm/objectiveFunction/TopologieObjectiveFunction.java

@@ -5,14 +5,17 @@ import ui.model.DecoratedHolonObject;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
 import ui.model.DecoratedSwitch;
+
+import java.util.HashSet;
 import java.util.Locale;
 import algorithm.objectiveFunction.GraphMetrics.Graph;
+import api.TopologieAlgorithmFramework.IndexCable;
 
 public class TopologieObjectiveFunction {
 	//Parameters
 	
 	//weight for f_g(H)
-	static double w_eb = .5, w_holon=.1, w_selection = .1, w_grid = .3;
+	static double w_eb = .3, w_max = 0.2, w_holon=.1, w_selection = .1, w_grid = .3;
 	
 	
 	//--> f_eb parameter
@@ -20,7 +23,10 @@ public class TopologieObjectiveFunction {
 	 * Maximum Energie Difference(kappa)
 	 */
 	static double k_eb = 100000.f;
-	
+	/**
+	 * Maximum when all on Energie Difference(kappa)
+	 */
+	static double k_max = 100000.f;
 	
 	//--> f_holon parameter
 	/**
@@ -33,9 +39,10 @@ public class TopologieObjectiveFunction {
 	/**
 	 *  average Maximum Cost for selction(kappa) of switch and elements.
 	 */
-	static double k_selection = 1000;
+	static double k_selection = 4000;
+	
 	static double cost_switch = 10;
-	static double cost_element = 30;
+	private static int cost_of_cable_per_meter = 200;
 	//--> f_grid parameter
 	/**
 	 * The avergae shortest path maximum length -> kappa for the squash function
@@ -51,6 +58,8 @@ public class TopologieObjectiveFunction {
 	 *  {@link TopologieObjectiveFunction#squash}
 	 */
 	static double squash_subtract = 1.0f / (1.f + (float) Math.exp(5.0));
+
+
 	
 	
 	static {
@@ -63,7 +72,7 @@ public class TopologieObjectiveFunction {
 	 * Here should all invariants be placed to be checked on initialization.
 	 */
 	private static void checkParameter() {
-		if(!(Math.abs(w_eb + w_holon + w_selection + w_grid - 1) < 0.001)) {
+		if(!(Math.abs(w_eb + w_holon + w_selection + w_grid + w_max - 1) < 0.001)) {
 			System.err.println("ParameterError in ObjectiveFunction: Sum of all weights should be 1");
 		}
 	}
@@ -78,9 +87,10 @@ public class TopologieObjectiveFunction {
 	 * 
 	 * 
 	 * @param state
+	 * @param moreInformation TODO
 	 * @return f_g value between 0 and 100
 	 */
-	static public float getFitnessValueForState(DecoratedState state) {
+	static public float getFitnessValueForState(DecoratedState state, int amountOfAddedSwitch, double addedCableMeters, boolean moreInformation) {
 		
 		
 
@@ -95,50 +105,60 @@ public class TopologieObjectiveFunction {
 			f_eb += Math.abs(netEnergyDifference);
 		}
 		
+		double f_maximum = 0;
+		for(DecoratedNetwork net : state.getNetworkList()) {
+			final int timestep = state.getTimestepOfState();
+			f_maximum += Math.abs(net.getConsumerList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep)).reduce(0.f, Float::sum));
+			f_maximum += Math.abs(net.getConsumerSelfSuppliedList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep)).reduce(0.f, Float::sum));
+			f_maximum += Math.abs(net.getSupplierList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep)).reduce(0.f, Float::sum));
+		}
+		
+		
 		//calculate f_holon
 		double f_holon = 0;
 		for(DecoratedNetwork net : state.getNetworkList()) {
 			double f_elements_diviation_production = net.getDiviationInProductionInNetworkForHolonObjects();
 			double f_elements_diviation_consumption = net.getDiviationInProductionInNetworkForHolonObjects();
-			double f_flexibility_diviation_consumption = net.getDiviationInFlexibilityConsumption();
-			double f_flexibility_diviation_production = net.getDiviationInFlexibilityProduction();
-			
-			double f_element = f_elements_diviation_production +f_elements_diviation_consumption;
-			double f_flexibility = f_flexibility_diviation_consumption +f_flexibility_diviation_production;
-				
-			f_holon += f_element + f_flexibility ;
+			double f_element = f_elements_diviation_production+f_elements_diviation_consumption;
+			f_holon += f_element;
 		}
 		
 		//calculating f_selection
 		double f_selection = 0;
+		double cost = 0;
 		int amountOfElemetsInWildcard = 0;
 		for(DecoratedNetwork net : state.getNetworkList()) {
 			for(DecoratedHolonObject dHobject : net.getConsumerList()) {
-				if(dHobject.getModel().getObjName().equals("Wildcard")){
-					amountOfElemetsInWildcard += dHobject.getModel().getNumberOfElements();
+				if(dHobject.getModel().getName().contains("Wildcard")){
+					if(dHobject.getModel().getName().length() > 9) {
+						String costString = dHobject.getModel().getName().substring(9);
+						cost += Double.parseDouble(costString);
+					}
 				}
 			}
 			for(DecoratedHolonObject dHobject : net.getConsumerList()) {
-				if(dHobject.getModel().getObjName().equals("Wildcard")){
-					amountOfElemetsInWildcard += dHobject.getModel().getNumberOfElements();
+				if(dHobject.getModel().getName().contains("Wildcard")){
+					if(dHobject.getModel().getName().length() > 9) {
+						String costString = dHobject.getModel().getName().substring(9);
+						cost += Double.parseDouble(costString);
+					}
 				}
 			}
 			for(DecoratedHolonObject dHobject : net.getSupplierList()) {
-				if(dHobject.getModel().getObjName().equals("Wildcard")){
-					amountOfElemetsInWildcard += dHobject.getModel().getNumberOfElements();
+				if(dHobject.getModel().getName().contains("Wildcard")){
+					if(dHobject.getModel().getName().length() > 9) {
+						String costString = dHobject.getModel().getName().substring(9);
+						cost += Double.parseDouble(costString);
+					}
 				}
 			}
 		}
-		f_selection += cost_switch * amountOfElemetsInWildcard;
-		int amountOfAddedSwitch = 0;
-		for(DecoratedSwitch sw : state.getDecoratedSwitches()) {
-			if(sw.getModel().getObjName().equals("AddedSwitch")) {
-				amountOfAddedSwitch++;
-			}
-		}
+		f_selection += cost;
 		f_selection += cost_switch * amountOfAddedSwitch;
 		
 		
+		f_selection += cost_of_cable_per_meter * addedCableMeters;
+		if(moreInformation)System.out.println("CostForWildcards:" + cost + ", CostSwitches(#" + amountOfAddedSwitch +"):" + cost_switch * amountOfAddedSwitch + ", CostCables(" +addedCableMeters+ "m):" + cost_of_cable_per_meter * addedCableMeters);
 		
 		
 		//calculating f_grid
@@ -182,6 +202,7 @@ public class TopologieObjectiveFunction {
 		 * F_grid is already squashed
 		 */
 		return (float) (w_eb * squash(f_eb, k_eb) 
+				+ w_max * squash(f_holon, k_max) 
 				+ w_holon * squash(f_holon, k_holon) 
 				+ w_selection * squash(f_selection, k_selection) 
 				+ w_grid * f_grid);

+ 4 - 2
src/algorithm/topologie/AcoAlgorithm.java

@@ -1,6 +1,7 @@
 package algorithm.topologie;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.TreeSet;
@@ -10,6 +11,7 @@ import algorithm.objectiveFunction.ObjectiveFunctionByCarlos;
 import algorithm.objectiveFunction.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import api.AlgorithmFrameworkFlex.Individual;
+import api.TopologieAlgorithmFramework.IndexCable;
 import ui.model.DecoratedState;
 
 public class AcoAlgorithm extends TopologieAlgorithmFramework {
@@ -32,8 +34,8 @@ public class AcoAlgorithm extends TopologieAlgorithmFramework {
 
 	}
 	@Override
-	protected double evaluateState(DecoratedState actualstate) {
-		return TopologieObjectiveFunction.getFitnessValueForState(actualstate);
+	protected double evaluateState(DecoratedState actualstate, int amountOfAddedSwitch, double addedCableMeters, boolean moreInformation) {
+		return TopologieObjectiveFunction.getFitnessValueForState(actualstate, amountOfAddedSwitch, addedCableMeters, this.moreInformation);
 	}
 
 	@Override

+ 4 - 2
src/algorithm/topologie/GaAlgorithm.java

@@ -1,6 +1,7 @@
 package algorithm.topologie;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.TreeSet;
@@ -10,6 +11,7 @@ import algorithm.objectiveFunction.ObjectiveFunctionByCarlos;
 import algorithm.objectiveFunction.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import api.AlgorithmFrameworkFlex.Individual;
+import api.TopologieAlgorithmFramework.IndexCable;
 import ui.model.DecoratedState;
 
 public class GaAlgorithm extends TopologieAlgorithmFramework {
@@ -41,8 +43,8 @@ public class GaAlgorithm extends TopologieAlgorithmFramework {
 
 	}
 	@Override
-	protected double evaluateState(DecoratedState actualstate) {
-		return TopologieObjectiveFunction.getFitnessValueForState(actualstate);
+	protected double evaluateState(DecoratedState actualstate, int amountOfAddedSwitch, double addedCableMeters, boolean moreInformation) {
+		return TopologieObjectiveFunction.getFitnessValueForState(actualstate, amountOfAddedSwitch, addedCableMeters, this.moreInformation);
 	}
 
 	@Override

+ 4 - 2
src/algorithm/topologie/PsoAlgorithm.java

@@ -1,6 +1,7 @@
 package algorithm.topologie;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.TreeSet;
@@ -10,6 +11,7 @@ import algorithm.objectiveFunction.ObjectiveFunctionByCarlos;
 import algorithm.objectiveFunction.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import api.AlgorithmFrameworkFlex.Individual;
+import api.TopologieAlgorithmFramework.IndexCable;
 import ui.model.DecoratedState;
 
 public class PsoAlgorithm extends TopologieAlgorithmFramework {
@@ -54,8 +56,8 @@ public class PsoAlgorithm extends TopologieAlgorithmFramework {
 	}
 	
 	@Override
-	protected double evaluateState(DecoratedState actualstate) {
-		return TopologieObjectiveFunction.getFitnessValueForState(actualstate);
+	protected double evaluateState(DecoratedState actualstate, int amountOfAddedSwitch, double addedCableMeters, boolean moreInformation) {
+		return TopologieObjectiveFunction.getFitnessValueForState(actualstate, amountOfAddedSwitch, addedCableMeters, this.moreInformation);
 	}
 
 	@Override

+ 62 - 78
src/api/TopologieAlgorithmFramework.java

@@ -93,14 +93,13 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	
 	private HashSet<IndexCable> cableSet = new HashSet<IndexCable>();
 	private ArrayList<IndexCable> cableList = new ArrayList<IndexCable>();
-	private HashSet<IndexCable> addedIndexCable = new HashSet<IndexCable>();
+	private HashMap<IndexCable, Double> addedIndexCable = new HashMap<IndexCable, Double>();
 	private int countForAccessMap = 0;
 	private int amountOfExistingCables = 0;
 	private ArrayList<HolonSwitch> switchList = new ArrayList<HolonSwitch>();
 	private HashMap<HolonSwitch, GroupNode> accessSwitchGroupNode = new HashMap<HolonSwitch, GroupNode>(); 
 	private ArrayList<Edge> edgeList = new ArrayList<Edge>();
 	
-	
 	boolean algoUseElements = false, algoUseSwitches = true, algoUseFlexes = true;
 	
 	//time
@@ -196,6 +195,12 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		
 		JButton runButton =  new JButton("Run");
 		runButton.addActionListener(actionEvent -> {
+			if(runThread.isAlive()) {
+				return;
+			}
+			reset();
+			this.resetAllList();
+			resetChain.clear();
 			Runnable task = () -> run();
 			runThread = new Thread(task);
 			runThread.start();
@@ -461,55 +466,26 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	}
 
 	private double evaluateNetwork() {
-		
-		// Not possible due exponentiak growing
-//		double times = Math.pow(2, switchList.size());
-//		double sum = 0;
-//		for(int i = 0; i < times; i++) {
-//			int positionInBitString = 0;
-//			for(HolonSwitch hSwitch: switchList) {
-//				boolean result = ((i >> positionInBitString++) & 1) != 0;
-//				hSwitch.setManualState(result);
-//			}	
-//			sum += evaluateNetwork() / times;
-//		}
 		runProgressbar.step();
-		//random solution
-//		double sum = 0;
-//		double step = 0.1;
-//		int steppsDone = 0;
-//		for(double actual = 0; actual <= 1 ; actual += step) {
-//			for(HolonSwitch hSwitch: switchList) {
-//				hSwitch.setManualMode(true);
-//				hSwitch.setManualState(Random.nextDouble() < actual);
-//			}
-//			control.calculateStateOnlyForCurrentTimeStep();
-//			DecoratedState actualstate = control.getSimManager().getActualDecorState();
-//			sum += evaluateState(actualstate);
-//			steppsDone++;
-//		}
-		//return sum /(double) steppsDone;
-		
-		double sum = 0;
-		for(HolonSwitch hSwitch: switchList) {
-			hSwitch.setManualMode(true);
-			hSwitch.setManualState(true);
-		}
-		control.calculateStateOnlyForCurrentTimeStep();
-		DecoratedState actualstate = control.getSimManager().getActualDecorState();
-		sum += evaluateState(actualstate);
 		for(HolonSwitch hSwitch: switchList) {
 			hSwitch.setManualMode(true);
 			hSwitch.setManualState(false);
 		}
 		control.calculateStateOnlyForCurrentTimeStep();
-		actualstate = control.getSimManager().getActualDecorState();
-		sum += evaluateState(actualstate);
-		return sum / 2.0;
+		DecoratedState actualstate = control.getSimManager().getActualDecorState();
+		return evaluateState(actualstate, calculateAmountOfAddedSwitches(), addedCableMeter(), false);
 	}
 	
 	
-	protected abstract double evaluateState(DecoratedState actualstate);
+	private double addedCableMeter() {
+		return addedIndexCable.values().stream().reduce(0.0, Double::sum);
+	}
+
+	private int calculateAmountOfAddedSwitches() {
+		return (int)this.switchList.stream().filter(sw -> sw.getName().contains("AddedSwitch")).count();
+	}
+	
+	protected abstract double evaluateState(DecoratedState actualstate, int amountOfAddedSwitch, double addedCableMeter, boolean moreInfromation);
 
 	
 	private void run() {
@@ -662,21 +638,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		if(!resetChain.isEmpty()) {
 			setState(resetChain.removeLast());			
 		}
-		//-->reset
-				accessWildcards.clear();
-				this.countForAccessMap = 0;
-				amountOfExistingCables = 0;
-				accessIntToObject.clear();
-				accessObjectToInt.clear();
-				cableSet.clear();
-				cableList.clear();
-				accessGroupNode.clear();
-				accessIntegerToWildcard.clear();
-				addedIndexCable.clear();
-				switchList.clear();
-				accessSwitchGroupNode.clear();
-				edgeList.clear();
-		//<---
+		resetAllList();
 	}
 
 
@@ -712,21 +674,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	protected List<Integer> extractPositionAndAccess() {
 		Model model = control.getModel();
 		
-		//-->reset
-		accessWildcards.clear();
-		this.countForAccessMap = 0;
-		amountOfExistingCables = 0;
-		accessIntToObject.clear();
-		accessObjectToInt.clear();
-		cableSet.clear();
-		cableList.clear();
-		accessGroupNode.clear();
-		accessIntegerToWildcard.clear();
-		addedIndexCable.clear();
-		switchList.clear();
-		accessSwitchGroupNode.clear();
-		edgeList.clear();
-		//<---
+		resetAllList();
 		Category category = control.searchCategory("Wildcards");
 		if(category != null) {
 			for(int count = 0; count < category.getObjects().size(); count++ ) {
@@ -763,6 +711,29 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		//console.println(cableSet.stream().map(Object::toString).collect(Collectors.f(", ")));
 		return initialState;
 	}
+
+
+
+
+
+
+	private void resetAllList() {
+		//-->reset
+		accessWildcards.clear();
+		this.countForAccessMap = 0;
+		amountOfExistingCables = 0;
+		accessIntToObject.clear();
+		accessObjectToInt.clear();
+		cableSet.clear();
+		cableList.clear();
+		accessGroupNode.clear();
+		accessIntegerToWildcard.clear();
+		addedIndexCable.clear();
+		switchList.clear();
+		accessSwitchGroupNode.clear();
+		edgeList.clear();
+		//<---
+	}
 	
 	
 	
@@ -779,7 +750,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 				HolonObject hO = (HolonObject) aCps;
 				accessIntToObject.put(++countForAccessMap, hO);
 				accessObjectToInt.put(hO, countForAccessMap);
-				if(hO.getName().equals("Wildcard")) {
+				if(hO.getName().contains("Wildcard")) {
 					accessWildcards.add(new AccessWrapper(hO));
 				}
 				if(groupnode != null) {
@@ -848,11 +819,11 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		}
 		IndexCable cable = new IndexCable(index0, index1);
 		//if cable is in existing cables
-		if(cableSet.contains(cable) || addedIndexCable.contains(cable)) {
+		if(cableSet.contains(cable) || addedIndexCable.values().contains(cable)) {
 			return;
 		}
 		generateEdgeFromIndexCable(cable, switchBetween);
-		addedIndexCable.add(cable);
+		addedIndexCable.put(cable, cable.getLength());
 	}
 	
 	private void generateEdgeFromIndexCable(IndexCable cable, boolean switchBetween){
@@ -1109,7 +1080,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		
 	
 	/**
-	 * A Wrapper Class for Access HolonElement and HolonSwitch in one Element and not have to split the List.
+	 * A Wrapper Class to access wildcards
 	 */
 	private class AccessWrapper {
 		int state = 0;
@@ -1121,19 +1092,29 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		public void setState(int state) {
 			if(this.state !=  state) {
 				this.state = state;
-				wildcard.getElements().clear();
 				if(state > 0) {
+					wildcard.getElements().clear();
 					HolonObject hO = (HolonObject)accessIntegerToWildcard.get(state);
 					if(hO == null) {
 						console.println("null set state(" + state + ")");
 					}else {
-						wildcard.getElements().addAll(hO.getElements());											
+						if(hO.getName().contains(":")) {
+							wildcard.setName("Wildcard" + hO.getName().substring(hO.getName().lastIndexOf(":")));
+						}else {
+							wildcard.setName("Wildcard");
+						}
+						wildcard.getElements().addAll(hO.getElements());
+						wildcard.setImage(hO.getImage());
 					}
+				}else {
+					resetState();
 				}
 			}
 		}
 		public void resetState() {
 			state = 0;
+			wildcard.setName("Wildcard");
+			wildcard.setImage("/Images/home-2.png");
 			wildcard.getElements().clear();
 		}
 		
@@ -1313,5 +1294,8 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	    public String toString() {
 			return "{" + first + "," + second + "}";
 	    }
+	    public double getLength() {
+	    	return accessIntToObject.get(first).getPosition().Distance(accessIntToObject.get(second).getPosition());
+	    }
 	}
 }

+ 8 - 128
src/classes/AbstractCanvasObject.java

@@ -2,8 +2,11 @@ package classes;
 
 import com.google.gson.annotations.Expose;
 
-import java.awt.*;
+import java.awt.Color;
 import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * The abstract class "CpsObject" represents any possible object in the system
@@ -27,23 +30,18 @@ public abstract class AbstractCanvasObject {
 	@Expose
 	String image;
 	/* Array of neighbors */
-	ArrayList<Edge> connections;
+	ArrayList<Edge> connections = new ArrayList<>();
 	/* Position with a X and Y value */
 	@Expose
-	Position position;
+	Position position = new Position(0,0);
 	/*
 	 * Energy input and output of each object in the grid Where the Object is
 	 * Stored
 	 */
 	@Expose
 	String sav;
-	/* borderColor the user sets */
-	@Expose
-	Color borderColor = Color.WHITE;
-	/* a Tag that can be used */
-	ArrayList<Integer> tags;
-	/* a Tag that can be used */
-	ArrayList<Integer> pseudoTags;
+	/* tags that can be used */
+	public Set<Integer> tags = new HashSet<Integer>();
 
 	/**
 	 * Constructor for a CpsObejct with an unique ID.
@@ -55,9 +53,6 @@ public abstract class AbstractCanvasObject {
 		setObjName(objName);
 		setName(objName);
 		setImage("/Images/Dummy_House.png");
-		setConnections(new ArrayList<>());
-		tags = new ArrayList<>();
-		pseudoTags = new ArrayList<>();
 	}
 
 	/**
@@ -72,7 +67,6 @@ public abstract class AbstractCanvasObject {
 		setObjName(obj.getObjName());
 		setName(obj.getObjName());
 		setConnections(new ArrayList<>());
-		setPosition(new Position());
 		setId(IdCounter.nextId());
 		setImage(obj.getImage());
 	}
@@ -242,119 +236,5 @@ public abstract class AbstractCanvasObject {
 		this.sav = sav;
 	}
 
-	/**
-	 * Get the color of the border.
-	 * 
-	 * @return the BorderColor
-	 */
-	public Color getBorderColor() {
-		return borderColor;
-	}
-
-	/**
-	 * Set the Border Color of this CpsObject.
-	 * 
-	 * @param c
-	 *            the BorderColor
-	 */
-	public void setBorderColor(Color c) {
-		this.borderColor = c;
-	}
-
-	/**
-	 * For internal purpose (energy flow).
-	 * 
-	 * @param tag
-	 *            for internal purpose
-	 */
-	public void addTag(int tag) {
-		if (!(tags.contains(tag))) {
-			this.tags.add(tag);
-		}
-	}
-
-	public void addAllTags(ArrayList<Integer> tags) {
-		for (Integer tag : tags) {
-			addTag(tag);
-		}
-	}
-
-	/**
-	 * Get the actual tags.
-	 * 
-	 * @return ArrayList
-	 */
-	public ArrayList<Integer> getTag() {
-		return tags;
-	}
-
-	/**
-	 * Rest the tags to Null.
-	 */
-	public void resetTags() {
-		this.tags = new ArrayList<>();
-		this.pseudoTags = new ArrayList<>();
-	}
-
-	/**
-	 * For internal purpose (energy flow).
-	 * 
-	 * @param tags
-	 *            for internal purpose
-	 */
-	public void setTags(ArrayList<Integer> tags) {
-		this.tags = tags;
-	}
-
-	/**
-	 * Get the pseudo tags.
-	 *
-	 * @return ArrayList
-	 */
-	public ArrayList<Integer> getPseudoTags() {
-		return this.pseudoTags;
-	}
-
-	/**
-	 * For internal purpose (energy flow).
-	 *
-	 * @param tags for internal purpose
-	 */
-	public void setPseudoTags(ArrayList<Integer> tags) {
-		this.pseudoTags = tags;
-	}
-
-	/**
-	 * add a pseudo tag.
-	 * 
-	 * @return ArrayList
-	 */
-	public void addPseudoTag(int tag) {
-		if (!pseudoTags.contains(tag)) {
-			pseudoTags.add(tag);
-		}
-	}
-
-	/**
-	 * adds all given pseudotags to the tags
-	 * 
-	 * @param pseudoTags
-	 */
-	public void addAllPseudoTags(ArrayList<Integer> pseudoTags) {
-		for (Integer tag : pseudoTags) {
-			addPseudoTag(tag);
-		}
-	}
-
-	/**
-	 * adds All pseudoTags to tags without duplicates
-	 */
-	public void recalculateTags() {
-		for (Integer tag : pseudoTags) {
-			if (!tags.contains(tag)) {
-				tags.add(tag);
-			}
-		}
-	}
 
 }

+ 12 - 0
src/classes/HolonObject.java

@@ -212,6 +212,18 @@ public class HolonObject extends AbstractCanvasObject {
     	return getElements().stream().filter(element -> element.isOn(flexManager)).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
     }
     
+    
+    public float getMaximumProductionPossible(int timestep) {
+    	return elements.stream().filter(element -> element.getEnergyAtTimeStep(timestep) > 0).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, Float::sum);
+    }
+    public float getMaximumConsumptionPossible(int timestep) {
+    	return elements.stream().filter(element -> element.getEnergyAtTimeStep(timestep) < 0).map(element -> -element.getEnergyAtTimeStep(timestep)).reduce(0.0f, Float::sum);
+    }
+    
+    
+    
+    
+    
     /** 
      * This Method returns the Energy that all HolonElements from the HolonObject produce by itself. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Producer.
      * If the HolonObject have no HolonElement its return 0;

+ 0 - 6
src/ui/controller/LoadController.java

@@ -466,14 +466,9 @@ public class LoadController {
     void initObjects(AbstractCanvasObject obj) {
 
         obj.setConnections(new ArrayList<>());
-        obj.setTags(new ArrayList<>());
-        obj.setPseudoTags(new ArrayList<>());
 
         if (obj instanceof HolonObject) {
             ((HolonObject) obj).setElements(new ArrayList<>());
-
-            ((HolonObject) obj).setTrackingProd(new float[100]);
-            ((HolonObject) obj).setTrackingCons(new float[100]);
         }
 
         if (obj instanceof HolonSwitch) {
@@ -507,7 +502,6 @@ public class LoadController {
      */
     void initCpsEdge(Edge edge) {
         edge.setTags(new ArrayList<>());
-        edge.setPseudoTag(new ArrayList<>());
         edge.setA(null);
         edge.setB(null);
     }

+ 5 - 8
src/ui/view/AddObjectPopUp.java

@@ -156,18 +156,15 @@ public class AddObjectPopUp extends JDialog {
 				}
 			});
 			if (edit) {
-				//TODO: check why this needs a file?
-				/*
-				selectedFile = Util.loadStream(this,obj.getImage());
-				filePath = selectedFile.getAbsolutePath();
-				sourcePath.setText(filePath);
-				ImageIcon icon = new ImageIcon(
-						new ImageIcon(filePath).getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH));
-						*/
 				lblImagePreview.setIcon(new ImageIcon(Util.loadImage(obj.getImage(), 50, 50)));
 			}
 			sourcePath.setBounds(148, 77, 271, 20);
+			if(edit) {
+				this.filePath = obj.getImage();
+				sourcePath.setText(filePath);
+			}
 			contentPanel.add(sourcePath);
+			
 			sourcePath.setColumns(10);
 		}
 		{

+ 18 - 4
src/ui/view/GUI.java

@@ -311,6 +311,8 @@ public class GUI implements CategoryListener {
 	private List<Outliner> outlinerList = new ArrayList<Outliner>();
 	private List<FlexWindow> flexList = new ArrayList<FlexWindow>();
 
+	private JMenuItem removeItem = new JMenuItem("Remove");
+
 	
 	/**
 	 * Create the application.
@@ -1921,6 +1923,7 @@ public class GUI implements CategoryListener {
 		
 
 		popmenuEdit.add(editItem);
+		popmenuEdit.add(removeItem);
 		editItem.setEnabled(false);
 		editItem.addActionListener(actionEvent -> {
 		});
@@ -1998,12 +2001,23 @@ public class GUI implements CategoryListener {
 		editItem.addActionListener(actionEvent -> {
 			// Remove the selected Object object
 			//AddObjectPopUp(boolean edit, AbstractCpsObject obj, String cat, JFrame parentFrame)
+			System.out.println("Edit");
 			addObjectPopUP = new AddObjectPopUp(true, tempCps,
 					catOfObjToBeEdited, holegJFrame);
 			addObjectPopUP.setCategory(catOfObjToBeEdited);
 			addObjectPopUP.setController(controller);
 			addObjectPopUP.setVisible(true);
 		});
+		removeItem.addActionListener(actionEvent -> {
+			// Remove the selected Object object
+			try {
+				System.out.println("catOfObjToBeEdited:" + catOfObjToBeEdited + ", tempCps:" + tempCps);
+				controller.delObjectCategory(catOfObjToBeEdited, tempCps.getName());				
+			}catch(IOException e) {
+				System.err.println("IOException");
+				e.printStackTrace();
+			}
+		});
 		scrollPane1.setViewportView(tree);
 
 		scrollPane1.setColumnHeaderView(panel);
@@ -2667,7 +2681,7 @@ public class GUI implements CategoryListener {
 	 *            the current categories
 	 */
 	private void updateCategories(final ArrayList<Category> categories) {
-		tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(
+		DefaultTreeModel treemodel = new DefaultTreeModel(new DefaultMutableTreeNode(
 				"Categories") {
 
 			private static final long serialVersionUID = 1L;
@@ -2676,8 +2690,7 @@ public class GUI implements CategoryListener {
 				DefaultMutableTreeNode node1;
 				for (Category c : categories) {
 					node1 = new DefaultMutableTreeNode(c.getName());
-
-					// kann eventuell umgeändert werden
+					
 					for (AbstractCanvasObject obj : c.getObjects()) {
 						node1.add(new DefaultMutableTreeNode(obj.getObjName()));
 					}
@@ -2685,7 +2698,8 @@ public class GUI implements CategoryListener {
 				}
 
 			}
-		}));
+		});
+		tree.setModel(treemodel);
 	}
 
 	/**