Hi Guys
Very sorry if I am posting this in the wrong forum!
At the minute I am working on implementing the nsga ii algorithm like so http://www.cs.nott.ac.uk/~mvh/teachi...tedSorting.pdf
At the minute I am using the same figures in the example provided and am looking to generate the first front, otherwise known as the undominated front.
I have started to program this and I have got the part working where either 1 dominates the other but the problem comes in when I try program the code that works when neither solution dominates the other, this is severely hindering progress on my project and any help would greatly obliged.
Please tell me this makes sense to some1 out there
Code Provided:
package dominationcheck; import java.util.ArrayList; /** * * @author 09523642 */ public class DominationCheck { /** * @param args the command line arguments */ public static void main(String[] args) { Solution s1 = new Solution(13,35); Solution s2 = new Solution(20,18); Solution s3 = new Solution(18,5); Solution s4 = new Solution(8,10); Solution s5 = new Solution(10,25); Solution s6 = new Solution(5,30); ArrayList<Solution> Undominated = new ArrayList<Solution>(); ArrayList<Solution> Unsorted= new ArrayList<Solution>(); Unsorted.add(s1); Unsorted.add(s2); Unsorted.add(s3); Unsorted.add(s4); Unsorted.add(s5); Unsorted.add(s6); int z; System.out.println("First List:"); for(int i =0;i<=Unsorted.size()-1;i++) { z=Unsorted.get(i).f1; System.out.println(""+z+""); } System.out.println("------------------\n"); Undominated.add(Unsorted.get(0)); Unsorted.remove(0); int endIdx = 0; for(int x = 0; x <= Undominated.size()-1; x++) { for(int i=0; i <= Unsorted.size()-1; i++) { Solution unsorted,undominated; unsorted = Unsorted.get(i); undominated = Undominated.get(x); int p = DominationCheck(unsorted,undominated); switch (p) { case 1: Undominated.remove(x); Undominated.add(unsorted); break; case 2: break; case 3: if(x==Undominated.size()-1) { Undominated.add(unsorted); break; } else{ break; } default: System.out.println("Error"); System.exit(0); break; } } } System.out.println("Second List:"); for(int a =0;a<=Undominated.size()-1;a++) { z=Undominated.get(a).f1; System.out.println(""+z+""); } System.out.println("------------------\n"); } public static int DominationCheck(Solution unsorted, Solution undominated) { int ans=0; if(unsorted.f1<undominated.f1 && unsorted.f2<undominated.f2) { ans = 1; } else if(unsorted.f1>undominated.f1 && unsorted.f2>undominated.f2) //s2 dominates s1 { ans = 2; } else //neither dominate { ans = 3; } return ans; } }