[Cbc] Problem in using SOS and LotSize objects

mg giunto.cardanico at gmail.com
Sun Jun 29 04:50:28 EDT 2014


Perfect!
Thank you very much John.


2014-06-28 17:24 GMT+02:00 John Forrest <john.forrest at fastercoin.com>:

>  Marco,
>
> My mistake (and laziness).  Each branching object should tighten the
> bounds.  This was being done on branching, but when I dug into code - not
> on final check of solution.  I have updated trunk and it now works.
>
> John Forrest
>
> On 28/06/14 11:59, mg wrote:
>
> Sorry for bothering you again, just one small doubt remaining.
> You said that in my lotsize example, the integrality of a variable was
> overridden by the lotsize object.
> In cases like this, when one or more objects give branching constraints on
> the same variable, is there a rule to solve these kind of conflicts ?
> e.g. object with higher priority wins ?
>
>  Thanks again
>
>
> 2014-06-28 12:30 GMT+02:00 mg <giunto.cardanico at gmail.com>:
>
>> Thanks a lot John for the bug fixes and extensive explanation.
>>
>>
>>
>>
>> 2014-06-28 10:14 GMT+02:00 John Forrest <john.forrest at fastercoin.com>:
>>
>>  Marco,
>>>
>>> I would strongly recommend going to Cbc/trunk as then I can quickly fix
>>> things for you.
>>>
>>> There are three! ways of passing in  SOS to Cbc -
>>> 1) SOS indicated in an mps file going in via OsiClp.
>>> 2) SOS set in CbcModel.solver() by OsiSOS
>>> 3) SOS set in CbcModel by CbcSOS
>>>
>>> 1) and 3) were working but 2) was not being detected (now fixed) - so
>>> probably better to have
>>>
>>>     objs[0]= new CbcSOS(&model,3,which,NULL,0,1);
>>>     model.addObjects(1,objs);
>>>
>>> in your code.
>>>
>>> The Lotsizing example does work on stable - but I can see problems with
>>> stable.  Osi and OsiClp do not know about lotsizing so again you need to
>>> use model.addObjects(1,objs).
>>>
>>> This worked on stable if I used model.branchAndBound().  I have fixed in
>>> trunk so that callCbc also works correctly.
>>>
>>> However for safety you need to modify your code a bit - by playing
>>> around a bit with bounds I managed to get a solution with x1 at 6.33333,
>>> even though x1 was declared as integer.  This is because a lotsizing
>>> decision overrode the integer decision.  There is no elegant change to code
>>> to fix that problem, but the solution is trivial.  If you really want
>>> ranges of valid values in a lotsizing variable then do not declare it to be
>>> integer.  If you want a subset of points, then again do not declare it as
>>> integer but use something like -
>>>
>>>     double points[7] =  {0.0,3.0,4.0,5.0,6.0,8.0,10.0};
>>>     objs[0] = new CbcLotsize(&model,1,7,points);
>>>     model.addObjects(1,objs);
>>>
>>> If you want something even more complicated then it is easy to derive a
>>> MyLotsizing object which does exactly what you want.
>>>
>>> I attach a (much) modified version of your code (adjusted for gcc).
>>>
>>> I hope this helps.
>>>
>>>
>>> John Forrest
>>> On 27/06/14 15:50, mg wrote:
>>>
>>>  Hi all,
>>> I'm trying to use SOS and LotSize/SemiContinuous objects without success.
>>>
>>>  I have created a very simple program (attached) containing a small
>>> problem with SOS and a small problem using LotSize objects...
>>>
>>>  The SOS test problem is the following:
>>>
>>>  max         3 * x0 + 2 * x1 + 4 * x2
>>> subject to
>>>             x0, x1, x2 binary
>>>             sos1(x0, x1, x2)
>>>
>>>  and solving it, I get x0 = 1, x1= 1, x2 = 1 where I expected just one
>>> single 1...
>>>
>>>  The LotSize/SemiContinuous test problem is the following:
>>>
>>>  min         2 * x0 + 3 * x1 + x2
>>> subject to
>>>             3 * x0 + 5 * x1 + 7 * x2 <= 42
>>>             4 * x0 + 3 * x1 + 2 * x2 <= 31
>>>             2 * x0 + 1 * x1 + 5 * x2 <= 23
>>>             x0, x1, x2 integers [0,4]
>>>             x1 semi-continuous can be 0 or [3,4]
>>>
>>>  and solving it, I get x0 = 4, x1 = 2 where I expected x1 being 0,3 or 4
>>>
>>>  Am I doing something wrong ?
>>>
>>>  Thanks in advance,
>>> Marco
>>>
>>>
>>>   _______________________________________________
>>> Cbc mailing listCbc at list.coin-or.orghttp://list.coin-or.org/mailman/listinfo/cbc
>>>
>>>
>>>
>>> _______________________________________________
>>> Cbc mailing list
>>> Cbc at list.coin-or.org
>>> http://list.coin-or.org/mailman/listinfo/cbc
>>>
>>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20140629/aa532093/attachment.html>


More information about the Cbc mailing list