45 EXPECT_DOUBLE_EQ(0.0, src_facility->InventorySize());
46 EXPECT_DOUBLE_EQ(capacity_, src_facility->Capacity());
47 EXPECT_DOUBLE_EQ(inv_, src_facility->MaxInventorySize());
48 EXPECT_DOUBLE_EQ(capacity_, src_facility->SpaceAvailable());
49 EXPECT_DOUBLE_EQ(0.0, src_facility->InventorySize());
50 std::string arr[] = {commod1_, commod2_};
51 std::vector<std::string> vexp (arr, arr +
sizeof(arr) /
sizeof(arr[0]) );
52 EXPECT_EQ(vexp, src_facility->input_commodities());
54 src_facility->EnterNotify();
55 double pref[] = {cyclus::kDefaultPref, cyclus::kDefaultPref};
56 std::vector<double> vpref (pref, pref +
sizeof(pref) /
sizeof(pref[0]) );
57 EXPECT_EQ(vpref, src_facility->input_commodity_preferences());
64 (src_facility->Clone());
66 EXPECT_DOUBLE_EQ(0.0, cloned_fac->InventorySize());
67 EXPECT_DOUBLE_EQ(capacity_, cloned_fac->Capacity());
68 EXPECT_DOUBLE_EQ(inv_, cloned_fac->MaxInventorySize());
69 EXPECT_DOUBLE_EQ(capacity_, cloned_fac->SpaceAvailable());
70 std::string arr[] = {commod1_, commod2_};
71 std::vector<std::string> vexp (arr, arr +
sizeof(arr) /
sizeof(arr[0]) );
72 EXPECT_EQ(vexp, cloned_fac->input_commodities());
81 <<
"<name>fooname</name>"
86 <<
" <incommodity>" << commod1_ <<
"</incommodity>"
87 <<
" <incommodity>" << commod2_ <<
"</incommodity>"
89 <<
" <input_capacity>" << capacity_ <<
"</input_capacity>"
90 <<
" <inventorysize>" << inv_ <<
"</inventorysize>"
98 cyclus::InfileTree engine(p);
102 std::string arr[] = {commod1_, commod2_};
103 std::vector<std::string> vexp (arr, arr +
sizeof(arr) /
sizeof(arr[0]) );
104 EXPECT_EQ(vexp, fac.input_commodities());
105 EXPECT_DOUBLE_EQ(capacity_, fac.Capacity());
106 EXPECT_DOUBLE_EQ(inv_, fac.MaxInventorySize());
107 EXPECT_DOUBLE_EQ(capacity_, fac.SpaceAvailable());
108 EXPECT_DOUBLE_EQ(0.0, fac.InventorySize());
113 using cyclus::Request;
114 using cyclus::RequestPortfolio;
115 using cyclus::CapacityConstraint;
116 using cyclus::Material;
118 std::string arr[] = {commod1_, commod2_};
119 std::vector<std::string> commods (arr, arr +
sizeof(arr) /
sizeof(arr[0]) );
121 src_facility->EnterNotify();
122 std::set<RequestPortfolio<Material>::Ptr> ports =
123 src_facility->GetMatlRequests();
125 ASSERT_EQ(ports.size(), 1);
126 ASSERT_EQ(ports.begin()->get()->qty(), capacity_);
127 const std::vector<Request<Material>*>& requests =
128 ports.begin()->get()->requests();
129 ASSERT_EQ(requests.size(), 2);
131 for (
int i = 0; i < ncommods_; ++i) {
132 Request<Material>* req = *(requests.begin() + i);
133 EXPECT_EQ(req->requester(), src_facility);
134 EXPECT_EQ(req->commodity(), commods[i]);
137 const std::set< CapacityConstraint<Material> >& constraints =
138 ports.begin()->get()->constraints();
139 EXPECT_EQ(constraints.size(), 0);
144 using cyclus::Material;
145 using cyclus::RequestPortfolio;
147 src_facility->Capacity(0);
148 std::set<RequestPortfolio<Material>::Ptr> ports =
149 src_facility->GetMatlRequests();
150 EXPECT_TRUE(ports.empty());
156 using cyclus::Material;
157 using cyclus::Request;
159 using test_helpers::get_mat;
161 double qty = qty_ * 2;
162 std::vector< std::pair<Trade<Material>,
163 Material::Ptr> > responses;
165 Request<Material>* req1 =
166 Request<Material>::Create(get_mat(922350000, qty_), src_facility,
168 Bid<Material>* bid1 = Bid<Material>::Create(req1, get_mat(), trader);
170 Request<Material>* req2 =
171 Request<Material>::Create(get_mat(922350000, qty_), src_facility,
173 Bid<Material>* bid2 =
174 Bid<Material>::Create(req2, get_mat(922350000, qty_), trader);
176 Trade<Material> trade1(req1, bid1, qty_);
177 responses.push_back(std::make_pair(trade1, get_mat(922350000, qty_)));
178 Trade<Material> trade2(req2, bid2, qty_);
179 responses.push_back(std::make_pair(trade2, get_mat(922350000, qty_)));
181 EXPECT_DOUBLE_EQ(0.0, src_facility->InventorySize());
182 src_facility->AcceptMatlTrades(responses);
183 EXPECT_DOUBLE_EQ(qty, src_facility->InventorySize());
188 using cyclus::RequestPortfolio;
189 using cyclus::Material;
190 using cyclus::Request;
191 cyclus::Recorder rec;
193 cyclus::Context ctx(&ti, &rec);
200 cyclus::Composition::Ptr c = cyclus::Composition::CreateFromMass(m);
201 ctx.AddRecipe(
"some_u",c) ;
205 snk->AddCommodity(
"some_u");
208 std::set<RequestPortfolio<Material>::Ptr> ports =
209 snk->GetMatlRequests();
210 ASSERT_EQ(ports.size(), 1);
212 const std::vector<Request<Material>*>& requests =
213 ports.begin()->get()->requests();
214 ASSERT_EQ(requests.size(), 1);
216 Request<Material>* req = *requests.begin();
217 EXPECT_EQ(req->requester(), snk);
218 EXPECT_EQ(req->commodity(),
"some_u");
223 using cyclus::QueryResult;
228 " <val>commods_1</val>"
229 " <val>commods_2</val>"
234 " </in_commod_prefs>"
235 " <capacity>1</capacity>"
236 " <input_capacity>1.0</input_capacity> ";
239 cyclus::MockSim sim(cyclus::AgentSpec
240 (
":cycamore:Sink"), config, simdur);
242 sim.AddSource(
"commods_1")
246 sim.AddSource(
"commods_2")
252 std::vector<Cond> conds;
253 conds.push_back(Cond(
"Commodity",
"==", std::string(
"commods_1")));
254 QueryResult qr = sim.db().Query(
"Transactions", &conds);
257 EXPECT_EQ(1, qr.rows.size());
259 std::vector<Cond> conds2;
260 conds2.push_back(Cond(
"Commodity",
"==", std::string(
"commods_2")));
261 QueryResult qr2 = sim.db().Query(
"Transactions", &conds2);
264 EXPECT_EQ(0, qr2.rows.size());
394 using cyclus::QueryResult;
398 " <val>commods_1</val>"
400 " <capacity>10</capacity>"
401 " <random_size_type>NormalReal</random_size_type> "
402 " <random_size_mean>0.5</random_size_mean> "
403 " <random_size_stddev>0.2</random_size_stddev> ";
406 cyclus::MockSim sim(cyclus::AgentSpec
407 (
":cycamore:Sink"), config, simdur);
408 sim.AddSource(
"commods_1").capacity(10).Finalize();
411 QueryResult qr = sim.db().Query(
"Resources", NULL);
412 EXPECT_EQ(qr.rows.size(), 1);
414 EXPECT_NEAR(qr.GetVal<
double>(
"Quantity"), 1.52979, 0.0001);
420 using cyclus::QueryResult;
424 " <val>commods_1</val>"
426 " <capacity>10</capacity>"
427 " <random_frequency_type>UniformInt</random_frequency_type> "
428 " <random_frequency_min>2</random_frequency_min> "
429 " <random_frequency_max>4</random_frequency_max> ";
432 cyclus::MockSim sim(cyclus::AgentSpec
433 (
":cycamore:Sink"), config, simdur);
434 sim.AddSource(
"commods_1").capacity(10).Finalize();
437 QueryResult qr = sim.db().Query(
"Transactions", NULL);
439 EXPECT_EQ(qr.rows.size(), 1);
441 int trans_time = qr.GetVal<
int>(
"Time", 0);
443 EXPECT_EQ(trans_time, 2);
449 using cyclus::QueryResult;
453 " <val>commods_1</val>"
455 " <capacity>10</capacity>"
456 " <random_frequency_type>NormalInt</random_frequency_type> ";
459 cyclus::MockSim sim(cyclus::AgentSpec
460 (
":cycamore:Sink"), config, simdur);
461 sim.AddSource(
"commods_1").capacity(10).Finalize();
464 QueryResult qr = sim.db().Query(
"Transactions", NULL);
466 EXPECT_EQ(qr.rows.size(), 1);
468 int trans_time = qr.GetVal<
int>(
"Time", 0);
470 EXPECT_EQ(trans_time, 2);
476 using cyclus::QueryResult;
480 " <val>commods_1</val>"
482 " <capacity>10</capacity>"
483 " <random_frequency_type>NormalInt</random_frequency_type> "
484 " <random_frequency_mean>2</random_frequency_mean> "
485 " <random_frequency_stddev>0.2</random_frequency_stddev> ";
488 cyclus::MockSim sim(cyclus::AgentSpec
489 (
":cycamore:Sink"), config, simdur);
490 sim.AddSource(
"commods_1").capacity(10).Finalize();
493 QueryResult qr = sim.db().Query(
"Transactions", NULL);
495 EXPECT_EQ(qr.rows.size(), 1);
497 int trans_time = qr.GetVal<
int>(
"Time", 0);
499 EXPECT_EQ(trans_time, 2);
504 using cyclus::QueryResult;
508 " <val>commods_1</val>"
510 " <capacity>10</capacity>"
511 " <random_frequency_type>NormalInt</random_frequency_type> "
512 " <random_frequency_mean>4</random_frequency_mean> "
513 " <random_frequency_stddev>1</random_frequency_stddev> ";
516 cyclus::MockSim sim(cyclus::AgentSpec
517 (
":cycamore:Sink"), config, simdur);
518 sim.AddSource(
"commods_1").capacity(10).Finalize();
521 QueryResult qr = sim.db().Query(
"Transactions", NULL);
523 EXPECT_EQ(3, qr.rows.size());
528 int first_trans_time = qr.GetVal<
int>(
"Time", 0);
529 EXPECT_EQ(5, first_trans_time);
530 int second_trans_time = qr.GetVal<
int>(
"Time", 1);
531 EXPECT_EQ(7, second_trans_time);
532 int third_trans_time = qr.GetVal<
int>(
"Time", 2);
533 EXPECT_EQ(11, third_trans_time);
539 using cyclus::QueryResult;
543 " <val>commods_1</val>"
545 " <capacity>10</capacity>"
546 " <random_size_type>NormalReal</random_size_type>"
547 " <random_size_mean>0.8</random_size_mean>"
548 " <random_size_stddev>0.2</random_size_stddev>"
549 " <random_frequency_type>UniformInt</random_frequency_type> "
550 " <random_frequency_min>2</random_frequency_min> "
551 " <random_frequency_max>4</random_frequency_max> ";
554 cyclus::MockSim sim(cyclus::AgentSpec
555 (
":cycamore:Sink"), config, simdur);
556 sim.AddSource(
"commods_1").capacity(20).Finalize();
559 QueryResult tqr = sim.db().Query(
"Transactions", NULL);
561 EXPECT_EQ(2, tqr.rows.size());
563 int trans_time = tqr.GetVal<
int>(
"Time", 0);
564 EXPECT_EQ(3, trans_time);
565 int res_id = tqr.GetVal<
int>(
"ResourceId", 0);
566 QueryResult rqr = sim.db().Query(
"Resources", NULL);
567 double quantity = rqr.GetVal<
double>(
"Quantity", 0);
568 EXPECT_NEAR(6.54143, quantity, 0.00001);