// create the conversion object and save a reference
IloConversion makeInteger cplex.conversion(x, IloNumVarType.Int);
// To modify the model, add the conversion object to the model
cplex.add(makeXInteger);
// solve the model,
IloBool success = cplex.solve();
// revert the model back to continuous
cplex.remove(makeXInteger);
# 1 楼答案
在Java/Concert API中,可以通过向模型添加IloConversion对象,将变量或变量数组从连续更改为整数。如果您有一个IloNumVar或IloNumVarArray x,您希望使其成为整数,那么您可以使用它创建转换对象