[Cbc] 回复: How to add cuts?

Haroldo Gambini Santos haroldo.santos at gmail.com
Thu Mar 17 10:47:32 EDT 2016


Dear Meng,

You should create a new class inheriting from CglCutGenrator.  Here goes 
one I create (just one file as example, will not compile because other 
files are not included).

After creating this class,  beforing calling branch and bound (or 
CbcMain) you should add this cut generator:

cbcModel.addCutGenrator

Cheers

On 14-03-2016 11:44, 不入角蜗牛 wrote:
> What class inherited from CglCutGenerator should I to use? I can't 
> find one to adjust my question which should add some cuts during 
> function branchAndBound through the CbcEventHandler.
>
> Best wishes.
> Meng Chen
>
>
> ------------------ 原始邮件 ------------------
> *发件人:* "Haroldo Gambini Santos"<haroldo.santos at gmail.com>;
> *发送时间:* 2016年3月14日(星期一) 上午9:17
> *收件人:* "不入角蜗牛"<1164651620 at qq.com>; "cbc"<cbc at list.coin-or.org>;
> *主题:* Re: [Cbc] How to add cuts?
>
> Hi,
>
> You should specialize a  CglCutGenerator class to implement cut 
> generation.
>
> Then you need to implement:
> generateCuts( const OsiSolverInterface &si, OsiCuts &cs, const 
> CglTreeInfo info )
>
> Use /si/ to obtain the fractional solution and add discovered cuts in 
> /cs/.
>
> Cheers,
>
> Haroldo
>
> Em 13-03-2016 22:07, 不入角蜗牛 escreveu:
>> Hello.
>> I try to use the class CbcEventHandler to add cuts to solve my 
>> problem, but it doesn't work.
>> for example :
>> min: x2
>> s.t. x0 + x1 >= 1;
>>       x1 + x2 >= 1;
>> x0,x1,x2 in {0,1}
>> Add the question normally. I get x0 = 1, x1 = 1 and x2 = 0. But when 
>> I try to add a cut x0 = 0 with codes:
>> <\code
>>         auto refSolver = model->referenceSolver();
>>         CoinPackedVector solution_cut;
>>         solution_cut.setVector(len, &cols[cols.size()-len], 
>> &values[values.size()-len]);
>>         refSolver->addRow(solution_cut, rhs_lower.back(), 
>> rhs_upper.back());
>>         model->resetToReferenceSolver();
>> code\>
>> But failed. I save the model as mps file and it can be read as:
>>  TITLE BLANK;
>>  [ OBJROW] MIN =  C0000002;
>>  [ R0000000]  C0000000 +  C0000001 >= 1;
>>  [ R0000001]  C0000001 +  C0000002 >= 1;
>>  [ R0000002]  C0000000 = 0;
>>  @BND( 0, C0000000, 0); @BND( 0, C0000001, 0);
>>  @BND( 0, C0000002, 0);
>> Thanks.
>>
>>
>> _______________________________________________
>> Cbc mailing list
>> Cbc at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/cbc
>
> -- 
> ==================================================
> Haroldo Gambini Santos
> D.Sc, Computer Science
> Universidade Federal de Ouro Preto
> http://www.decom.ufop.br/haroldo/

-- 
==================================================
Haroldo Gambini Santos
D.Sc, Computer Science
Universidade Federal de Ouro Preto
http://www.decom.ufop.br/haroldo/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20160317/b6299dc1/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CglEClique.cpp
Type: text/x-c++src
Size: 8958 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20160317/b6299dc1/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CglEClique.hpp
Type: text/x-c++hdr
Size: 1023 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20160317/b6299dc1/attachment-0003.bin>


More information about the Cbc mailing list