4#include "CoinPackedVector.hpp"
16 std::vector<BuildOrder> orders;
20 std::map<CommodityProducer*, Builder*> p_to_b;
21 std::map<int, CommodityProducer*> idx_to_p;
22 SetUp_(iface, ctx, p_to_b, idx_to_p, commodity, demand);
23 Solve_(iface, ctx, p_to_b, idx_to_p, orders);
30 std::map<CommodityProducer*, Builder*>& p_to_b,
31 std::map<int, CommodityProducer*>& idx_to_p,
34 CoinPackedVector caps;
35 std::set<Builder*>::iterator bit;
36 std::set<CommodityProducer*>::iterator pit;
41 for (bit = builders_.begin(); bit != builders_.end(); ++bit) {
43 for (pit = b->producers().begin(); pit != b->producers().end(); ++pit) {
47 caps.insert(idx, p->
Capacity(commodity));
58 ctx.
m.setDimensions(0, ctx.
col_ubs.size());
59 ctx.
m.appendRow(caps);
62void BuildingManager::Solve_(OsiCbcSolverInterface& iface,
63 ProgTranslatorContext& ctx,
64 std::map<CommodityProducer*, Builder*>& p_to_b,
65 std::map<int, CommodityProducer*>& idx_to_p,
66 std::vector<BuildOrder>& orders) {
67 int nvar = ctx.col_ubs.size();
69 iface.
loadProblem(ctx.m, &ctx.col_lbs[0], &ctx.col_ubs[0], &ctx.obj_coeffs[0],
70 &ctx.row_lbs[0], &ctx.row_ubs[0]);
71 for (
int i = 0; i != nvar; i++) {
81 for (
int i = 0; i != nvar; i++) {
82 n =
static_cast<int>(sol[i]);
86 orders.push_back(BuildOrder(n, b, p));
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
virtual void initialSolve()
Solve initial LP relaxation.
virtual void loadProblem(const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub)
Load in an problem by copying the arguments (the constraints on the rows are given by lower and upper...
virtual void branchAndBound()
Invoke solver's built-in enumeration algorithm.
virtual void setObjSense(double s)
Set objective function sense (1 for min (default), -1 for max,)
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
virtual double getInfinity() const
Get solver's value for infinity.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
struct to hold all problem instance state
std::vector< double > col_lbs
std::vector< double > col_ubs
std::vector< double > obj_coeffs
std::vector< double > row_ubs
std::vector< double > row_lbs