Open limit123123 opened 2 years ago
我遇到了一个要比较art喝rt的多样性的问题。使用l 你的code,但是发现有问题。我谢了个比较的代码 如下: package com.limit.test;
import com.limit.faultzone.FaultZone; import com.limit.faultzone.FaultZone_Block; import com.limit.fscsart.FSCS_ART; import com.limit.node.Point;
import java.util.Arrays; import java.util.Scanner;
public class Comparison { public static int[][] domain = { { -5000, 5000 }, { -5000, 5000 } }; public static Scanner in = new Scanner(System.in);
static FSCS_ART art = new FSCS_ART(); public static int generatedNum = 0; // Number of generated test cases static int selectedIndex; static Point[] candidates = new Point[art.candNum]; // 候选用例集合 public static Point generateArtTC(FSCS_ART art, int[][] domain, Point[] candidates, int selectedIndex, Point[] tcP) { for (int j = 0; j < art.candNum; j++) { // 随机生成n个候选的测试用例 candidates[j] = Point.generateRandP(domain); } selectedIndex = art.findFarestCandidate(tcP, generatedNum, candidates); tcP[generatedNum] = candidates[selectedIndex]; generatedNum++; return tcP[generatedNum - 1]; } public static void main(String[] args) { System.out.println("Enter a failure rate:"); float failureRate = in.nextFloat(); System.out.println("How many competitions you want to run:"); int competitions = in.nextInt(); FaultZone fz = new FaultZone_Block(domain, failureRate); int maxTry = (int) (30 / fz.theta); // 如果超过maxTry次还未击中故障区则停止 Point[] tcP = new Point[maxTry + 2]; // 已测试用例的集合 tcP[0] = Point.generateRandP(domain); boolean RtHit; boolean artHit; int m=0; int n=0; for (int i = 1; i <= competitions; i++) { Point randomTC = Point.generateRandP(domain); // Random Test Case Point artTC = generateArtTC(art, domain, candidates, selectedIndex, tcP); RtHit = fz.findTarget(randomTC); if(RtHit==true){ m++; } artHit = fz.findTarget(artTC); if(artHit==true){ n++; } System.out.println("Comparison\t"+i); System.out.println("ART TC:\t" + Arrays.toString(artTC.coordPoint) + "\tHit?\t" + artHit); System.out.println("RT TC:\t" + Arrays.toString(randomTC.coordPoint) + "Hit?\t" + RtHit); } System.out.println("art Hit counts:" + n); System.out.println("RT Hit counts:" +m); }
}
希望您能指点迷津
同时能不能留个联系方式
我遇到了一个要比较art喝rt的多样性的问题。使用l 你的code,但是发现有问题。我谢了个比较的代码 如下: package com.limit.test;
import com.limit.faultzone.FaultZone; import com.limit.faultzone.FaultZone_Block; import com.limit.fscsart.FSCS_ART; import com.limit.node.Point;
import java.util.Arrays; import java.util.Scanner;
public class Comparison { public static int[][] domain = { { -5000, 5000 }, { -5000, 5000 } }; public static Scanner in = new Scanner(System.in);
}