[Cbc] Intermediate Results

Tobias Stengel Tobias.Stengel at locom.de
Mon Jul 10 11:21:02 EDT 2017


It is not that difficult (assuming you are using something like Cbc/samples/driver4.cpp, remove the "static int callBack(CbcModel * model, int whereFrom)" function):

 - Create your on subclass of  CbcEventHandler if you don't have one [1]. Override event(CbcEvent). In driver4.cpp there is "MyEventHandler3" which queries each new solution as soon as one is found.

- a feasible solution can be loaded like this:
CbcModel* model = ...
std::vector<std::pair<std::string, double> > sol; auto solver = model->solver();
double* initialSolution = ...
for (int i = 0; i < number_of_columns; ++i) {
	const auto val = initialSolution[i];
	sol.emplace_back(solver->getColName(i), val); }

model->setMIPStart(sol);

Note that setting the MIPStart does not prevent CBC from visiting (at least some) of the nodes it visited in the previous run. 
So fixing the power supply will be better.

Tobias

[1] https://www.coin-or.org/Doxygen/Cbc/classCbcEventHandler.html
[2] https://www.coin-or.org/Doxygen/Cbc/classCbcModel.html#a3a1e768202835e9ee3c6d415e992e543



-----Ursprüngliche Nachricht-----
Von: Cbc [mailto:cbc-bounces at coin-or.org] Im Auftrag von Christopher Gross
Gesendet: Montag, 10. Juli 2017 16:50
An: cbc at list.coin-or.org
Betreff: Re: [Cbc] Intermediate Results

Hi Jeff,

being only an average C programmer myself and having looked at CBC code before, I would assume that storing and loading intermediate solution data will be quite a feat. Unfortunately, I can't give you any advice on that.

However, I would suggest a different solution that works not only for
CBC: Have you ever thought about getting an uninterrupted power supply (UPS)? Consumer units are available for less than 100USD and will last about 5-20 minutes, depending on the size of the device and your power consumption. If your power outages aren't longer than that, this should be sufficient to continue running your computations.

If your power outages are longer than that, you could also consider running CBC in a virtual machine. Those can be paused and resumed at a later point in time. When the power goes out, your UPS will signal your guest system which will pause the virtual machine and shut down the system. You can then power it back up when the power is back on and resume the virtual machine, continuing your calculations.

Hope that helps.

Best regards,

Christopher

On 2017-07-10 15:49, Jeff Willert wrote:
> I have recently started using CBC both standalone and through the PuLP 
> interface.  Some of my problems become rather large and take a 
> significant amount of time to run.  Unfortunately, I've been having 
> issues with computer reliability (power outages and such) and if the 
> optimization hasn't completed, I lose all of the progress which has 
> been made.
> 
> Does CBC currently have the ability to write (to a file) the current 
> best solution at some interval, either in time or based on an 
> iteration count?  I've been looking at the source code but I am only a 
> moderate C programmer and haven't been able to find an easy way to do 
> this.  I'm happy to make changes to the code myself on my local copy 
> if someone could point me to the correct location.  Even an 
> approximate solution is better than losing all progress.
> 
> Regards,
> Jeff
> 
> 
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.or
> g_mailman_listinfo_cbc&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWP
> A_2Wlc4&r=gEVaymfbiUvp55D10lWK6mFSIIFoSWnM41MvN3xiko6wjVENkHAS1IDcdpwn
> gCCy&m=vU7ldw2G_FnOiwF6LzEqInJmI-c3LU0ZdJbjz2dLUtA&s=9h8XAYvraSGlKjFkU
> 5k6pDTjF0_lUajzEXZKpbmXndw&e=
> 

--
Christopher Gross, M.Sc.

Lehrstuhl für Health Care Operations/Health Information Management

Universitäres Zentrum für Gesundheitswissenschaften am Klinikum Augsburg (UNIKA-T), Neusässer Straße 47, 86156 Augsburg;

Wirtschaftswissenschaftliche Fakultät, Universität Augsburg, Universitätsstraße 16, 86159 Augsburg


Tel.: +49 821 598-6452

E-Mail:  christopher.gross at unikat.uni-augsburg.de
Web:  https://urldefense.proofpoint.com/v2/url?u=http-3A__www.unika-2Dt.de_&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=zU1-bo4qay1GSxqnW8lKSuGZO4rtR2XKpD4FKabSFw8&m=2opujEm6AKOMaW_68TgwVQUe5l_PIR6UYRQCEHFVUqY&s=JEpeyKDI4-QhbOIXGrFjyvO0_roHye4MTgYVvYEeVm0&e=
_______________________________________________
Cbc mailing list
Cbc at list.coin-or.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cbc&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=zU1-bo4qay1GSxqnW8lKSuGZO4rtR2XKpD4FKabSFw8&m=2opujEm6AKOMaW_68TgwVQUe5l_PIR6UYRQCEHFVUqY&s=86AV8-RKq-46OnS-iTFOyMjBx5dqf-4aj64i2ruqKHY&e= 



More information about the Cbc mailing list