Przeglądaj źródła

Merge branch 'updateInProgress' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git into updateInProgress

Rolf Egert 4 lat temu
rodzic
commit
a4b676bdc7

+ 7 - 7
exampleNetworks/RandomizerExample/elements.json

@@ -33,7 +33,7 @@
         "maxAmount" : 1,
         "priority" : "Essential",
         "energy" : -450.0,
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 300,
 	    "maxCost" : 400,
 	    "minDuration" : 1,
@@ -47,7 +47,7 @@
         "maxAmount" : 1,
         "priority" : "Low",
         "energy" : -300.0,
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 100,
 	    "maxCost" : 200,
 	    "minDuration" : 1,
@@ -61,7 +61,7 @@
         "maxAmount" : 1,
         "priority" : "Medium",
         "energy" : -1300.0,
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 200,
 	    "maxCost" : 250,
 	    "minDuration" : 1,
@@ -89,7 +89,7 @@
         "maxAmount" : 1,
         "energy" : -500.0,
         "priority" : "Low",
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 50,
 	    "maxCost" : 100,
 	    "minDuration" : 1,
@@ -103,7 +103,7 @@
         "maxAmount" : 1,
         "priority" : "Low",
         "energy" : 2000.0,
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 120,
 	    "maxCost" : 300,
 	    "minDuration" : 1,
@@ -124,7 +124,7 @@
         "maxAmount" : 1,
         "energy" : -2000.0,
         "priority" : "Medium",
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 200,
 	    "maxCost" : 350,
 	    "minDuration" : 1,
@@ -138,7 +138,7 @@
         "maxAmount" : 1,
         "priority" : "Low",
         "energy" : -2500.0,
-        "flexChance" : 0.5,
+        "flexChance" : 0.95,
 	    "minCost" : 100,
 	    "maxCost" : 250,
 	    "minDuration" : 1,

+ 0 - 0
src/exampleNetworks/_solved_variable_hugeassgrid_new.holon → exampleNetworks/_solved_variable_hugeassgrid_new.holon


+ 0 - 0
src/exampleNetworks/holonsplitSP.holon → exampleNetworks/holonsplitSP.holon


+ 0 - 0
src/exampleNetworks/hugeassgrid.holon → exampleNetworks/hugeassgrid.holon


+ 0 - 0
src/exampleNetworks/hugeassgridsolved.holon → exampleNetworks/hugeassgridsolved.holon


+ 0 - 0
src/exampleNetworks/inhomogen_grid.holon → exampleNetworks/inhomogen_grid.holon


BIN
exampleNetworks/scenario1600flex.holon


+ 0 - 0
src/exampleNetworks/test.holon → exampleNetworks/test.holon


+ 0 - 0
src/exampleNetworks/testbig.holon → exampleNetworks/testbig.holon


+ 0 - 0
src/exampleNetworks/testholonsplit-grp.holon → exampleNetworks/testholonsplit-grp.holon


+ 0 - 0
src/exampleNetworks/testholonsplit.holon → exampleNetworks/testholonsplit.holon


+ 0 - 0
src/exampleNetworks/variable_hugeassgrid.holon → exampleNetworks/variable_hugeassgrid.holon


+ 0 - 0
src/exampleNetworks/variable_hugeassgrid_new.holon → exampleNetworks/variable_hugeassgrid_new.holon


Plik diff jest za duży
+ 12 - 0
plottAcoAlgo.txt


+ 1 - 0
src/api/AlgorithmFrameworkFlex.java

