/home/coin/SVN-release/OS-2.1.1/Bcp/src/LP/BCP_lp_create_lp.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 #include "OsiSolverInterface.hpp"
00005 #include "CoinWarmStart.hpp"
00006 
00007 #include "BCP_matrix.hpp"
00008 #include "BCP_problem_core.hpp"
00009 #include "BCP_warmstart.hpp"
00010 #include "BCP_lp_node.hpp"
00011 #include "BCP_lp_user.hpp"
00012 #include "BCP_lp_pool.hpp"
00013 #include "BCP_lp.hpp"
00014 #include "BCP_lp_functions.hpp"
00015 
00016 void BCP_lp_create_lp(BCP_lp_prob& p)
00017 {
00018   p.user->load_problem(*p.lp_solver, p.core, p.node->vars, p.node->cuts);
00019   BCP_var_set& vars = p.node->vars;
00020   BCP_cut_set& cuts = p.node->cuts;
00021   const int varnum = vars.size();
00022   const int cutnum = cuts.size();
00023 
00024   // Now fix the bounds
00025   const int num = std::max<int>(varnum, cutnum);
00026   BCP_vec<int> ind;
00027   ind.reserve(num);
00028   int i = -1;
00029   while (++i < num) {
00030     ind.unchecked_push_back(i);
00031   }
00032 
00033   BCP_vec<double> bd;
00034   bd.reserve(2 * num);
00035   BCP_var_set::const_iterator vi = vars.begin();
00036   BCP_var_set::const_iterator lastvi = vars.end();
00037   for ( ; vi != lastvi; ++vi) {
00038     bd.unchecked_push_back((*vi)->lb());
00039     bd.unchecked_push_back((*vi)->ub());
00040   }
00041   p.lp_solver->setColSetBounds(ind.begin(), ind.entry(varnum), bd.begin());
00042 
00043   bd.clear();
00044   BCP_cut_set::const_iterator ci = cuts.begin();
00045   BCP_cut_set::const_iterator lastci = cuts.end();
00046   for ( ; ci != lastci; ++ci) {
00047     bd.unchecked_push_back((*ci)->lb());
00048     bd.unchecked_push_back((*ci)->ub());
00049   }
00050   p.lp_solver->setRowSetBounds(ind.begin(), ind.entry(cutnum), bd.begin());
00051 
00052   // The rows/cols corresponding to the cached cuts/vars are not valid
00053   if (p.local_cut_pool) {
00054     p.local_cut_pool->rows_are_valid(false);
00055   }
00056   if (p.local_var_pool) {
00057     p.local_var_pool->cols_are_valid(false);
00058   }
00059 
00060   //--------------------------------------------------------------------------
00061   // The last step is to initialize warmstarting if we can. After
00062   // warmstarting info is used up we won't need it again. If there will be any
00063   // warmstarting info needed regarding this node, that info is what we'll
00064   // get at the end of processing the node. So delete the current ws info.
00065   if (p.node->warmstart) {
00066     CoinWarmStart* ws = p.node->warmstart->convert_to_CoinWarmStart();
00067     p.lp_solver->setWarmStart(ws);
00068     delete ws;
00069     delete p.node->warmstart;
00070     p.node->warmstart = 0;
00071   }
00072 }

Generated on Mon May 3 03:05:11 2010 by  doxygen 1.4.7