IloObject | +--IloOplDataSource
有关 OPL 的 ILOG 脚本扩展的总体介绍,请参阅 "概述"。
floatmaxOfx= .....;
dvar float x;
maximize x;
subject to {
x<=maxOfx;
}maxOfx=10;
main {
var source = newIloOplModelSource("basicmodel.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
var opl = new IloOplModel(def,cplex);
var data = new IloOplDataSource("basicmodel.dat");
opl.addDataSource(data);
opl.generate();
if ( cplex.solve() ) {
writeln("OBJ = " + cplex.getObjValue());
} else {
writeln("No solution");
}
var opl2 = new IloOplModel(def,cplex);
vardata2=newIloOplDataElements();
data2.maxOfx=11;
opl2.addDataSource(data2);
opl2.generate();
if ( cplex.solve() ) {
writeln("OBJ = " + cplex.getObjValue());
} else {
writeln("No solution");
}
opl.end();
opl2.end();
data.end();
def.end();
cplex.end();
source.end();
}OBJ = 10 OBJ = 11
| 构造函数属性 | 构造函数名称和说明 |
|---|---|
IloOplDataSource(path)
|
| 字段属性 | 字段名称和说明 |
|---|---|
| 流控制 |
访问数据源的名称。
|
| 结束 |
这是文件模型源的路径。
一个数据源不能重复用于多个模型。