@@ -759,6 +759,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 		}
 		public void stop() {
 			isActive = false;
+			progressBar.setValue(0);
 		}
 		public JProgressBar getJProgressBar(){
 			return progressBar;

+ 14 - 0
src/classes/CpsEdge.java

@@ -24,6 +24,20 @@ public class CpsEdge {
     AbstractCpsObject a;
     // Destination
     AbstractCpsObject b;
+    
+    
+    
+    
+    
+    /**
+     * Getter for the length of the Cable.
+     * Always calculate never saved.
+     * Needs to be profiled whats better.
+     * @return
+     */
+    public float getLength() {
+    	return (float)a.getPosition().Distance(b.getPosition());
+    }
 
     @Expose
     private boolean breakedManuel = false;

+ 1 - 1
src/classes/HolonObject.java

@@ -6,7 +6,7 @@ import ui.controller.FlexManager;
 
 import java.util.ArrayList;
 
-
+
 
 /**
  * The class HolonObject represents any Object on the system which capability of

+ 4 - 0
src/ui/controller/FlexManager.java

@@ -24,6 +24,7 @@ public class FlexManager {
 	private List<Flexibility> allFlexesOrderedThisTimeStep = new ArrayList<Flexibility>();
 	private HashMap<Flexibility, FlexWrapper> accessFlexMap = new HashMap<Flexibility, FlexWrapper>();
 	public FlexManager(Model model, int timeStep, FlexManager timestepBefore){
+		//Thread.dumpStack();
 		this.timeStep = timeStep;
 		allFlexModels = getAllFlexFromModel(model);
 		//fill accessFlexMap
@@ -164,4 +165,7 @@ public class FlexManager {
 		}
 		
 	}
+	public void reset() {
+		getAllFlexWrapper().forEach(flexWrapper -> flexWrapper.cancel());
+	}
 }

+ 39 - 12
src/ui/controller/SimulationManager.java

@@ -29,7 +29,7 @@ import java.util.List;
 import java.util.ListIterator;
 
 import javax.swing.JPanel;
-
+
 
 /**
  * Controller for Simulation.
@@ -71,14 +71,14 @@ public class SimulationManager {
 	 * @param updateVisual TODO
 	 */
 	public void calculateStateForTimeStep(int timestep, boolean updateVisual) {
-		FlexManager newFlexManager = new FlexManager(model, timestep, savesFlexManger.getOrDefault(timestep-1, null));
-		//Actual ordered not delete:
-		FlexManager flexManagerFromActual = savesFlexManger.getOrDefault(timestep, null);
-		if(flexManagerFromActual != null) {
-			newFlexManager.orderFlexFromList(flexManagerFromActual.getAllFlexesOrderedThisTimeStep());
-		}
-		savesFlexManger.put(timestep, newFlexManager);
 		
+//		long startTime = System.currentTimeMillis(), endTime;
+		boolean doesFlexManagerExist = savesFlexManger.containsKey(timestep);
+		FlexManager newFlexManager = doesFlexManagerExist? savesFlexManger.get(timestep): new FlexManager(model, timestep, savesFlexManger.get(timestep-1));
+		if(!doesFlexManagerExist) savesFlexManger.put(timestep, newFlexManager);
+//		endTime = System.currentTimeMillis();
+//		System.out.print(" a:" + (endTime - startTime)); 
+//		startTime = endTime;
 		
 		
 		
@@ -94,6 +94,13 @@ public class SimulationManager {
 			}
 		}
 		timeStep = timestep;
+		
+//		endTime = System.currentTimeMillis();
+//		System.out.print(" b:" + (endTime - startTime)); 
+//		startTime = endTime;
+		
+		
+		
 		ArrayList<MinimumNetwork> list =  new ArrayList<MinimumNetwork>();
 		MinimumModel minimumModel = new MinimumModel(model.getObjectsOnCanvas(), model.getEdgesOnCanvas());
 		//set all BreakedManuel Cable Burned:
@@ -106,6 +113,14 @@ public class SimulationManager {
 			if(map.containsKey(cable.getModel())) cable.setState(map.get(cable.getModel()));
 		}
 		ArrayList<IntermediateCableWithState> leftOver = new ArrayList<IntermediateCableWithState>();
+		
+		
+//		endTime = System.currentTimeMillis();
+//		System.out.print(" c:" + (endTime - startTime)); 
+//		startTime = endTime;
+		
+		
+		
 		boolean doAnotherLoop = true;
 		while(doAnotherLoop) {
 			doAnotherLoop = false;
@@ -125,15 +140,28 @@ public class SimulationManager {
 		for (MinimumNetwork net : list) {
 			decorNetworks.add(new DecoratedNetwork(net, timestep, actualFairnessModel, newFlexManager));
 		}
+		
+		
+//		endTime = System.currentTimeMillis();
+//		System.out.print(" d:" + (endTime - startTime)); 
+//		startTime = endTime;
+		
+		
+		
 		ArrayList<DecoratedCable> leftOverDecoratedCables = new ArrayList<DecoratedCable>();
 		
 		for(IntermediateCableWithState cable: leftOver) {
 			leftOverDecoratedCables.add(new DecoratedCable(cable.getModel(), cable.getState(), 0.0f));
 		}
 		ArrayList<DecoratedSwitch> listOfDecoratedSwitches = decorateSwitches(minimumModel, timestep);
-		DecoratedState stateFromThisTimestep = new DecoratedState(decorNetworks, leftOverDecoratedCables, listOfDecoratedSwitches, flexManagerFromActual, timestep);
+		DecoratedState stateFromThisTimestep = new DecoratedState(decorNetworks, leftOverDecoratedCables, listOfDecoratedSwitches, newFlexManager, timestep);
 		saves.put(timestep, stateFromThisTimestep);
 		if(updateVisual)savesVisual.put(timestep, new VisualRepresentationalState(stateFromThisTimestep, minimumModel));
+		
+//		endTime = System.currentTimeMillis();
+//		System.out.println(" e:" + (endTime - startTime)); 
+//		startTime = endTime;
+		
 	}
 	/** 
 	 * Decorate a switch
@@ -268,12 +296,11 @@ public class SimulationManager {
 		savesFlexManger.clear();
 	}
 	public void resetFlexManagerForTimeStep(int timestep) {
-		FlexManager newFlexManager = new FlexManager(model, timestep, savesFlexManger.getOrDefault(timestep-1, null));
-		savesFlexManger.put(timestep, newFlexManager);
+		savesFlexManger.get(timestep).reset();
 	}
 	
 	public DecoratedState getDecorState(int timestep) {
-		return saves.getOrDefault(timestep, null);
+		return saves.get(timestep);
 	}
 	public VisualRepresentationalState getVisualRepresentationalState(int timestep) {
 		return savesVisual.getOrDefault(timestep, null);

+ 1 - 1
src/ui/controller/UpdateController.java

@@ -448,7 +448,7 @@ public class UpdateController {
 			Object[] tempCapacity = { Languages.getLanguage()[81], model.getSelectedEdge().getCapacity() };
 			model.getPropertyTable().addRow(tempCapacity);
 			// Status displayed
-            Object[] tempStatus = {Languages.getLanguage()[82], ""};
+            Object[] tempStatus = {"Length", model.getSelectedEdge().getLength() };
             model.getPropertyTable().addRow(tempStatus);
             // For edges, the only possible editable cell is the max
 			// flow

+ 3 - 3
src/ui/view/AddElementPopUp.java

@@ -26,7 +26,7 @@ public class AddElementPopUp extends JDialog {
 	private static final long serialVersionUID = 1L;
 	/* Data */
 	/** Holon Object the Element should be added to */
-	private AbstractCpsObject tempCps;
+	private AbstractCpsObject tempCps;
 	/** Holon Element that should be edited (if in edit Modus */
 	private HolonElement hl;
 	
@@ -45,7 +45,7 @@ public class AddElementPopUp extends JDialog {
 	private JTextField flexibleEnergy;
 	/** Flexible if checkbox is checked */
 	JCheckBox checkboxFlexible;
-	/** Model which is used */
+	/** Model which is used */
 	private Model model;
 
 	/**
@@ -220,4 +220,4 @@ public class AddElementPopUp extends JDialog {
 			elementName.setBackground(new Color(255, 50, 50));
 		}
 	}
-}
+}

+ 2 - 2
src/ui/view/GUI.java

@@ -212,7 +212,7 @@ public class GUI implements CategoryListener {
 	private final JPanel panel = new JPanel();
 	private final JPanel panelHolonEl = new JPanel();
 	// Buttons
-
+
 	private final JButton btnAdd = new JButton("New");
 	private final JPopupMenu btnAddPopUp = new JPopupMenu("New");
 	private final JMenuItem mItemNew = new JMenuItem("New..");
@@ -224,7 +224,7 @@ public class GUI implements CategoryListener {
 	private final JButton btnAddHolEL = new JButton("New Element");
 	private final JButton btnDelHolEL = new JButton("Delete Element");
 	private final JButton resetGraphBtn = new JButton("Reset");
-
+
 	private final JToolBar toolBar = new JToolBar();
 	private final JToolBar toolBarHolonEl = new JToolBar();
 	private final JToolBar toolBarGraph = new JToolBar();

+ 0 - 1
src/ui/view/Main.java

@@ -5,7 +5,6 @@ import ui.controller.SingletonControl;
 import ui.model.Model;
 
 import javax.swing.*;
-import javax.swing.UIManager.LookAndFeelInfo;
 
 import java.awt.*;
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików