“参考文献
“https://blog.csdn.net/u013555719/article/details/103569252 > https://blog.csdn.net/u013555719/article/details/103595998
public void evaluate(Solution solution) throws JMException {
double vars[] = scaleVariables(solution);
protected double[] scaleVariables(Solution solution) throws JMException {
Variable[] decisionVariables = solution.getDecisionVariables();
double[] x = new double[numberOfVariables_];
for (int i = 0; i < numberOfVariables_; i++)
x[i] = decisionVariables[i].getValue();
for (int i = 0; i < numberOfVariables_; i++) {
double sl = decisionVariables[i].getLowerBound();
double su = decisionVariables[i].getUpperBound();
double pl = lowerLimit_[i];
double pu = upperLimit_[i];
x[i] = ((x[i] - sl) * (pu - pl)) / (su - sl) + pl;
}
return x;
}
ProblemSet matp1;
ProblemSet matp3;
matp1 = MATP1.getProblem();
matp3 = MATP3.getProblem();
SolutionSet testSSvarMATP1 = new SolutionSet();
//初始化示例化的Solution
tools.InibasictestSolSet(testSSvarMATP1, matp1, -100, 100);
//Solution 0Variable
//0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
double[] tempvar = matp1.get(0).scaleVariables(testSSvarMATP1.get(0));
//0.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0
for (int i = 0; i < numberOfVariables_; i++) {
double sl = decisionVariables[i].getLowerBound();
double su = decisionVariables[i].getUpperBound();
double pl = lowerLimit_[i];
double pu = upperLimit_[i];
// System.out.println("sl su pl pu" + sl+" "+ su+" "+ pl+" "+ pu);
//对于MATP3问题
// sl su pl pu0.0 1.0 0.0 1.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
// sl su pl pu0.0 1.0 -5.0 5.0
如上是 MATP3 中 10 个变量的范围,MATP3 问题集变量范围[1]
double sl = decisionVariables[i].getLowerBound();
double su = decisionVariables[i].getUpperBound();
double pl = lowerLimit_[i];double pu = upperLimit_[i];
获得testSSvarMATP1.get(0).getUnifiedLowerLimit();
testSSvarMATP1.get(0).getUnifiedUpperLimit();
//0
//1
double vars[] = scaleVariables(solution);
printdoublearray
0.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0 -100.0
printdoublearray
0.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0 -5.0
//测试迁移时的scaleVariables函数
double[] tempvar = matp1.get(0).scaleVariables(testSSvarMATP1.get(3));
//因为testSSvarMATP1本身就是使用MATP1问题集合初始化的,因此此处不会有变量范围的变化
tools.printdoublearray(tempvar);
//此时如果使用MATP3来对matp1做scale
tempvar = matp3.get(0).scaleVariables(testSSvarMATP1.get(3));
tools.printdoublearray(tempvar);
//Solution 3Variable
// 0.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0
printdoublearray
// 0.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0 19900.0
// printdoublearray
// 0.0 995.0 995.0 995.0 995.0 995.0 995.0 995.0 995.0 995.0
[1]MATP3问题集变量范围: https://blog.csdn.net/u013555719/article/details/103569252
[2]0,1],具体可以[参考一下博文: https://blog.csdn.net/u013555719/article/details/103595998