[Coin-discuss] Re: Coin-discuss Digest, Vol 22, Issue 25
PAN, Zhendong
zhendongpan at 163.com
Thu Aug 31 00:51:08 EDT 2006
Hello coin-discuss-request,
Sorry for the imcomplete message, I am working on VS.net 2003.
The codes I wrote are:
//use branch and cut algorithm to solve this subproblem
OsiClpSolverInterface solver1;
// build up the LP solver.
int n_cols; //the number of variables.
n_cols = iIti * iPer;
double * objective = new double[n_cols];//the objective coefficients
double * col_lb = new double[n_cols];//the column lower bounds
double * col_ub = new double[n_cols];//the column upper bounds
for (int i = 0; i < iIti; i++)
for (int t = 0; t < iPer; t++)
objective[i * iPer + t] = this->pItiCost[i] - this->pMul[i][t] * this->iCap;
for (int i = 0; i < n_cols; i++){
col_lb[i] = 0;
col_ub[i] = 1;
}
//Define the constraint matrix.
CoinPackedMatrix * matrix = new CoinPackedMatrix(false,0,0);
matrix->setDimensions(0, n_cols);
int n_rows = iRet * iPer + iPer;
double * row_lb = new double[n_rows]; //the row lower bounds
double * row_ub = new double[n_rows]; //the row upper bounds
for (int i = 0; i < n_rows; i++)
row_ub[i] = solver1.getInfinity();
for (int r = 0; r < iRet; r++)
for (int t = 0; t < iPer; t++){
CoinPackedVector row;
for (int k = 0; k <= t; k++)
for (int i = 0; i < iIti; i++)
if (this->pIti[i][k] == true)
row.insert(i * iPer + k, 1);
matrix->appendRow(row);
double tmp = 0;
for (int k = 0; k <= t; k++)
tmp += this->pDem[r][k];
row_lb[r * iPer + t] = tmp / this->iCap;
}
for (int t = 0; t < iPer; t++){
CoinPackedVector row;
for (int k = 0; k <= t; k++)
for (int i = 0; i < iIti; i++)
row.insert(i * iPer + k, 1);
matrix->appendRow(row);
double tmp = 0;
for (r = 0; r < iRet; r++)
for (k = 0; k <= t; k++)
tmp += this->pDem[r][k];
row_lb[iRet * iPer + t] = tmp / this->iCap;
}
//load the problem to OSI
solver1.loadProblem(*matrix, col_lb, col_ub, objective, row_lb, row_ub);
//write the MPS file to a file called example.mps
solver1.writeMps("example1");
// Pass the solver with the problem to be solved to CbcModel
CbcModel model(solver1);
// Do complete search
model.branchAndBound();
/* Print the solution. CbcModel clones the solver so we
need to get current copy from the CbcModel */
const double * solution = model.bestSolution();
system("pause");
Best regards,
======= At 2006-08-31, 00:00:20 you wrote: =======
>Send Coin-discuss mailing list submissions to
> coin-discuss at list.coin-or.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://list.coin-or.org/mailman/listinfo/coin-discuss
>or, via email, send a message with subject or body 'help' to
> coin-discuss-request at list.coin-or.org
>
>You can reach the person managing the list at
> coin-discuss-owner at list.coin-or.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Coin-discuss digest..."
>
>
>Today's Topics:
>
> 1. error at3100 in AMPL using CBC ( Nicol?s Anastasiadis )
> 2. Re: error at3100 in AMPL using CBC (J P Fasano)
> 3. Questions for CbcModel (PAN, Zhendong)
> 4. Re: Questions for CbcModel ( Nicol?s Anastasiadis )
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Tue, 29 Aug 2006 14:02:12 -0400
>From: " Nicol?s Anastasiadis " <anastasiadis at gmail.com>
>Subject: [Coin-discuss] error at3100 in AMPL using CBC
>To: coin-discuss at list.coin-or.org
>Message-ID:
> <e045e9e00608291102h77773cfdi463a700e2bbec4bb at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Hi
>I downloaded the cbc code and builded the cbc.exe file as says the
>https://projects.coin-or.org/MSVisualStudio page, using MSVisual Stuido 6. I
>copyed the cbc.exe file in the ampl folder to try solve my problems but
>after the resume of variables and constraints I got this error message:
>Default solver is clp
>Unable to open file.\at3100
>No match for AMPL - ? for list of cammands
>can/t open at3100.sol
>
>I really don't know what does it mean. I need a file? When did I miss
>creating it? How can I get it? Is that file the only one that I need?
>Thanks a lot
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: http://list.coin-or.org/pipermail/coin-discuss/attachments/20060829/7f3db4c4/attachment-0001.html
>
>------------------------------
>
>Message: 2
>Date: Tue, 29 Aug 2006 15:12:05 -0400
>From: J P Fasano <jpfasano at us.ibm.com>
>Subject: Re: [Coin-discuss] error at3100 in AMPL using CBC
>To: Discussions about open source software for Operations Research
> <coin-discuss at list.coin-or.org>
>Message-ID:
> <OFD97C26F7.5BDAF330-ON852571D9.00691A26-852571D9.0069758F at us.ibm.com>
>Content-Type: text/plain; charset=US-ASCII
>
>> I downloaded the cbc code and builded the cbc.exe file as says the
>> https://projects.coin-or.org/MSVisualStudio page, using MSVisual
>> Stuido 6. I copyed the cbc.exe file in the ampl folder to try solve
>> my problems but after the resume of variables and constraints I got
>> this error message:
>> Default solver is clp
>> Unable to open file.\at3100
>> No match for AMPL - ? for list of cammands
>> can/t open at3100.sol
>
>The MSVisualStudio build is not setup to build the Cbc Ampl driver.
>
>To build the CBC AMPL driver see the faq "How do you build the COIN-OR Cbc
>AMPL solver executable on Unix-like platforms (including Cygwin and MinGW)
>from the SUBVERSION Cbc code base?" on page
>https://projects.coin-or.org/Cbc/wiki/FAQ.
>
>Since you are using windows, you will want to use Cygwin or MinGW.
>
>
>
>------------------------------
>
>Message: 3
>Date: Wed, 30 Aug 2006 17:03:35 +0800
>From: "PAN, Zhendong" <zhendongpan at 163.com>
>Subject: [Coin-discuss] Questions for CbcModel
>To: "coin-discuss" <coin-discuss at list.coin-or.org>
>Message-ID: <44F5534C.03AD28.09534>
>Content-Type: text/plain; charset="gb2312"
>
>Hello coin-discuss,
>
>I tried to use CbcModel to solve a integer program problem. However, the results returned is
>
>
>Cbc3007W No integer variables - nothing to do
>Clp0006I 0 Obj 0 Primal inf 70.5 (24)
>Clp0006I 4 Obj 177.5
>Clp0000I Optimal - objective value 177.5
>Clp0006I 0 Obj 0 Primal inf 70.5 (24)
>Clp0006I 4 Obj 177.5
>Clp0000I Optimal - objective value 177.5
>Cbc0004I Integer solution of 177.5 found after 0 iterations and 0 nodes
>Cbc0001I Search completed - best objective 177.5, took 0 iterations and 0 nodes
>Clp0006I 0 Obj 0 Primal inf 70.5 (24)
>Clp0006I 4 Obj 177.5
>Clp0000I Optimal - objective value 177.5
>Cbc0004I Integer solution of 177.5 found after 0 iterations and 0 nodes
>Clp0000I Optimal - objective value 177.5
>
>How can I tell the CbcModel which variables are integer. I found no such examples on http://www.coin-or.org/Cbc/index.html.
>
>Best regards,
>
>PAN, Zhendong
>zhendongpan at 163.com
>2006-08-30
>
>
>
>
>------------------------------
>
>Message: 4
>Date: Wed, 30 Aug 2006 10:31:50 -0400
>From: " Nicol?s Anastasiadis " <anastasiadis at gmail.com>
>Subject: Re: [Coin-discuss] Questions for CbcModel
>To: "Discussions about open source software for Operations Research"
> <coin-discuss at list.coin-or.org>
>Message-ID:
> <e045e9e00608300731n7e3200cfic3d13499f20ec8cc at mail.gmail.com>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Hi
>Where are you using the CbcModel? at Neos Server or you builded the file on
>your pc? Are you using AMPL?
>
>Nico
>
>On 8/30/06, PAN, Zhendong <zhendongpan at 163.com> wrote:
>>
>> Hello coin-discuss,
>>
>> I tried to use CbcModel to solve a integer program problem. However, the
>> results returned is
>>
>>
>> Cbc3007W No integer variables - nothing to do
>> Clp0006I 0 Obj 0 Primal inf 70.5 (24)
>> Clp0006I 4 Obj 177.5
>> Clp0000I Optimal - objective value 177.5
>> Clp0006I 0 Obj 0 Primal inf 70.5 (24)
>> Clp0006I 4 Obj 177.5
>> Clp0000I Optimal - objective value 177.5
>> Cbc0004I Integer solution of 177.5 found after 0 iterations and 0 nodes
>> Cbc0001I Search completed - best objective 177.5, took 0 iterations and 0
>> nodes
>> Clp0006I 0 Obj 0 Primal inf 70.5 (24)
>> Clp0006I 4 Obj 177.5
>> Clp0000I Optimal - objective value 177.5
>> Cbc0004I Integer solution of 177.5 found after 0 iterations and 0 nodes
>> Clp0000I Optimal - objective value 177.5
>>
>> How can I tell the CbcModel which variables are integer. I found no such
>> examples on http://www.coin-or.org/Cbc/index.html.
>>
>> Best regards,
>>
>> PAN, Zhendong
>> zhendongpan at 163.com
>> 2006-08-30
>>
>>
>> _______________________________________________
>> Coin-discuss mailing list
>> Coin-discuss at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/coin-discuss
>>
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL: http://list.coin-or.org/pipermail/coin-discuss/attachments/20060830/87d4a6ef/attachment-0001.html
>
>------------------------------
>
>_______________________________________________
>Coin-discuss mailing list
>Coin-discuss at list.coin-or.org
>http://list.coin-or.org/mailman/listinfo/coin-discuss
>
>
>End of Coin-discuss Digest, Vol 22, Issue 25
>********************************************
>
= = = = = = = = = = = = = = = = = = = =
PAN, Zhendong
zhendongpan at 163.com
2006-08-31
More information about the Coin-discuss
mailing list