Modifying problems

These problem modification routines change a problem object after it has been created.

Problem modification routines change a problem object after it has been created.

Modifications that can be made include:

  • adding rows and columns to the constraint matrix,

  • deleting rows and columns from the constraint matrix,

  • changing the sense of the objective function,

  • changing the value of coefficients in the constraint matrix,

  • changing an objective or righthand side coefficient,

  • changing the bounds on a variable,

  • changing the sense of a constraint, and

  • changing names of rows or columns.

When you are modifying multiple existing objects in the object-oriented APIs (C++, Java, C#.NET), you have a choice between modifying each object individually in a sequence of operations (such as in a loop) or making accumulated changes simultaneously in a single operation (for example, on an array of modeling objects). Generally, the single operation is more efficient than a sequence of operations.

For example, in the C++ API, it is possible to change the lower bounds on a set of variables through a sequence of invocations of the method IloNumVar::setLB; however, it is more efficient to accumulate the variables in an array (an instance of IloNumVarArray) and then to apply the method IloNumVarArray::setBounds simultaneously to all the variables in that array. The same observation about efficiency applies to objects of other classes derived from the base class IloExtractable, such classes as IloRange, IloSOS1, IloSOS2, and IloSemiContVar.

Note:

Names of classes, methods, and symbolic constants in the C#.NET API correspond very closely to those in the Java API with these systematic exceptions:

  • In the Java API, the names of classes begin with the prefix Ilo, whereas in C#.NET they do not.

  • In the Java API, the names of methods conventionally begin with a lowercase letter, for example, addCols, whereas in the C#.NET API, the names of methods conventionally begin with an uppercase (that is, capital) letter, for example, AddCols according to Microsoft practice.

Purpose Java API C++ API C API
Adds a single variable Create IloNumVar, IloIntVar, IloSemiContVar objects or use IloLPMatrix. addColumn Create IloNumVar, IloIntVar, IloSemiContVar objects CPXXaddcols and CPXaddcols
Adds multiple variables Use IloModeler.numVarArray(int, double, double, ilog.concert.IloNumVarArrayType), IloModeler.intVarArray(int, int, int), IloSemiContVar or use IloLPMatrix. addCols Create IloNumVarArray, IloIntVarArray, IloSemiContVarArray objects CPXXaddcols and CPXaddcols
Adds a single variable without matrix coefficients Create IloNumVar, IloIntVar, IloSemiContVar objects or use IloLPMatrix. addColumn Create IloNumVar, IloIntVar, IloSemiContVar objects CPXXnewcols and CPXnewcols
Adds multiple variables without matrix coefficients Use IloModeler.numVarArray(int, double, double, ilog.concert.IloNumVarType), IloModeler.intVarArray(int, int, int), IloMPModeler.semiContVarArray(int, double, double, ilog.concert.IloNumVarType), or use IloLPMatrix.addCols(ilog.concert.IloNumVar[]) Create IloNumVarArray, IloIntVarArray, IloSemiContVarArray objects CPXXnewcols and CPXnewcols
Adds constraints IloModel.add(ilog.concert.IloAddable) or IloMPModeler.addRange(double, double), or IloModeler.addLe(double, ilog.concert.IloNumExpr) or IloModeler.addGe(double, ilog.concert.IloNumExpr), or IloModeler.addEq(double, ilog.concert.IloNumExpr), or IloLPMatrix.addRows(double[], double[], int[][], double[][]) IloModel:: add CPXXaddrows and CPXaddrows
Adds constraints without matrix coefficients IloModel.add(ilog.concert.IloAddable) or IloMPModeler.addRange(double, double), or Ilomodeler.addLe(double, ilog.concert.IloNumExpr),s or IloModeler.addGe(double, ilog.concert.IloNumExpr), or IloModeler.addEq(double, ilog.concert.IloNumExpr), or IloLPMatrix.addRows(double[], double[], int[][], double[][]) IloModel:: add CPXXnewrows and CPXnewrows
Deletes a single constraint IloModel.remove(ilog.concert.IloAddable),(IloAddable) or IloCplexModeler.delete(IloCopyable),(IloCopyable), or IloLPMatrix.removeRow(int). IloRange:: end or IloModel:: remove (const IloExtractable ) CPXXdelcols and CPXdelcols
Deletes a range of constraints IloModel.remove(ilog.concert.IloAddable[]), or IloCplexModeler.delete(IloCopyable[], int, int), or IloLPMatrix.removeRows(int[]) IloRange:: end or IloModel:: remove(const IloExtractableArray) CPXXdelrows and CPXdelrows
Deletes a set of constraints IloModel.remove(ilog.concert.IloAddable[]), or IloCplexModeler.delete(IloCopyable[], int, int)., or IloLPMatrix.removeRows(int, int) IloRangeArray:: endElements or IloModel:: remove(const IloExtractableArray) CPXXdelsetrows and CPXdelsetrows
Deletes names of rows and columns ---- ---- CPXXdelnames and CPXdelnames
Deletes a single variable IloMPModeler.delete(IloCopyable)(IloCopyable) IloNumVar:: end, IloIntVar:: end, IloSemiContVar:: end CPXXdelcols and CPXdelcols
Deletes a range of variables IloCplexModeler.delete(IloCopyable[], int, int) IloNumVar:: end, IloIntVar:: end, IloSemiContVar:: end CPXXdelcols and CPXdelcols
Deletes a set of variables IloCplexModeler.delete(IloCopyable[], int, int) IloNumVar:: end, IloIntVar:: end, IloSemiContVar:: end CPXXdelsetcols and CPXdelsetcols
Changes objective sense IloObjective.setSense(ilog.concert.IloObjectiveSense) IloObjective:: setSense CPXXchgobjsen and CPXchgobjsen
Changes sense of a single constraint IloRange.setLB(double), IloRange.setUB(double) IloRange:: setLB, setUB CPXXchgsense and CPXchgsense
Changes sense of multiple constraints IloRange.setBounds(double, double) IloRange:: setBounds CPXXchgsense and CPXchgsense
Changes a coefficient in a matrix, rhs, or objective function

IloMPModeler.addToExpr(ilog.concert.IloRange, ilog.concert.IloNumExpr)

IloLPMatrix.setNZ(int, int, double) (for matrix)

IloRange.setLB(double), IloRange.setUB(double), IloRange#setBounds(double, double) (for rhs)

IloMPModeler.setLinearCoef(ilog.concert.IloObjective, ilog.concert.IloNumVar, double) (for objective)

IloRange:: setLinearCoef (for matrix)

IloRange:: setLB, IloRange:: setUB, IloRange:: setBounds (for rhs)

IloObjective:: setLinearCoef (for objective)

CPXXchgcoef and CPXchgcoef
Changes a list of matrix coefficients IloMPModeler.setLinearCoefs(ilog.concert.IloRange, double[], ilog.concert.IloNumVar[]) or IloLPMatrix.setNZs(int[], int[], double[]) IloRange:: setLinearCoefs CPXXchgcoeflist and CPXchgcoeflist
Changes a coefficient in the Q matrix IloMPModeler.addToExpr(ilog.concert.IloRange, ilog.concert.IloNumExpr) or IloObjective.setExpr(ilog.concert.IloNumExpr) IloObjective:: setExpr CPXXchgqpcoef and CPXchgqpcoef
Changes a single bound For IloNumVar, IloIntVar, and IloSemiContVar objects, use the methods setLB, setUB and IloSemiContVar. setSemiContLB For IloNumVar, IloIntVar, IloBoolVar, and IloSemiContVar objects, use the methods setLB, setUB, setBounds, and setSemiContLB CPXXchgbds and CPXchgbds
Changes multiple bounds For IloNumVar, IloIntVar, and IloSemiContVar objects, use the methods setLB, setUB and IloSemiContVar. setSemiContLB For IloNumVar, IloIntVar, IloBoolVar, and IloSemiContVar objects, use the methods setLB, setUB, setBounds, and setSemiContLB CPXXchgbds and CPXchgbds
Changes a single coefficient in objective function IloMPModeler.setLinearCoef(ilog.concert.IloObjective, ilog.concert.IloNumVar, double) or IloObjective. setExpr IloObjective:: setLinearCoef, setExpr CPXXchgobj and CPXchgobj
Changes multiple coefficients in objective function IloMPModeler.setLinearCoefs(ilog.concert.IloObjective, double[], ilog.concert.IloNumVar[]) or IloObjective. setExpr IloObjective:: setLinearCoef, setExpr CPXXchgobj and CPXchgobj
Changes a single coefficient in righthand side IloRange. setLB, setUB, IloRange#setBounds(double, double) IloRange:: setLB, setUB, setBounds CPXXchgrhs and CPXchgrhs
Changes multiple coefficients in righthand side IloRange. setLB, setUB, IloRange#setBounds(double, double) IloRange:: setLB, setUB, setBounds CPXXchgrhs and CPXchgrhs
Changes range coefficients of a set of constraints IloRange. setLB, setUB, IloRange#setBounds(double, double) IloRange:: setLB, setUB, setBounds CPXXchgrngval and CPXchgrngval
Changes name of a variable or constraint IloRange. setName For IloNumVar, IloIntVar, IloSemiContVar, use the method setName.

IloRange:: setName

For IloNumVar, IloIntVar, IloBoolVar, IloSemiContVar, use the method setName

CPXXchgname and CPXchgname
Changes names of constraints IloRange. setName IloRange:: setName CPXXchgrowname and CPXchgrowname
Changes names of variables For IloNumVar, IloIntVar, IloSemiContVar, use the method setName. For IloNumVarArray, IloIntVarArray, IloBoolVarArray, IloSemiContVarArray, use the method setName CPXXchgcolname and CPXchgcolname
Changes problem name IloModel. setName IloModel:: setName CPXXchgprobname and CPXchgprobname
Changes problem type Use IloConversion objects or IloCplex. solveFixed IloConversion objects or IloCplex:: solveFixed CPXXchgprobtype and CPXchgprobtype
Changes variable type Use IloConversion objects Use IloConversion objects CPXXchgctype and CPXchgctype
Adds a single Special Ordered Set Create and add IloSOS1 or IloSOS2 objects or use

IloMPModeler.addSOS1(ilog.concert.IloNumVar[], double[])

or

IloMPModeler.addSOS2(ilog.concert.IloNumVar[], double[])

Create and add IloSOS1 or IloSOS2 objects CPXXaddsos and CPXaddsos
Adds multiple Special Ordered Sets IloSOS classes implement the interface IloAddable, both individual objects and arrays of objects. Create and add IloSOS1Array or IloSOS2Array objects CPXXaddsos and CPXaddsos
Removes a single Special Ordered Set IloModel. remove (IloSOS classes implement the interface IloAddable, both individual objects and arrays of objects). IloSOS1:: end, IloSOS2:: end CPXXdelsetsos and CPXdelsetsos
Removes multiple Special Ordered Sets IloModel. remove (IloSOS classes implement the interface IloAddable, both individual objects and arrays of objects). IloSOS1:: removeFromAll, IloSOS2:: removeFromAll CPXXdelsetsos and CPXdelsetsos
Removes all MIP priority orders from a single variable IloCplex. delPriority IloCplex:: delPriority CPXXcopyorder and CPXcopyorder with item count set to 0 or set CPX_PARAM_MIPORDIND to 0 and order will be ignored
Removes all MIP priority orders from multiple variables IloCplex. delPriorities IloCplex:: delPriorities CPXXcopyorder and CPXcopyorder with item count set to 0 or set CPX_PARAM_MIPORDIND to 0 and order will be ignored
Removes all MIP branching directives from a single variable IloCplex. delDirection IloCplex:: delDirection CPXXcopyorder and CPXcopyorder with item count set to 0 or set CPX_PARAM_MIPORDIND to 0 and order will be ignored
Removes all MIP branching directives from multiple variables IloCplex. delDirections IloCplex:: delDirections CPXXcopyorder and CPXcopyorder with item count set to 0 or set CPX_PARAM_MIPORDIND to 0 and order will be ignored
Removes cuts IloCplex. clearCuts IloCplex:: clearCuts ----