CPXXcopyctype and CPXcopyctype

The routine CPXXcopyctype/CPXcopyctype can be used to copy variable type information into a given problem.

int  CPXXcopyctype( CPXCENVptr env, CPXLPptr lp, char const * xctype )

int  CPXcopyctype( CPXCENVptr env, CPXLPptr lp, char const * xctype )

Description

The routine CPXXcopyctype/CPXcopyctype can be used to copy variable type information into a given problem. Variable types specify whether a variable is continuous, integer, binary, semi-continuous, or semi-integer. Adding xctype information automatically changes the problem type from continuous to mixed integer (from CPXPROB_LP to CPXPROB_MILP, from CPXPROB_QP to CPXPROB_MIQP, and from CPXPROB_QCP to CPXPROB_MIQCP), even if the provided xctype data specifies that all variables are continuous.

This routine allows the types of all the variables to be set in one function call. When CPXXcopyctype/CPXcopyctype is called, any current solution information is freed.

Important: Defining a variable j to be binary by setting the corresponding xctype[j]='B' does not change the bounds associated with that variable. A later call to CPXXmipopt/CPXmipopt will change the bounds to 0 (zero) and 1 (one) and issue a warning.

Table 1. Table 1: Possible values for elements of xctype
CPX_CONTINUOUS 'C' continuous variable
CPX_BINARY 'B' binary variable
CPX_INTEGER 'I' general integer variable
CPX_SEMICONT 'S' semi-continuous variable
CPX_SEMIINT 'N' semi-integer variable

When you build or modify your problem with this routine, you can verify that the results are as you intended by calling CPXcheckcopyctype during application development.

Arguments

env
A pointer to the CPLEX environment as returned by CPXXopenCPLEX/CPXopenCPLEX.
lp
A pointer to a CPLEX problem object as returned by CPXXcreateprob/CPXcreateprob.
xctype
An array of length CPXgetnumcols(env, lp) containing the type of each column in the constraint matrix. Possible values appear in Table 1.

Return

The routine returns 0 (zero) if successful and nonzero if an error occurs.

Example


 status = CPXcopyctype (env, lp, ctype);

See also the example mipex1.c distributed with the product.