|
@@ -8,6 +8,8 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import com.miniframe.core.ExecProcessFlow;
|
|
|
import com.miniframe.core.exception.BusinessException;
|
|
@@ -91,6 +93,7 @@ public class MDO0020Service extends MDO0020BaseModel implements ExecProcessFlow
|
|
|
//获取变量信息
|
|
|
Optimizer_GA_Input ga_input = readInputXml(pid);
|
|
|
String x_name = ga_input.getOptimodel_data().getX_name();
|
|
|
+ x_name=x_name+","+ga_input.getOptimodel_data().getF_name();
|
|
|
MdoProComvalMapper comvalDao =UtilTools.getBean(MdoProComvalMapper.class);
|
|
|
MdoProComvalSQLBuilder sb =new MdoProComvalSQLBuilder();
|
|
|
MdoProComvalSQLBuilder.Criteria sc = sb.createCriteria();
|
|
@@ -116,6 +119,12 @@ public class MDO0020Service extends MDO0020BaseModel implements ExecProcessFlow
|
|
|
String step =line.substring(0,line.indexOf(":"));
|
|
|
line =line.substring(line.indexOf(":")+1).trim();
|
|
|
String vals =line.substring(line.indexOf("[")+1,line.indexOf("]"));
|
|
|
+ String[] fits =line.split("Fitness-");
|
|
|
+ String fitness=fits[1].substring(1,fits[1].indexOf("]")).trim();
|
|
|
+ vals =vals+" "+fitness;
|
|
|
+// System.out.println(vals);
|
|
|
+ vals =extractDoubles(vals);
|
|
|
+
|
|
|
MdoProComval comval =new MdoProComval();
|
|
|
comval.setId(UtilTools.getUUid());
|
|
|
comval.setPid(pid);
|
|
@@ -137,6 +146,44 @@ public class MDO0020Service extends MDO0020BaseModel implements ExecProcessFlow
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ //Gen20: BestX-[0.60371031 0.38946135 0.26024623 0.02400547 0.10866815], Fitness-[4.63029182], Index-[27]
|
|
|
+ String line ="Gen1: BestX-[0.92628971 0.66077288 1.1946117 1.38324986 1.74320906], Fitness-[64.73871441], Index-[0]\n";
|
|
|
+ if(line.startsWith("Gen")) {
|
|
|
+ line = line.replace("Gen", "");
|
|
|
+ String step = line.substring(0, line.indexOf(":"));
|
|
|
+ line = line.substring(line.indexOf(":") + 1).trim();
|
|
|
+ String vals = line.substring(line.indexOf("[") + 1, line.indexOf("]"));
|
|
|
+ String[] fits =line.split("Fitness-");
|
|
|
+ String fitness=fits[1].substring(1,fits[1].indexOf("]")).trim();
|
|
|
+ vals =vals+" "+fitness;
|
|
|
+
|
|
|
+ String ds =extractDoubles(vals);
|
|
|
+ System.out.println(ds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String extractDoubles(String input) {
|
|
|
+ List<Double> doubles = new ArrayList<>();
|
|
|
+ Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?");
|
|
|
+ Matcher matcher = pattern.matcher(input);
|
|
|
+
|
|
|
+ while (matcher.find()) {
|
|
|
+ String matchedString = matcher.group();
|
|
|
+ try {
|
|
|
+ doubles.add(Double.parseDouble(matchedString));
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // Skip the string if it's not a valid double
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String ds ="";
|
|
|
+ for (Double d:doubles) {
|
|
|
+ ds+=d.toString()+" ";
|
|
|
+ }
|
|
|
+
|
|
|
+ return ds.trim();
|
|
|
+ }
|
|
|
+
|
|
|
private Optimizer_GA_Input readInputXml(String pid) throws JAXBException {
|
|
|
String inputxml =LogService.BPATH+"/"+ pid +"/in/Optimizer_GA_Input.xml";
|
|
|
JAXBContext jaxbContext = JAXBContext.newInstance(Optimizer_GA_Input.class);
|