5#include "CoinPackedVector.hpp"
6#include "OsiSolverInterface.hpp"
51void ProgTranslator::Init() {
52 arc_offset_ = g_->
arcs().size();
60void ProgTranslator::CheckPref(
double pref) {
63 ss <<
"Preference value found to be nonpositive (" << pref
64 <<
"). Preferences must be positive when using an optimization solver."
65 <<
" If using Cyclus in simulation mode (e.g., from the command line),"
66 <<
" this error is likely a bug in Cyclus. Please report it to the developer's "
67 <<
"list (https://groups.google.com/forum/#!forum/cyclus-dev).";
68 throw ValueError(
ss.str());
77 nfalse +=
rgs[i].get()->HasArcs() ? 1 : 0;
79 ctx_.
m.setDimensions(0,
n_cols);
83 for (
int i = 0; i !=
sgs.size(); i++) {
85 XlateGrp_(
sgs[i].get(), request);
88 for (
int i = 0; i !=
rgs.size(); i++) {
90 XlateGrp_(
rgs[i].get(), request);
96 double inf = iface_->getInfinity();
97 for (
int i = g_->
arcs().size(); i != arc_offset_; i++) {
105 iface_->setObjSense(1.0);
113 std::vector<Arc>& arcs = g_->
arcs();
114 for (
int i = 0; i != arcs.size(); i++) {
117 iface_->setInteger(g_->
arc_ids()[
a]);
130 double inf = iface_->getInfinity();
131 std::vector<double>&
caps =
grp->capacities();
133 if (request && !
grp->HasArcs())
136 std::vector<CoinPackedVector>
cap_rows;
138 for (
int i = 0; i !=
caps.size(); i++) {
142 std::vector<ExchangeNode::Ptr>& nodes =
grp->nodes();
143 for (
int i = 0; i != nodes.size(); i++) {
144 std::map<Arc, std::vector<double> >&
ucap_map = nodes[i]->unit_capacities;
145 std::map<Arc, std::vector<double> >::iterator
cap_it;
154 for (
int j = 0; j !=
ucaps.size(); j++) {
156 if (excl_ &&
a.exclusive()) {
179 for (
int i = 0; i !=
cap_rows.size(); i++) {
194 std::vector< std::vector<ExchangeNode::Ptr> >&
exngs =
195 grp->excl_node_groups();
196 for (
int i = 0; i !=
exngs.size(); i++) {
198 std::vector<ExchangeNode::Ptr>& nodes =
exngs[i];
199 for (
int j = 0; j != nodes.size(); j++) {
201 for (
int k = 0; k != arcs.size(); k++) {
205 if (
excl_row.getNumElements() > 0) {
211 for (
int i = 0; i !=
excl_rows.size(); i++) {
220 const double*
sol = iface_->getColSolution();
221 std::vector<Arc>& arcs = g_->
arcs();
223 for (
int i = 0; i < arcs.size(); i++) {
An arc represents a possible connection between two nodes in the bipartite resource exchange graph.
An ExchangeGraph is a resource-neutral representation of a ResourceExchange.
const std::vector< Arc > & arcs() const
const std::vector< ExchangeNodeGroup::Ptr > & supply_groups() const
const std::map< ExchangeNode::Ptr, std::vector< Arc > > & node_arc_map() const
const std::map< Arc, int > & arc_ids() const
const std::vector< RequestGroup::Ptr > & request_groups() const
void AddMatch(const Arc &a, double qty)
adds a match for a quanity of flow along an arc
const std::map< int, Arc > & arc_by_id() const
A ExchangeNodeGroup is a collection of ExchangeNodes, and is the ExchangeGraph representation of a Bi...
static double Cost(const Arc &a, bool exclusive_orders=kDefaultExclusive)
return the cost of an arc
ProgTranslator(ExchangeGraph *g, OsiSolverInterface *iface)
constructor
void FromProg()
translates solution from iface back into graph matches
void Populate()
populates the solver interface with values from the translators Context
void ToProg()
translates graph into mathematic program via iface.
void Translate()
translates the graph, filling the translators Context
Code providing rudimentary logging capability for the Cyclus core.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
@ LEV_DEBUG1
debugging information - least verbose
double eps()
a generic epsilon value
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
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