/* $Id: modify.cpp 1662 2011-01-04 17:52:40Z lou $ */ // Copyright (C) 2007, International Business Machines // Corporation and others. All Rights Reserved. // This code is licensed under the terms of the Eclipse Public License (EPL). /* This example shows the creation of a model from arrays, solution and then changes to objective and adding a row */ #include "ClpSimplex.hpp" #include "CoinHelperFunctions.hpp" #include #define N 5 #define M 2 #define numberElements N*M * (N+M+M) using namespace std; int main(int argc, const char *argv[]) { ClpSimplex model; //int N = 5; //int M = 2; int numberRow1 = N; int numberRow2 = M; int numberRow3 = M; int numberColumns = N*M; int numberRows = N + M + M; //int numberElements = numberColumns * (numberRow1 + numberRow2 + numberRow3); double c[N][M] = { { -1,-3 },{ -2,-1 },{ -3,-2 },{ -2,-1 },{ -0,-1 } }; double a[N][M] = { { 2,0 },{ 0,5 },{ 3,1 },{ 4,5 },{ 1,3 } }; double b[M] = { 1,1 }; // matrix data - column ordered CoinBigIndex start[N*M + 1]; //COLUMN 的个数迭代之和 start[0] = 0; for (int i = 1; i < N*M + 2; i++) { start[i] = start[i - 1] + N + M + M; } //int length[N*M] = {3,3,3,3,3,3,3,3,3,3}; int length[N*M]; for (int i = 0; i < N*M; i++) { length[i] = M + M + N; } //numberElements = numberColumns * (numberRow1 + numberRow2 + numberRow3) = 90 // position of the vars //int rows[30] = { 0,5,7,1,5,7,2,5,7,3,5,7,4,5,7,0,6,8,1,6,8,2,6,8,3,6,8,4,6,8 }; //有数据的变量所在位置 int rows[numberElements]; for (int i = 0; i < numberElements; i++) { rows[i] = i % 9; cout <<"rows: "<