CoinPackedMatrix * matrix = new CoinPackedMatrix(true,0,0); matrix->setDimensions(n_rows, 0); // Create cols and append them to matrix // First, create cols related with x for (i = 0; i < M; ++i) { for (j = 0; j < N; ++j) { CoinPackedVector col; col.insert(i, 1.0); col.insert(j+M, 1.0); matrix->appendCol(col); } } // Then, create cols related with y for (j = 0; j < N; ++j) { CoinPackedVector col2; col2.insert(j+M, -total_demand); matrix->appendCol(col2); }