10 std::string in_recipe,
11 std::string out_commod,
12 std::string out_recipe) {
13 in_commods_.insert(in_commod);
22 rsrc_commod_map_[rsrc->obj_id()] =
commod;
27 rsrc_commod_map_.erase(rsrc->obj_id());
32 rsrc_commod_map_[rsrc->obj_id()] =
commod;
38 in_recipes_[incommod] = recipe;
47 for (
int i = 0; i < nfuel; i++) {
49 di.
NewDatum(
"CommodityRecipeContext_inoutmap")
59 QueryResult qr = b->Query(
"CommodityRecipeContext_inoutmap", NULL);
60 for (
int i = 0; i < qr.
rows.size(); ++i) {
62 qr.
GetVal<std::string>(
"in_recipe", i),
63 qr.
GetVal<std::string>(
"out_commod", i),
64 qr.
GetVal<std::string>(
"out_recipe", i));
68 qr = b->Query(
"CommodityRecipeContext_resmap", NULL);
69 }
catch(std::exception err) {
return; }
71 for (
int i = 0; i < qr.
rows.size(); ++i) {
72 std::string
commod = qr.
GetVal<std::string>(
"commod", i);
73 int id = qr.
GetVal<
int>(
"res_id", i);
74 rsrc_commod_map_[id] =
commod;
79 std::set<std::string>::iterator it2;
80 for (it2 = in_commods_.begin(); it2 != in_commods_.end(); ++it2) {
82 di.
NewDatum(
"CommodityRecipeContext_inoutmap")
84 ->
AddVal(
"in_recipe", in_recipes_[c])
85 ->
AddVal(
"out_commod", out_commod_map_[c])
86 ->
AddVal(
"out_recipe", out_recipes_[c])
90 std::map<int, std::string>::iterator it = rsrc_commod_map_.begin();
91 for (; it != rsrc_commod_map_.end(); ++it) {
92 di.
NewDatum(
"CommodityRecipeContext_resmap")
93 ->
AddVal(
"commod", it->second)
94 ->
AddVal(
"res_id", it->first)
102 " <element name=\"fuel\"> \n"
103 " <element name=\"incommodity\"><text/></element>\n"
104 " <element name=\"inrecipe\"><text/></element>\n"
105 " <element name=\"outcommodity\"><text/></element>\n"
106 " <element name=\"outrecipe\"><text/></element>\n"
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
void Record()
Record this datum to its Recorder.
DbInit provides an interface for agents to record data to the output db that automatically injects th...
Datum * NewDatum(std::string title)
Returns a new datum to be used exactly as the Context::NewDatum method.
A class for extracting information from a given XML parser.
virtual int NMatches(std::string query)
investigates the current status and returns the number of elements matching a query
InfileTree * SubTree(std::string query, int index=0)
populates a child infile based on a query and index
virtual std::string GetString(std::string query, int index=0)
investigates the current status and returns a string representing the content of a query at a given i...
Meta data and results of a query.
std::vector< QueryRow > rows
ordered results of a query
T GetVal(std::string field, int row=0)
Convenience method for retrieving a value from a specific row and named field (column).
Interface implemented by backends that support rudimentary querying.
boost::shared_ptr< Resource > Ptr
a CommodityRecipeContext contains relationships between commodities, recipes and resources
std::string in_recipe(std::string in_commod)
virtual void Snapshot(DbInit di)
Snapshots agent-internal state to the output db via di.
virtual void InfileToDb(InfileTree *qe, DbInit di)
Translates info for the object from input file information to the database by reading parameters from...
virtual CommodityRecipeContext * Clone()
Return a newly created/allocated object that is an exact copy of this.
std::string out_commod(std::string in_commod)
void AddInCommod(std::string in_commod, std::string in_recipe, std::string out_commod, std::string out_recipe)
add an input commodity and its relations
void RemoveRsrc(Resource::Ptr rsrc)
removes a resource from the context
virtual std::string schema()
Returns an object's xml rng schema for initializing from input files.
void AddRsrc(std::string commod, Resource::Ptr rsrc)
add a resource and its commodity affiliation
std::string commod(Resource::Ptr rsrc)
void UpdateInRec(std::string in_commod, std::string recipe)
update an input recipe and its commodity affiliation
void UpdateRsrc(std::string commod, Resource::Ptr rsrc)
update a resource and its commodity affiliation
virtual void InitFrom(QueryableBackend *b)
Intializes an agent's internal state from an output database.
std::string out_recipe(std::string in_commod)
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....