Dominik Rieder 6 years ago
parent
commit
9b556dbe3c

+ 40 - 16
src/algorithms/geneticAlgorithm/holegGA/Components/HolegCrossover.java

@@ -1,4 +1,4 @@
-package algorithms.geneticAlgorithm.holegGA;
+package algorithms.geneticAlgorithm.holegGA.Components;
 
 import java.util.ArrayList;
 
@@ -19,29 +19,47 @@ public class HolegCrossover extends GACrossoverStrategy<HolegIndividual> {
 	}
 
 	private HolegIndividual createChild(HolegIndividual parent1, HolegIndividual parent2) {
-		HolegIndividual child = new HolegIndividual();
-		int splitIdx = (int) Math.ceil(parent1.holonObjects.size()/2);
+		HolegIndividual child = new HolegIndividual(parent1.getOriginObjects());
+		ArrayList<HolegIndividual> parents = new ArrayList<HolegIndividual>();
+		parents.add(parent1);
+		parents.add(parent2);
+		child.setParents(parents);
+		
+		ArrayList<Integer> parent1NonOrgIndexes = parent1.getNonOriginIndexes();
+		int splitIdx = (int) Math.ceil((double)parent1NonOrgIndexes.size()/2);
+		child.addLogEntry("Object Split: " + splitIdx);
+		child.addLogEntry("none Org Indexes par1: " + parent1NonOrgIndexes.size());
 		
 		//HolonObjects
 		for(int i = 0; i < splitIdx; i++){
-			child.holonObjects.add(parent1.holonObjects.get(i).makeCopy());
+			int index = parent1NonOrgIndexes.get(i);
+			
+			child.addObjectWithIdx(parent1.indexToObjectMap.get(index).makeCopy(), index);
 		}
-		int restAmount = parent1.holonObjects.size() - splitIdx;
+		int restAmount = parent1NonOrgIndexes.size() - splitIdx;
+		
+		ArrayList<Integer> parent2NonOrgIndexes = parent2.getNonOriginIndexes();
 		for(int j = 0; j < restAmount; j++){
-			int idx = parent2.holonObjects.size() - 1; //greift auf letztes element zu
-			idx -= j;	//greift bei jedem durchlauf auf ein weiter vorderes element zu
-			if(idx >= 0){
-				child.holonObjects.add(parent2.holonObjects.get(idx).makeCopy());
+			int index = parent2NonOrgIndexes.size() - 1; //greift auf letztes element zu
+			index -= j;	//greift bei jedem durchlauf auf ein weiter vorderes element zu
+			if(index >= 0){
+				int objIdx = parent2NonOrgIndexes.get(index);
+				child.addObjectWithIdx(parent2.indexToObjectMap.get(objIdx).makeCopy(), objIdx);
 			}else{
 				break;
 			}
 		}
 		
 		//HolonEdges
-		splitIdx = (int)Math.ceil(parent1.holonEdges.size()/2);
+		splitIdx = (int) Math.ceil((double)parent1.getEdges().size()/2);
+		child.addLogEntry("Edge Split: " + splitIdx);
 		for(int k = 0; k < splitIdx; k++){
-			int posA = parent1.holonEdges.get(k).aPos;
-			int posB = parent1.holonEdges.get(k).bPos;
+			int posA = parent1.getEdges().get(k).aPos;
+			int posB = parent1.getEdges().get(k).bPos;
+			
+			child.addEdge(posA, posB);
+			
+			/*
 			AbstractCpsObject objA;
 			AbstractCpsObject objB;
 			
@@ -67,16 +85,21 @@ public class HolegCrossover extends GACrossoverStrategy<HolegIndividual> {
 				child.holonObjects.add(objB);
 			}
 			child.holonEdges.add(new GAEdge(posA, posB, objA, objB));
+			*/
 		}
 		
-		restAmount = parent1.holonEdges.size() - splitIdx;
+		restAmount = parent1.getEdges().size() - splitIdx;
 		for(int l = 0; l < restAmount; l++){
-			int idx = parent2.holonEdges.size() - 1;
+			int idx = parent2.getEdges().size() - 1;
 			idx -= l;
 			
 			if(idx >= 0){
-				int posA = parent2.holonEdges.get(idx).aPos;
-				int posB = parent2.holonEdges.get(idx).bPos;
+				int posA = parent2.getEdges().get(idx).aPos;
+				int posB = parent2.getEdges().get(idx).bPos;
+				
+				child.addEdge(posA, posB);
+				
+				/*
 				AbstractCpsObject objA;
 				AbstractCpsObject objB;
 			
@@ -94,6 +117,7 @@ public class HolegCrossover extends GACrossoverStrategy<HolegIndividual> {
 					child.holonObjects.add(objB);
 				}
 				child.holonEdges.add(new GAEdge(posA, posB, objA, objB));
+				*/
 			}
 		}
 		return child;

+ 34 - 19
src/algorithms/geneticAlgorithm/holegGA/Components/HolegFactory.java

@@ -1,4 +1,4 @@
-package algorithms.geneticAlgorithm.holegGA;
+package algorithms.geneticAlgorithm.holegGA.Components;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -16,9 +16,11 @@ import algorithms.geneticAlgorithm.Components.GAIndividualFactory;
 public class HolegFactory implements GAIndividualFactory<HolegIndividual> {
 
 	ArrayList<AbstractCpsObject> objectSpace;
-	int maxObjects;
-	int maxConnections;
+	public ArrayList<AbstractCpsObject> originObjects;
+	public int maxObjects;
+	public int maxConnections;
 	Random rng;
+	public boolean onlyNodes;
 	
 	public HolegFactory(ArrayList<AbstractCpsObject> objects, int maxObjects, int maxConnections){
 		objectSpace = objects;
@@ -26,13 +28,19 @@ public class HolegFactory implements GAIndividualFactory<HolegIndividual> {
 		this.maxObjects = maxObjects;
 		this.maxConnections = maxConnections;
 		rng = new Random();
+		originObjects = new ArrayList<AbstractCpsObject>();
+		onlyNodes = false;
 	}
 	
 	@Override
 	public HolegIndividual createRandomIndividual() {
-		HolegIndividual hI = new HolegIndividual();
-		createObjects(hI);
-		createEdges(hI);
+		HolegIndividual hI = new HolegIndividual(originObjects);
+		if(maxObjects > 0){
+			createObjects(hI);
+		}
+		if(maxConnections > 0){
+			createEdges(hI);
+		}
 		return hI;
 	}
 	
@@ -42,29 +50,35 @@ public class HolegFactory implements GAIndividualFactory<HolegIndividual> {
 		
 		for(int i = 0; i < objCount; i++){
 			
-			AbstractCpsObject absObj = objectSpace.get(rng.nextInt(objectSpace.size()));
+			
 			AbstractCpsObject newObj = null;
-			if(absObj instanceof HolonObject){
-				newObj = new HolonObject(absObj);
-			}else if(absObj instanceof HolonSwitch){
-				newObj = new HolonSwitch(absObj);
-			}else if(absObj instanceof HolonBattery){
-				newObj = new HolonBattery(absObj);
-			}else if(absObj == null){
+			if(!onlyNodes){
+				AbstractCpsObject absObj = objectSpace.get(rng.nextInt(objectSpace.size()));
+				if(absObj instanceof HolonObject){
+					newObj = new HolonObject(absObj);
+				}else if(absObj instanceof HolonSwitch){
+					newObj = new HolonSwitch(absObj);
+				}else if(absObj instanceof HolonBattery){
+					newObj = new HolonBattery(absObj);
+				}else if(absObj == null){
+					newObj = new CpsNode("Node");
+				}
+			}else{
 				newObj = new CpsNode("Node");
 			}
 			
-			hI.holonObjects.add(newObj);
+			//hI.holonObjects.add(newObj);
+			hI.addObject(newObj);
 		}
 	}
 	
 	public void createEdges(HolegIndividual hI){
-		if(hI.holonObjects.size() > 1){
+		if(hI.getIndexes().size() > 1){
 			int edgeCount = rng.nextInt(maxConnections) + 1;
 			ArrayList<Integer> list = new ArrayList<Integer>();
 	    
-			for (int i = 0; i < hI.holonObjects.size(); i++) {
-				list.add(new Integer(i));
+			for (int i = 0; i < hI.getIndexes().size(); i++) {
+				list.add(hI.getIndexes().get(i));
 			}
 	   
 		
@@ -72,7 +86,8 @@ public class HolegFactory implements GAIndividualFactory<HolegIndividual> {
 				Collections.shuffle(list);
 				int aPos = list.get(0);
 				int bPos = list.get(1);
-				hI.holonEdges.add(new GAEdge(aPos, bPos, hI.holonObjects.get(aPos), hI.holonObjects.get(bPos)));
+				//hI.holonEdges.add(new GAEdge(aPos, bPos, hI.holonObjects.get(aPos), hI.holonObjects.get(bPos)));
+				hI.addEdge(aPos, bPos);
 			}
 		}
 

+ 25 - 0
src/algorithms/geneticAlgorithm/holegGA/Components/HolegFittnessFkt.java

@@ -0,0 +1,25 @@
+package algorithms.geneticAlgorithm.holegGA.Components;
+
+import classes.AbstractCpsObject;
+import classes.HolonObject;
+import algorithms.geneticAlgorithm.Components.GAFittnessFunctionStrategy;
+import algorithms.geneticAlgorithm.Components.GAIndividual;
+
+public class HolegFittnessFkt implements GAFittnessFunctionStrategy<HolegIndividual>{
+
+	@Override
+	public double calculateFittness(HolegIndividual candidate) {
+		double fittness = 0;
+		for(AbstractCpsObject abs : candidate.getObjects()){
+			if(abs instanceof HolonObject){
+				if(((HolonObject) abs).getState() == HolonObject.SUPPLIED){
+					fittness += 100;
+				}
+			}
+		}
+		candidate.setFittness(fittness);
+		candidate.addLogEntry("Fittness: " + fittness);
+		return fittness;
+	}
+
+}

+ 141 - 5
src/algorithms/geneticAlgorithm/holegGA/Components/HolegIndividual.java

@@ -1,23 +1,47 @@
-package algorithms.geneticAlgorithm.holegGA;
+package algorithms.geneticAlgorithm.holegGA.Components;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
 import classes.AbstractCpsObject;
+import classes.CpsNode;
 import algorithms.geneticAlgorithm.Components.GAIndividual;
+import algorithms.geneticAlgorithm.holegGA.GAEdge;
 
 public class HolegIndividual extends GAIndividual {
 	
-	public ArrayList<AbstractCpsObject> holonObjects;
-	public ArrayList<GAEdge> holonEdges;
+	private ArrayList<AbstractCpsObject> holonObjects;
+	private ArrayList<GAEdge> holonEdges;
+	public ArrayList<Integer> indexes;
+	public ArrayList<Integer> originIndexes;
 	public ArrayList<HolegIndividual> parents;
+	public HashMap<Integer, AbstractCpsObject> indexToObjectMap;
+	private HashMap<AbstractCpsObject, Integer> objectToIndexMap;
+	public boolean drawn;
 	public String id;
+	public String log;
 	public int gen;
 	public int pos;
+	private int lastIndex;
 	
-	public HolegIndividual(){
+	public HolegIndividual(ArrayList<AbstractCpsObject> originObjects){
 		holonObjects = new  ArrayList<AbstractCpsObject>();
 		holonEdges = new ArrayList<GAEdge>();
+		indexes = new ArrayList<Integer>();
+		originIndexes = new ArrayList<Integer>();
 		parents = new ArrayList<HolegIndividual>();
+		indexToObjectMap = new HashMap<Integer, AbstractCpsObject>();
+		objectToIndexMap = new HashMap<AbstractCpsObject, Integer>();
+		lastIndex = 0;
+		log = "Individual Log";
+		drawn = false;
+		
+		for(AbstractCpsObject abs : originObjects){
+			AbstractCpsObject newObj = abs.makeCopy();
+			newObj.setPosition(abs.getPosition());
+			addObject(newObj);
+			originIndexes.add(objectToIndexMap.get(newObj));
+		}
 	}
 	
 	public ArrayList<HolegIndividual> getParents(){
@@ -26,13 +50,125 @@ public class HolegIndividual extends GAIndividual {
 	
 	public void setParents(ArrayList<HolegIndividual> parents){
 		this.parents = parents;
+		for(int i = 0; i < parents.size(); i++){
+			addLogEntry("Parent" + i + ": " + parents.get(i).getId());
+		}
 	}
 	
 	public void setId(int Gen, int pos){
-		id = "Generation_" + Gen + " Position_" + pos;
+		if(Gen > 0){
+			id = "Generation_" + Gen + " Position_" + pos;
+		}else{
+			id = "Generation_Origin" + " Position_" + pos;
+		}
 	}
 	
 	public String getId(){
 		return id;
 	}
+	
+	public ArrayList<AbstractCpsObject> getObjects(){
+		ArrayList<AbstractCpsObject> objects = new ArrayList<AbstractCpsObject>();
+		for(Integer i : indexes){
+			objects.add(indexToObjectMap.get(i));
+		}
+		return objects;
+	}
+	
+	public ArrayList<AbstractCpsObject> getOriginObjects(){
+		ArrayList<AbstractCpsObject> originObjects = new ArrayList<AbstractCpsObject>();
+		for(Integer i : originIndexes){
+			originObjects.add(indexToObjectMap.get(i));
+		}
+		return originObjects;
+	}
+	
+	public AbstractCpsObject getObjectWithIndex(int index){
+		return indexToObjectMap.get(index);
+	}
+	
+	public AbstractCpsObject getObjectAt(int position){
+		return indexToObjectMap.get(indexes.get(position));
+	}
+	
+	public ArrayList<Integer> getIndexes(){
+		return indexes;
+	}
+	
+	public ArrayList<Integer> getNonOriginIndexes(){
+		if(indexes.size() > originIndexes.size()){
+			return new ArrayList<Integer>(indexes.subList(originIndexes.size(), indexes.size()));
+		}else{
+			return new ArrayList<Integer>();
+		}
+	}
+	
+	public ArrayList<GAEdge> getEdges(){
+		return holonEdges;
+	}
+	
+	public void addObject(AbstractCpsObject obj){
+		addObjectWithIdx(obj, lastIndex);
+		lastIndex++;
+	}
+	
+	public void addObjectWithIdx(AbstractCpsObject obj, int index){
+		if(!indexToObjectMap.containsKey(index)){
+			addIndex(index);
+			indexToObjectMap.put(index, obj);
+			objectToIndexMap.put(obj, index);
+		}else{
+			objectToIndexMap.remove(indexToObjectMap.get(index));
+			indexToObjectMap.put(index, obj);
+			objectToIndexMap.put(obj, index);
+		}
+		//indexToObjectMap.put(index, obj);
+	}
+	
+	public void addIndex(int index){
+		for(int i = 0; i < indexes.size(); i++){
+			if(index < indexes.get(i)){
+				indexes.add(i, index);
+				return;
+			}
+		}
+		indexes.add(index);
+		return;
+	}
+	/*
+	 * posA and posB are the indexes of the Endpoints A and B in the list of Objects
+	 */
+	public void addEdge(int indexA, int indexB){
+		if(!edgeExists(indexA, indexB)){
+			
+			if(!indexToObjectMap.containsKey(indexA)){
+				CpsNode newObjA = new CpsNode("Node");
+				addObjectWithIdx(newObjA, indexA);
+			}
+			if(!indexToObjectMap.containsKey(indexB)){
+				CpsNode newObjB = new CpsNode("Node");
+				addObjectWithIdx(newObjB, indexB);
+			}
+			holonEdges.add(new GAEdge(indexA, indexB, indexToObjectMap.get(indexA), indexToObjectMap.get(indexB)));
+		
+		}else{
+			addLogEntry("double Edge: " + indexToObjectMap.get(indexA).getId() + " to " 
+					+ indexToObjectMap.get(indexB).getId());
+		}
+
+	}
+	
+	public boolean edgeExists(int indexA, int indexB){
+		for(GAEdge e : holonEdges){
+			if((e.aPos == indexA && e.bPos == indexB) || (e.bPos == indexA && e.aPos == indexB)){
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	public void addLogEntry(String entry){
+		log += "\n" + entry;
+	}
+
 }

+ 12 - 0
src/algorithms/geneticAlgorithm/holegGA/Components/HolegMutation.java

@@ -0,0 +1,12 @@
+package algorithms.geneticAlgorithm.holegGA.Components;
+
+import algorithms.geneticAlgorithm.Components.GAMutationStrategy;
+
+public class HolegMutation extends GAMutationStrategy<HolegIndividual>{
+
+	@Override
+	public HolegIndividual mutateIndividual(HolegIndividual mutant) {
+		return mutant;
+	}
+
+}

+ 2 - 2
src/algorithms/geneticAlgorithm/holegGA/GAEdge.java

@@ -5,8 +5,8 @@ import classes.CpsEdge;
 
 public class GAEdge extends CpsEdge {
 	
-	int aPos;
-	int bPos;
+	public int aPos;
+	public int bPos;
 	
 	public GAEdge(int a, int b, AbstractCpsObject nodeA, AbstractCpsObject nodeB){
 		super(nodeA,nodeB, CAPACITY_INFINITE);

+ 74 - 15
src/algorithms/geneticAlgorithm/holegGA/GenAlgoHandler.java

@@ -9,6 +9,9 @@ import classes.Position;
 import ui.controller.Control;
 import ui.model.Model;
 import algorithms.geneticAlgorithm.Components.GAResultListener;
+import algorithms.geneticAlgorithm.holegGA.Components.HolegCrossover;
+import algorithms.geneticAlgorithm.holegGA.Components.HolegFactory;
+import algorithms.geneticAlgorithm.holegGA.Components.HolegIndividual;
 
 public class GenAlgoHandler {
 	
@@ -17,6 +20,7 @@ public class GenAlgoHandler {
 	Control controller;
 	Model model;
 	int genCount;
+	boolean onlyNodes;
 	
 	public GenAlgoHandler(Control controller, Model model){
 		this.controller = controller;
@@ -28,10 +32,16 @@ public class GenAlgoHandler {
 				objSpace.add(obj);
 			}
 		}
+		ArrayList<AbstractCpsObject> origin = model.getObjectsOnCanvas();
 		factory = new HolegFactory(objSpace, 5, 5);
+		factory.originObjects = origin;
+		onlyNodes = false;
 	}
 	
-	public void createGeneration(){
+	public void createGeneration(int objAmount, int edgeAmount){
+		factory.maxObjects = objAmount;
+		factory.maxConnections = edgeAmount;
+		factory.onlyNodes = onlyNodes;
 		ArrayList<HolegIndividual> population = new ArrayList<HolegIndividual>();
 		for(int i = 1; i <= 2; i++){
 			population.add(factory.createRandomIndividual());
@@ -46,36 +56,85 @@ public class GenAlgoHandler {
 		//}
 		addPopulationListeners(genCount, children);
 		genCount++;
+
 	}
 	
 	public void drawIndividual(HolegIndividual hI){
+		if(hI.drawn){
+			//draws Individual with the positions in the objects
+			drawIndividualWithPos(hI);
+		}else{
+			//draws Individual as a default grid
+			drawIndividualWithoutPos(hI);
+			hI.drawn = true;
+		}
+	}
+	
+	public void drawIndividualWithPos(HolegIndividual hI){
 		model.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
 		model.setEdgesOnCanvas(new ArrayList<CpsEdge>());
 		
-		int xBound = (int) Math.ceil(Math.sqrt(hI.holonObjects.size()));
+		for(int i = 0; i < hI.getIndexes().size(); i++){
+			controller.addObjectCanvas(hI.getObjectAt(i));
+		}
+		
+		for(CpsEdge e : hI.getEdges()){
+			controller.addEdgeOnCanvas(e);
+		}
+	}
+	
+	public void drawIndividualWithoutPos(HolegIndividual hI){
+		model.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
+		model.setEdgesOnCanvas(new ArrayList<CpsEdge>());
+		
+		int originBound = (int) Math.ceil(Math.sqrt(hI.originIndexes.size()));
 		int row = -1;
 		
 		int x = 50;
 		int y = 50;
-		int dist = 200;
+		int dist = 100;
 		boolean isX = true;
 		
-		for(int i = 0; i < hI.holonObjects.size(); i++){
-		//for(AbstractCpsObject abs : hI.holonObjects){
-			AbstractCpsObject abs = hI.holonObjects.get(i);
-			
-			
-			
-			if(i % xBound == 0){
+		int allBound = (int) Math.ceil(Math.sqrt(hI.indexes.size()));
+		
+		ArrayList<ArrayList<Integer>> objectField = new ArrayList<ArrayList<Integer>>();
+		for(int i = 0; i < hI.originIndexes.size(); i++){
+			if(i % originBound == 0){
 				row++;
+				objectField.add(new ArrayList<Integer>());
+			}
+			objectField.get(row).add(hI.originIndexes.get(i));
+		}
+		
+		row = 0;
+		for(int j = hI.originIndexes.size(); j < hI.indexes.size(); j++){
+			boolean inserted = false;
+			while(!inserted){
+				if(objectField.size() <= row){
+					objectField.add(new ArrayList<Integer>());
+					objectField.get(row).add(hI.indexes.get(j));
+					inserted = true;
+				}else{
+					if(objectField.get(row).size() < allBound){
+						objectField.get(row).add(hI.indexes.get(j));
+						inserted = true;
+					}else{
+						row++;
+					}
+				}
+			}
+		}
+		
+		for(int k = 0; k < objectField.size(); k++){
+			for(int l = 0; l < objectField.get(k).size(); l++){
+				AbstractCpsObject toDraw = hI.getObjectWithIndex(objectField.get(k).get(l));
+				toDraw.setPosition(new Position(x + (l*dist), y +(k*dist)));
+				controller.addObjectCanvas(toDraw);
 			}
-			
-			abs.setPosition(new Position(((i % xBound)* dist) + x , (row * dist) + y));
-			controller.addObjectCanvas(abs);
 		}
 		
-		for(int j = 0; j < hI.holonEdges.size(); j++){
-			controller.addEdgeOnCanvas(hI.holonEdges.get(j));
+		for(CpsEdge e : hI.getEdges()){
+			controller.addEdgeOnCanvas(e);
 		}
 	}
 	

+ 58 - 6
src/algorithms/geneticAlgorithm/holegGA/GenAlgoWindow.java

@@ -25,6 +25,7 @@ import ui.view.UnitGraph;
 import javax.swing.JButton;
 
 import algorithms.geneticAlgorithm.Components.GAResultListener;
+import algorithms.geneticAlgorithm.holegGA.Components.HolegIndividual;
 
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
@@ -33,7 +34,11 @@ import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.util.ArrayList;
 import java.util.HashMap;
+
 import javax.swing.JTextField;
+import javax.swing.JLabel;
+import javax.swing.JCheckBox;
+import javax.swing.JTextArea;
 
 public class GenAlgoWindow implements GAResultListener<HolegIndividual> {
 
@@ -46,7 +51,10 @@ public class GenAlgoWindow implements GAResultListener<HolegIndividual> {
 	HashMap<DefaultMutableTreeNode, HolegIndividual> treeIndiHashmap;
 
 	GenAlgoHandler algoHandler;
-	private JTextField textField;
+	private JTextField objectAmountField;
+	private JTextField edgeAmountField;
+	private JCheckBox chckbxOnlyNodes;
+	private JTextArea logArea;
 	/**
 	 * Create the application.
 	 */
@@ -58,6 +66,11 @@ public class GenAlgoWindow implements GAResultListener<HolegIndividual> {
 		treeIndiHashmap = new HashMap<DefaultMutableTreeNode, HolegIndividual>();
 		initialize();
 		
+		HolegIndividual originIndividual = new HolegIndividual(model.getObjectsOnCanvas());
+		ArrayList<HolegIndividual> originPopulation = new ArrayList<HolegIndividual>();
+		originPopulation.add(originIndividual);
+		populationCreated(-1, originPopulation);
+		
 	}
 
 	/**
@@ -94,17 +107,49 @@ public class GenAlgoWindow implements GAResultListener<HolegIndividual> {
 		rightSplitPane.setLeftComponent(panel);
 		
 		JButton btnCreategeneration = new JButton("createGeneration");
+		btnCreategeneration.setBounds(44, 11, 117, 23);
 		btnCreategeneration.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
-				algoHandler.createGeneration();
+				int objAmount = Integer.parseInt(objectAmountField.getText());
+				int edgeAmount = Integer.parseInt(edgeAmountField.getText());
+				algoHandler.onlyNodes = chckbxOnlyNodes.isSelected();
+				algoHandler.createGeneration(objAmount, edgeAmount);
 			}
 		});
+		panel.setLayout(null);
 		
-		textField = new JTextField();
-		panel.add(textField);
-		textField.setColumns(10);
+		objectAmountField = new JTextField();
+		objectAmountField.setText("0");
+		objectAmountField.setBounds(89, 45, 86, 20);
+		panel.add(objectAmountField);
+		objectAmountField.setColumns(10);
 		panel.add(btnCreategeneration);
 		
+		edgeAmountField = new JTextField();
+		edgeAmountField.setText("0");
+		edgeAmountField.setBounds(89, 76, 86, 20);
+		panel.add(edgeAmountField);
+		edgeAmountField.setColumns(10);
+		
+		JLabel lblMaxObjects = new JLabel("Max Objects");
+		lblMaxObjects.setBounds(10, 48, 69, 14);
+		panel.add(lblMaxObjects);
+		
+		JLabel lblMaxEdges = new JLabel("Max Edges");
+		lblMaxEdges.setBounds(10, 79, 69, 14);
+		panel.add(lblMaxEdges);
+		
+		chckbxOnlyNodes = new JCheckBox("\r\n");
+		chckbxOnlyNodes.setBounds(89, 103, 25, 23);
+		panel.add(chckbxOnlyNodes);
+		
+		JLabel lblOnlyNodes = new JLabel("Only Nodes?");
+		lblOnlyNodes.setBounds(10, 107, 69, 14);
+		panel.add(lblOnlyNodes);
+		
+		logArea = new JTextArea();
+		rightSplitPane.setRightComponent(logArea);
+		
 		 MouseListener ml = new MouseAdapter() {
 		     public void mousePressed(MouseEvent e) {
 		         int selRow = genTree.getRowForLocation(e.getX(), e.getY());
@@ -127,6 +172,7 @@ public class GenAlgoWindow implements GAResultListener<HolegIndividual> {
 		DefaultMutableTreeNode node = (DefaultMutableTreeNode)selPath.getLastPathComponent();
 		if(treeIndiHashmap.get(node) != null){
 			algoHandler.drawIndividual(treeIndiHashmap.get(node));
+			logArea.setText(treeIndiHashmap.get(node).log);
 		}
 		
 	}
@@ -134,10 +180,16 @@ public class GenAlgoWindow implements GAResultListener<HolegIndividual> {
 
 	@Override
 	public void populationCreated(int generation, ArrayList<HolegIndividual> population) {
-		DefaultMutableTreeNode genNode = new DefaultMutableTreeNode("Generation " + generation);
+		DefaultMutableTreeNode genNode;
+		if(! (generation == -1)){
+			genNode = new DefaultMutableTreeNode("Generation " + generation);
+		}else{
+			genNode = new DefaultMutableTreeNode("Origin Network");
+		}
 		
 		for(int i = 0; i < population.size(); i++){
 			DefaultMutableTreeNode child = new DefaultMutableTreeNode("Individual " + i);
+			population.get(i).setId(generation, i);
 			treeIndiHashmap.put(child, population.get(i));
 			genNode.add(child);
 		}

+ 1 - 1
src/classes/AbstractCpsObject.java

@@ -57,7 +57,7 @@ public abstract class AbstractCpsObject {
 		setImage("/Images/Dummy_House.png");
 		tags = new ArrayList<>();
 		pseudoTags = new ArrayList<>();
-		position = new Position(500, 500);
+		//position = new Position(500, 500);
 	}
 
 	/**