10 std::string in_recipe,
11 std::string out_commod,
12 std::string out_recipe) {
27 rsrc_commod_map_.erase(
rsrc->obj_id());
46 int nfuel =
qe->NMatches(
"fuel");
47 for (
int i = 0; i <
nfuel; i++) {
49 di.NewDatum(
"CommodityRecipeContext_inoutmap")
50 ->AddVal(
"in_commod",
fuel->GetString(
"incommodity"))
51 ->AddVal(
"in_recipe",
fuel->GetString(
"inrecipe"))
52 ->AddVal(
"out_commod",
fuel->GetString(
"outcommodity"))
53 ->AddVal(
"out_recipe",
fuel->GetString(
"outrecipe"))
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")
83 ->AddVal(
"in_commod",
c)
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"
DbInit provides an interface for agents to record data to the output db that automatically injects th...
A class for extracting information from a given XML parser.
InfileTree * SubTree(std::string query, int index=0)
populates a child infile based on a query and index
Meta data and results of a query.
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....
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters