I guess you used a non-NULL ctype argument for function CPXnewcols. The below program works just fine. It creates your model and solves it without issue.
#include <stdio.h>
#include <stdlib.h>
#include <ilcplex/cplexx.h>
static double const obj[] = { 0.0, 0.0 };
static double const lb[] = { 0, -CPX_INFBOUND };
static double const ub[] = { 1, CPX_INFBOUND };
static char const *const name[] = { "x1", "x2" };
#ifdef PRODUCE_MIP
static char const ctype[] = { 'C', 'C' };
#else
static char const *ctype = NULL;
#endif
int
main(void)
{
CPXENVptr env;
CPXLPptr lp;
int status;
if ( (env = CPXXopenCPLEX(&status)) == NULL || status != 0 ) {
fprintf (stderr, "CPXXopenCPLEX: %d\n", status);
abort();
}
if ( (lp = CPXXcreateprob(env, &status, "model")) == NULL || status != 0 ) {
fprintf (stderr, "CPXXcreateprob: %d\n", status);
abort ();
}
status = CPXXnewcols (env, lp, 2, obj, lb, ub, ctype, name);
if ( status != 0 ) {
fprintf (stderr, "CPXXnewcols: %d\n", status);
abort ();
}
status = CPXXwriteprob (env, lp, "model.lp", NULL);
if ( status != 0 ) {
fprintf (stderr, "CPXXwriteprob: %d\n", status);
abort ();
}
status = CPXXlpopt (env, lp);
if ( status != 0 ) {
fprintf (stderr, "CPXXlpopt: %d\n", status);
abort ();
}
CPXXfreeprob (env, &lp);
CPXXcloseCPLEX (&env);
printf ("Success\n");
return 0;
}
Note that I pass a NULL pointer as ctype to CPXnewcols. When I pass a non-NULL pointer as ctype (define PRODUCE_MIP) then CPLEX will always consider the problem as a MIP, even if all entries in ctype are 'C'.
This is expected behavior and is specified in the reference documentation for CPXnewcols.
#CPLEXOptimizers#DecisionOptimization