资源简介
javaCallCplex and Gurobi,包含大量相关实例,一看就会!
代码片段和文件信息
package com.homework;
import java.io.IOException;
import ilog.concert.IloColumn;
import ilog.concert.IloException;
import ilog.concert.IloNumVar;
import ilog.concert.IloNumVarType;
import ilog.concert.Iloobjective;
import ilog.concert.IloRange;
import ilog.cplex.IloCplex;
class CutStockp_example {
static double RC_EPS = 1.0e-6;
// Data of the problem
static double _rollWidth;
static double[] _size;
static double[] _amount;
static void readData(String fileName)
throws IOException
InputDataReader.InputDataReaderException {
InputDataReader reader = new InputDataReader(fileName);
_rollWidth = reader.readDouble();
_size = reader.readDoubleArray();
_amount = reader.readDoubleArray();
}
static void report1(IloCplex cutSolver IloNumVarArray Cut IloRange[] Fill)
throws IloException {
System.out.println();
System.out.println(“Using “ + cutSolver.getObjValue() + “ rolls“);
System.out.println();
for (int j = 0; j < Cut.getSize(); j++) {
System.out.println(“ Cut“ + j + “ = “ +
cutSolver.getValue(Cut.getElement(j)));
}
System.out.println();
for (int i = 0; i < Fill.length; i++)
System.out.println(“ Fill“ + i + “ = “ + cutSolver.getDual(Fill[i]));
System.out.println();
}
static void report2(IloCplex patSolver IloNumVar[] Use)
throws IloException {
System.out.println();
System.out.println(“Reduced cost is “ + patSolver.getObjValue());
System.out.println();
if (patSolver.getObjValue() <= -RC_EPS) {
for (int i = 0; i < Use.length; i++)
System.out.println(“ Use“ + i + “ = “
+ patSolver.getValue(Use[i]));
System.out.println();
}
}
static void report3(IloCplex cutSolver IloNumVarArray Cut)
throws IloException {
System.out.println();
System.out.println(“Best integer solution uses “ +
cutSolver.getObjValue() + “ rolls“);
System.out.println();
for (int j = 0; j < Cut.getSize(); j++)
System.out.println(“ Cut“ + j + “ = “ +
cutSolver.getValue(Cut.getElement(j)));
}
static class IloNumVarArray {
int _num = 0;
IloNumVar[] _array = new IloNumVar[32];
void add(IloNumVar ivar) {
if ( _num >= _array.length ) {
IloNumVar[] array = new IloNumVar[2 * _array.length];
System.arraycopy(_array 0 array 0 _num);
_array = array;
}
_array[_num++] = ivar;
}
IloNumVar getElement(int i) { return _array[i]; }
int getSize() { return _num; }
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-25 09:20 javaCallCplex\
文件 681 2017-11-22 16:59 javaCallCplex\.classpath
文件 398 2017-10-25 15:52 javaCallCplex\.project
目录 0 2018-04-25 09:20 javaCallCplex\.settings\
文件 664 2017-10-25 14:59 javaCallCplex\.settings\org.eclipse.jdt.core.prefs
目录 0 2018-04-25 09:20 javaCallCplex\bin\
目录 0 2018-04-25 09:20 javaCallCplex\bin\com\
目录 0 2018-04-25 09:20 javaCallCplex\bin\com\homework\
文件 22 2017-10-19 13:06 javaCallCplex\bin\com\homework\cutstock.dat
文件 1099 2017-11-27 10:37 javaCallCplex\bin\com\homework\CutStockp_example$IloNumVarArray.class
文件 6588 2017-11-27 10:37 javaCallCplex\bin\com\homework\CutStockp_example.class
文件 1197 2017-11-27 10:37 javaCallCplex\bin\com\homework\InputDataReader$DoubleArray.class
文件 1396 2017-11-27 10:37 javaCallCplex\bin\com\homework\InputDataReader$DoubleArrayArray.class
文件 770 2017-11-27 10:37 javaCallCplex\bin\com\homework\InputDataReader$InputDataReaderException.class
文件 1234 2017-11-27 10:37 javaCallCplex\bin\com\homework\InputDataReader$IntArray.class
文件 1384 2017-11-27 10:37 javaCallCplex\bin\com\homework\InputDataReader$IntArrayArray.class
文件 4429 2017-11-27 10:37 javaCallCplex\bin\com\homework\InputDataReader.class
文件 4595 2017-11-27 10:37 javaCallCplex\bin\com\homework\MyColGen.class
文件 3908 2017-11-27 10:37 javaCallCplex\bin\com\homework\MyColGenByRSM.class
目录 0 2018-04-25 09:20 javaCallCplex\bin\cplex\
目录 0 2018-04-25 09:20 javaCallCplex\bin\cplex\basis\
文件 2643 2017-11-27 10:37 javaCallCplex\bin\cplex\basis\Basis1.class
文件 3341 2017-11-27 10:37 javaCallCplex\bin\cplex\basis\Basis2.class
文件 152464 2017-10-02 11:05 javaCallCplex\bin\cplex\basis\Basis2.png
文件 3859 2017-11-27 10:37 javaCallCplex\bin\cplex\basis\Basis3.class
文件 437667 2017-10-02 11:04 javaCallCplex\bin\cplex\basis\Basis3.png
文件 4651 2017-11-27 10:37 javaCallCplex\bin\cplex\basis\Basis4.class
文件 179321 2017-10-02 14:10 javaCallCplex\bin\cplex\basis\Basis4.png
文件 887 2017-11-27 10:37 javaCallCplex\bin\cplex\basis\Basis5.class
文件 2355 2017-11-27 10:37 javaCallCplex\bin\cplex\basis\Basis6.class
文件 119753 2017-10-02 15:50 javaCallCplex\bin\cplex\basis\Basis6.png
............此处省略185个文件信息
- 上一篇:android登陆界面保存账号密码
- 下一篇:JSP+Servlet新闻管理系统
评论
共有 条评论