523 save_xml_header(*
sim);
525 for (std::size_t ind = 1; ind <= sn_.nodes.size(); ++ind) save_node(*
sim, ind);
559 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist) {
565 const qn::NodeType ty = sn_.nodes[sn_.station_to_node[ist - 1] - 1].nodetype;
566 if (ty == qn::NodeType::Source || ty == qn::NodeType::Sink)
continue;
572 if (!std::isfinite(sn_.cap[ist - 1]))
continue;
573 if (sn_.cap[ist - 1] >= reachable_population(ist))
continue;
574 if (!std::isfinite(sn_.stations[ist - 1].nservers))
continue;
576 return "SolverJMT: station '" + nname(sn_.station_to_node[ist - 1]) +
577 "' carries a finite capacity " +
jmt_int(sn_.cap[ist - 1]) +
578 " that binds. The JMVA document has no capacity element at all, so the "
579 "analytical engine would solve the model as if the buffer were unbounded "
580 "and report that as the answer. Use the 'jsim' method, which exports the "
581 "buffer with its drop rule when JMT can express it, or SolverCTMC, "
582 "SolverSSA or SolverLDES";
584 assert_station_cap_exportable(ist);
586 return std::string(e.what());
589 return std::string();
595 std::vector<std::vector<bool>> conn_;
596 std::vector<bool> keep_, cacheclass_;
599 const std::string& cname(std::size_t r)
const {
return sn_.
classes[r - 1].name; }
600 const std::string& nname(std::size_t i)
const {
return sn_.
nodes[i - 1].name; }
603 std::vector<std::size_t> outputs_of(std::size_t ind)
const {
604 std::vector<std::size_t> v;
605 for (std::size_t j = 1; j <= sn_.nodes.size(); ++j)
606 if (conn_[ind - 1][j - 1]) v.push_back(j);
611 std::vector<std::size_t> inputs_of(std::size_t ind)
const {
612 std::vector<std::size_t> v;
613 for (std::size_t j = 1; j <= sn_.nodes.size(); ++j)
614 if (conn_[j - 1][ind - 1]) v.push_back(j);
623 std::vector<std::pair<std::size_t, std::size_t>> inhibitor_only_arcs()
const {
624 std::vector<std::pair<std::size_t, std::size_t>> arcs;
625 for (
const auto& kv : sn_.transparam) {
626 const std::size_t t = kv.first;
627 for (std::size_t p = 1; p <= sn_.nodes.size(); ++p) {
630 for (
const Matrix<T>& M : kv.second.inhibiting) {
631 if (p > M.rows())
continue;
632 for (std::size_t r = 0; r < M.cols() && !finite; ++r)
633 finite = std::isfinite(num_traits<T>::to_double(M(p - 1, r)));
636 if (finite) arcs.emplace_back(p, t);
645 void save_xml_header(xml::Element& sim) {
646 sim.set_attr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance");
647 sim.set_attr(
"name", opt_.file_name +
".jsimg");
648 sim.set_attr(
"xsi:noNamespaceSchemaLocation",
"SIMmodeldefinition.xsd");
649 sim.set_attr(
"disableStatisticStop",
"true");
650 sim.set_attr(
"logDecimalSeparator",
".");
651 sim.set_attr(
"logDelimiter",
";");
652 sim.set_attr(
"logPath", opt_.log_path);
653 sim.set_attr(
"logReplaceMode",
"0");
654 sim.set_attr(
"maxSamples",
655 std::isnan(opt_.max_samples) ?
"10000" :
jmt_int(opt_.max_samples));
656 sim.set_attr(
"maxEvents",
jmt_int(opt_.max_events));
657 if (std::isfinite(opt_.max_simulated_time)) {
659 std::snprintf(buf,
sizeof(buf),
"%.3f", opt_.max_simulated_time);
660 sim.set_attr(
"maxSimulated", buf);
662 sim.set_attr(
"polling",
"1.0");
663 sim.set_attr(
"seed",
jmt_int(
static_cast<double>(opt_.seed)));
674 void save_classes(xml::Element& sim) {
676 for (std::size_t r = 0; r < sn_.nclasses; ++r)
677 maxprio = std::max(maxprio, sn_.classes[r].prio);
678 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
679 if (!keep_[r - 1])
continue;
680 const qn::JobClass& cl = sn_.classes[r - 1];
681 xml::Element& uc = sim.add_child(
"userClass");
682 uc.set_attr(
"name", cl.name);
683 const bool open = !std::isfinite(cl.population);
684 uc.set_attr(
"type", open ?
"open" :
"closed");
689 uc.set_attr(
"priority",
jmt_int(
static_cast<double>(maxprio - cl.prio)));
690 const std::size_t refst = cl.refstat;
691 const std::string refname = nname(sn_.station_to_node[refst - 1]);
693 uc.set_attr(
"customers",
jmt_int(cl.population));
694 uc.set_attr(
"referenceSource", refname);
695 }
else if (sn_.disabled[refst - 1][r - 1]) {
699 uc.set_attr(
"referenceSource",
"ClassSwitch");
701 uc.set_attr(
"referenceSource", refname);
709 void save_node(xml::Element& sim, std::size_t ind) {
711 xml::Element& node = sim.add_child(
"node");
712 node.set_attr(
"name", nname(ind));
714 save_class_soft_deadlines(node, ind);
715 const std::string parts[3] = {sec.input, sec.server, sec.output};
716 for (
int k = 0; k < 3; ++k) {
717 if (parts[k].empty())
continue;
718 std::string cls = parts[k];
723 xml::Element& xs = node.add_child(
"section");
724 xs.set_attr(
"className", cls);
725 if (cls ==
"Buffer") {
726 xs.set_attr(
"className",
"Queue");
727 save_buffer_capacity(xs, ind);
728 save_drop_strategy(xs, ind);
729 if (has_retrial(ind)) {
733 save_retrial_distributions(xs, ind);
734 save_get_strategy(xs, ind);
735 save_put_strategy(xs, ind);
737 save_get_strategy(xs, ind);
738 save_put_strategy(xs, ind);
739 save_impatience(xs, ind);
741 }
else if (cls ==
"Server") {
742 save_number_of_servers(xs, ind);
743 save_server_visits(xs);
744 save_service_strategy(xs, ind);
745 save_delay_off_strategy(xs, ind);
749 save_class_parallelism(xs, ind);
750 save_server_type_names(xs, ind);
751 save_servers_per_type(xs, ind);
752 save_server_compatibilities(xs, ind);
753 save_hetero_sched_policy(xs, ind);
754 warn_hetero_rates(ind);
755 warn_switchover_on_non_polling(ind);
756 }
else if (cls ==
"PreemptiveServer") {
757 save_number_of_servers(xs, ind);
758 save_server_visits(xs);
759 save_service_strategy(xs, ind);
760 save_delay_off_strategy(xs, ind);
761 }
else if (cls ==
"SharedServer") {
762 xs.set_attr(
"className",
"PSServer");
763 save_number_of_servers(xs, ind);
764 save_server_visits(xs);
765 save_service_strategy(xs, ind);
766 save_delay_off_strategy(xs, ind);
767 save_preemptive_strategy(xs, ind);
768 save_preemptive_weights(xs, ind);
769 }
else if (cls ==
"InfiniteServer") {
770 xs.set_attr(
"className",
"Delay");
771 save_service_strategy(xs, ind);
772 }
else if (cls ==
"PollingServer") {
773 xs.set_attr(
"className", polling_server_class(ind));
774 save_number_of_servers(xs, ind);
775 save_server_visits(xs);
776 save_service_strategy(xs, ind);
777 save_switchover_strategy(xs, ind);
778 }
else if (cls ==
"RandomSource") {
779 save_arrival_strategy(xs, ind);
780 }
else if (cls ==
"Dispatcher") {
781 xs.set_attr(
"className",
"Router");
782 save_routing_strategy(xs, ind);
783 }
else if (cls ==
"StatelessClassSwitcher") {
784 xs.set_attr(
"className",
"ClassSwitch");
785 save_class_switch_strategy(xs, ind);
786 }
else if (cls ==
"Cache") {
787 save_cache_strategy(xs, ind);
788 }
else if (cls ==
"LogTunnel") {
789 save_log_tunnel(xs, ind);
790 }
else if (cls ==
"Joiner") {
791 xs.set_attr(
"className",
"Join");
792 save_join_strategy(xs, ind);
793 }
else if (cls ==
"Forker") {
794 xs.set_attr(
"className",
"Fork");
795 save_fork_strategy(xs, ind);
796 }
else if (cls ==
"Storage") {
797 save_total_capacity(xs, ind);
798 save_place_capacities(xs, ind);
799 save_drop_rule(xs, ind);
800 save_get_strategy(xs, ind);
801 save_put_strategies(xs, ind);
802 }
else if (cls ==
"Enabling") {
803 save_enabling_conditions(xs, ind);
804 save_inhibiting_conditions(xs, ind);
805 }
else if (cls ==
"Firing") {
806 save_firing_outcomes(xs, ind);
807 }
else if (cls ==
"Timing") {
808 save_mode_names(xs, ind);
809 save_numbers_of_servers(xs, ind);
810 save_timing_strategies(xs, ind);
811 save_firing_priorities(xs, ind);
812 save_firing_weights(xs, ind);
819 const char* polling_server_class(std::size_t ind)
const {
820 const std::size_t ist = sn_.nodes[ind - 1].station;
821 const typename qn::NetworkStruct<T>::PollingParam pp = sn_.effective_polling(ist);
823 case PollingType::GATED:
return "GatedPollingServer";
824 case PollingType::EXHAUSTIVE:
return "ExhaustivePollingServer";
825 case PollingType::KLIMITED:
return "LimitedPollingServer";
826 case PollingType::DECREMENTING:
828 "SolverJMT: JMT does not support the decrementing (semiexhaustive) polling "
829 "discipline; use the LDES solver");
830 case PollingType::GLIMITED:
832 "SolverJMT: JMT does not support the G-limited polling discipline; use the "
835 throw UnsupportedError(ErrorKind{
"SchedStrategy_POLLING"},
"SolverJMT: unknown polling discipline");
839 bool has_retrial(std::size_t ind)
const {
840 const std::size_t ist = sn_.nodes[ind - 1].station;
841 if (ist == 0)
return false;
842 const auto it = sn_.retrialparam.find(ist);
843 if (it == sn_.retrialparam.end())
return false;
844 for (
const lang::Distrib<T>& p : it->second.retrial_proc)
845 if (!p.disabled)
return true;
858 void warn_switchover_on_non_polling(std::size_t ind)
const {
859 const std::size_t ist = sn_.nodes[ind - 1].station;
860 if (ist == 0)
return;
861 for (
const lang::Distrib<T>& s : sn_.stations[ist - 1].switchover)
863 std::cerr <<
"[LINE] Warning: JMT does not support switchover times for "
864 <<
"non-polling queues. Switchover times will be ignored for node '"
865 << nname(ind) <<
"'." << std::endl;
872 if (!sn_.stations[ist - 1].switchover_pair.empty())
873 std::cerr <<
"[LINE] Warning: JMT does not support switchover times for "
874 <<
"non-polling queues. Switchover times will be ignored for node '"
875 << nname(ind) <<
"'." << std::endl;
899 void save_buffer_capacity(xml::Element& section, std::size_t ind) {
900 const std::size_t ist = sn_.nodes[ind - 1].station;
901 std::string v =
"-1";
902 if (ist != 0 && std::isfinite(sn_.cap[ist - 1])) {
903 const double total = reachable_population(ist);
904 const double ns = sn_.stations[ist - 1].nservers;
905 if (sn_.cap[ist - 1] < total && std::isfinite(ns)) {
906 assert_station_cap_exportable(ist);
933 double reachable_population(std::size_t ist)
const {
935 for (std::size_t c = 0; c < sn_.nchains; ++c) {
937 double chain_jobs = 0.0;
938 for (std::size_t r : sn_.inchain[c]) {
939 if (!sn_.disabled[ist - 1][r - 1]) served =
true;
940 chain_jobs += sn_.classes[r - 1].population;
942 if (served) n += chain_jobs;
960 bool is_bas_destination(std::size_t ist, std::size_t r)
const {
961 if (ist == 0 || sn_.isbasdestination.size() < ist)
return false;
962 if (sn_.isbasdestination[ist - 1].size() < r)
return false;
963 return sn_.isbasdestination[ist - 1][r - 1];
983 const char* drop_strategy_text(std::size_t ist, std::size_t r)
const {
984 if (ist == 0)
return "drop";
986 if (d == DropStrategy::WAITQ && is_bas_destination(ist, r))
1033 void assert_station_cap_exportable(std::size_t ist)
const {
1034 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1035 if (sn_.disabled[ist - 1][r - 1])
continue;
1040 "SolverJMT: station '" + nname(sn_.station_to_node[ist - 1]) +
1041 "' applies drop strategy '" +
jmt_drop_text(dr) +
"' to class '" + cname(r) +
1042 "' and carries a finite capacity " +
jmt_int(sn_.cap[ist - 1]) +
1043 " it can reach. JMT's queue section reads only 'drop', 'waiting queue', "
1044 "'BAS blocking' and 'retrial'; it does not approximate anything else, it "
1045 "ignores it, so the capacity would stop being enforced and the run would "
1046 "return the unconstrained answer. Use SolverCTMC, SolverSSA or SolverLDES");
1047 if (!std::isfinite(sn_.classes[r - 1].population))
continue;
1048 if (dr != DropStrategy::WAITQ)
1050 if (is_bas_destination(ist, r))
1054 "SolverJMT: station '" + nname(sn_.station_to_node[ist - 1]) +
1055 "' carries a finite capacity " +
jmt_int(sn_.cap[ist - 1]) +
1056 " that binds for the closed class '" + cname(r) +
1057 "'. LINE blocks a closed job that finds no room -- the upstream departure is "
1058 "disabled and the job stays where it is -- and no JMT drop strategy reproduces "
1059 "that: 'waiting queue' does not enforce the size at all, and 'BAS blocking' "
1060 "completes the service before blocking, which is a different queueing model. "
1061 "Use SolverCTMC, SolverSSA or SolverLDES, or declare DropStrategy.BAS if "
1062 "blocking after service is the model you want, which SolverJMT does export");
1067 void save_drop_strategy(xml::Element& section, std::size_t ind) {
1068 const std::size_t ist = sn_.nodes[ind - 1].station;
1069 xml::Element& p =
jmt_param(section,
"java.lang.String",
"dropStrategies",
true);
1070 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1071 if (!keep_[r - 1])
continue;
1073 const char* txt = drop_strategy_text(ist, r);
1074 xml::Element& sp = p.add_child(
"subParameter");
1075 sp.set_attr(
"classPath",
"java.lang.String");
1076 sp.set_attr(
"name",
"dropStrategy");
1077 sp.add_text_child(
"value", txt);
1085 void save_get_strategy(xml::Element& section, std::size_t ind) {
1086 const std::size_t ist = sn_.nodes[ind - 1].station;
1087 const bool polling = sn_.nodes[ind - 1].nodetype == NodeType::Queue && ist != 0 &&
1088 sn_.stations[ist - 1].sched == SchedStrategy::POLLING;
1090 xml::Element& p = section.add_child(
"parameter");
1091 p.set_attr(
"classPath",
"jmt.engine.NetStrategies.QueueGetStrategies.FCFSstrategy");
1092 p.set_attr(
"name",
"FCFSstrategy");
1095 const typename qn::NetworkStruct<T>::PollingParam pp = sn_.effective_polling(ist);
1096 xml::Element& p = section.add_child(
"parameter");
1098 case PollingType::GATED:
1099 p.set_attr(
"classPath",
1100 "jmt.engine.NetStrategies.QueueGetStrategies.GatedPollingGetStrategy");
1102 case PollingType::EXHAUSTIVE:
1105 "jmt.engine.NetStrategies.QueueGetStrategies.ExhaustivePollingGetStrategy");
1107 case PollingType::KLIMITED: {
1108 p.set_attr(
"classPath",
1109 "jmt.engine.NetStrategies.QueueGetStrategies.LimitedPollingGetStrategy");
1110 xml::Element& k = p.add_child(
"subParameter");
1111 k.set_attr(
"classPath",
"java.lang.Integer");
1112 k.set_attr(
"name",
"pollingKValue");
1113 k.add_text_child(
"value",
jmt_int(
static_cast<double>(pp.pk)));
1116 case PollingType::DECREMENTING:
1118 "SolverJMT: JMT does not support the decrementing (semiexhaustive) polling "
1119 "discipline; use the LDES solver");
1120 case PollingType::GLIMITED:
1122 "SolverJMT: JMT does not support the G-limited polling discipline; use the "
1125 p.set_attr(
"name",
"FCFSstrategy");
1137 void save_put_strategy(xml::Element& section, std::size_t ind) {
1138 const std::size_t ist = sn_.nodes[ind - 1].station;
1140 jmt_param(section,
"jmt.engine.NetStrategies.QueuePutStrategy",
"QueuePutStrategy",
true);
1141 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1142 if (!keep_[r - 1])
continue;
1144 const char* nm =
"TailStrategy";
1146 switch (sn_.stations[ist - 1].sched) {
1147 case SchedStrategy::SIRO: nm =
"RandStrategy";
break;
1148 case SchedStrategy::LJF: nm =
"LJFStrategy";
break;
1149 case SchedStrategy::SJF: nm =
"SJFStrategy";
break;
1150 case SchedStrategy::LEPT: nm =
"LEPTStrategy";
break;
1151 case SchedStrategy::SEPT: nm =
"SEPTStrategy";
break;
1152 case SchedStrategy::LCFS: nm =
"HeadStrategy";
break;
1153 case SchedStrategy::LCFSPRIO: nm =
"HeadStrategyPriority";
break;
1154 case SchedStrategy::LCFSPR: nm =
"LCFSPRStrategy";
break;
1155 case SchedStrategy::LCFSPI: nm =
"LCFSPIStrategy";
break;
1156 case SchedStrategy::LCFSPRPRIO: nm =
"LCFSPRStrategyPriority";
break;
1157 case SchedStrategy::LCFSPIPRIO: nm =
"LCFSPIStrategyPriority";
break;
1158 case SchedStrategy::FCFSPR: nm =
"FCFSPRStrategy";
break;
1159 case SchedStrategy::FCFSPI: nm =
"FCFSPIStrategy";
break;
1160 case SchedStrategy::FCFSPRPRIO: nm =
"FCFSPRStrategyPriority";
break;
1161 case SchedStrategy::FCFSPIPRIO: nm =
"FCFSPIStrategyPriority";
break;
1162 case SchedStrategy::HOL: nm =
"TailStrategyPriority";
break;
1163 case SchedStrategy::EDD: nm =
"EDDStrategy";
break;
1164 case SchedStrategy::EDF: nm =
"EDFStrategy";
break;
1165 case SchedStrategy::SRPT: nm =
"SRPTStrategy";
break;
1166 case SchedStrategy::SRPTPRIO: nm =
"SRPTStrategyPriority";
break;
1167 default: nm =
"TailStrategy";
break;
1170 xml::Element& sp = p.add_child(
"subParameter");
1171 sp.set_attr(
"classPath",
1172 std::string(
"jmt.engine.NetStrategies.QueuePutStrategies.") + nm);
1173 sp.set_attr(
"name", nm);
1189 void save_number_of_servers(xml::Element& section, std::size_t ind) {
1190 const std::size_t ist = sn_.nodes[ind - 1].station;
1191 double maxjobs = 1.0;
1193 if (sn_.stations[ist - 1].sched == SchedStrategy::LPS) {
1196 maxjobs = sn_.stations[ist - 1].nservers;
1197 for (
const T& s : sn_.stations[ist - 1].lldscaling)
1198 maxjobs = std::max(maxjobs, d(s));
1205 void save_server_visits(xml::Element& section) {
1206 xml::Element& p =
jmt_param(section,
"java.lang.Integer",
"numberOfVisits",
true);
1207 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1208 if (!keep_[r - 1])
continue;
1210 xml::Element& sp = p.add_child(
"subParameter");
1211 sp.set_attr(
"classPath",
"java.lang.Integer");
1212 sp.set_attr(
"name",
"numberOfVisits");
1213 sp.add_text_child(
"value",
"1");
1228 struct ServerPools {
1229 bool present =
false;
1230 std::vector<std::string> names;
1231 std::vector<double> counts;
1232 std::vector<std::vector<bool>> compat;
1234 std::vector<std::size_t> parallelism;
1237 ServerPools server_pools(std::size_t ind)
const {
1239 const std::size_t ist = sn_.nodes[ind - 1].station;
1240 if (ist == 0)
return pools;
1241 const auto& st = sn_.stations[ist - 1];
1242 const bool has_types = !st.server_types.empty();
1243 bool has_parallelism =
false;
1244 for (std::size_t n : st.server_parallelism) {
1245 if (n > 1) { has_parallelism =
true;
break; }
1247 if (!has_types && !has_parallelism)
return pools;
1249 pools.present =
true;
1250 pools.parallelism.assign(sn_.nclasses, 1);
1251 for (std::size_t r = 0; r < sn_.nclasses && r < st.server_parallelism.size(); ++r) {
1252 pools.parallelism[r] = st.server_parallelism[r] < 1 ? 1 : st.server_parallelism[r];
1255 pools.policy = st.hetero_policy;
1256 for (
const auto& pool : st.server_types) {
1257 pools.names.push_back(pool.name);
1258 pools.counts.push_back(pool.count);
1259 std::vector<bool> row(sn_.nclasses,
true);
1260 for (std::size_t r = 0; r < sn_.nclasses; ++r) {
1263 row[r] = pool.compatible.empty()
1265 : (r < pool.compatible.size() ? pool.compatible[r] :
false);
1267 pools.compat.push_back(row);
1270 pools.names.push_back(sn_.nodes[ind - 1].name +
" - Server Type 1");
1271 pools.counts.push_back(st.nservers);
1272 pools.compat.push_back(std::vector<bool>(sn_.nclasses,
true));
1278 void save_class_parallelism(xml::Element& section, std::size_t ind) {
1279 const ServerPools pools = server_pools(ind);
1280 if (!pools.present)
return;
1281 xml::Element& p =
jmt_param(section,
"java.lang.Integer",
"classParallelism",
true);
1282 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1283 if (!keep_[r - 1])
continue;
1285 xml::Element& sp = p.add_child(
"subParameter");
1286 sp.set_attr(
"classPath",
"java.lang.Integer");
1287 sp.set_attr(
"name",
"serverParallelism");
1288 sp.add_text_child(
"value",
jmt_int(
static_cast<double>(pools.parallelism[r - 1])));
1293 void save_server_type_names(xml::Element& section, std::size_t ind) {
1294 const ServerPools pools = server_pools(ind);
1295 if (!pools.present)
return;
1296 xml::Element& p =
jmt_param(section,
"java.lang.String",
"serverNames",
true);
1297 for (
const std::string& name : pools.names) {
1298 xml::Element& sp = p.add_child(
"subParameter");
1299 sp.set_attr(
"classPath",
"java.lang.String");
1300 sp.set_attr(
"name",
"serverTypesNames");
1301 sp.add_text_child(
"value", name);
1306 void save_servers_per_type(xml::Element& section, std::size_t ind) {
1307 const ServerPools pools = server_pools(ind);
1308 if (!pools.present)
return;
1309 xml::Element& p =
jmt_param(section,
"java.lang.Integer",
"serversPerServerType",
true);
1310 for (
double count : pools.counts) {
1311 xml::Element& sp = p.add_child(
"subParameter");
1312 sp.set_attr(
"classPath",
"java.lang.Integer");
1313 sp.set_attr(
"name",
"serverTypesNumOfServers");
1314 sp.add_text_child(
"value",
jmt_int(count));
1319 void save_server_compatibilities(xml::Element& section, std::size_t ind) {
1320 const ServerPools pools = server_pools(ind);
1321 if (!pools.present)
return;
1322 xml::Element& p =
jmt_param(section,
"java.lang.Object",
"serverCompatibilities",
true);
1323 for (
const std::vector<bool>& row : pools.compat) {
1324 xml::Element& tn = p.add_child(
"subParameter");
1325 tn.set_attr(
"array",
"true");
1326 tn.set_attr(
"classPath",
"java.lang.Boolean");
1327 tn.set_attr(
"name",
"serverTypesCompatibilities");
1328 for (std::size_t r = 0; r < sn_.nclasses; ++r) {
1329 xml::Element& cn = tn.add_child(
"subParameter");
1330 cn.set_attr(
"classPath",
"java.lang.Boolean");
1331 cn.set_attr(
"name",
"compatibilities");
1332 cn.add_text_child(
"value", row[r] ?
"true" :
"false");
1338 void save_hetero_sched_policy(xml::Element& section, std::size_t ind) {
1339 const ServerPools pools = server_pools(ind);
1340 if (!pools.present)
return;
1354 void warn_hetero_rates(std::size_t ind)
const {
1355 const std::size_t ist = sn_.nodes[ind - 1].station;
1356 if (ist == 0)
return;
1357 const auto& pools = sn_.stations[ist - 1].server_types;
1358 if (pools.size() < 2)
return;
1359 bool first_set =
false, distinct =
false;
1361 for (
const auto& pool : pools) {
1362 for (
const lang::Distrib<T>& sd : pool.service) {
1363 if (sd.disabled)
continue;
1364 const double mean = num_traits<T>::to_double(sd.mean);
1365 if (!(mean > 0))
continue;
1366 if (!first_set) { first = mean; first_set =
true; }
1367 else if (std::abs(mean - first) > 1e-12) { distinct =
true; }
1370 if (!distinct)
return;
1371 std::cerr <<
"[LINE] Warning: JMT keys service strategies by job class, so the "
1372 <<
"per-server-type service rates of station '" << sn_.nodes[ind - 1].name
1373 <<
"' cannot be exported; every pool will serve at the class service rate. "
1374 <<
"Use the LDES or CTMC solver for per-type rates." << std::endl;
1384 void save_service_strategy(xml::Element& section, std::size_t ind) {
1385 const std::size_t ist = sn_.nodes[ind - 1].station;
1386 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.ServiceStrategy",
1387 "ServiceStrategy",
true);
1388 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1389 if (!keep_[r - 1])
continue;
1391 xml::Element& sts = p.add_child(
"subParameter");
1392 const JmtDistView<T> v =
1393 ist == 0 ? JmtDistView<T>() :
jmt_dist_view(sn_.service[ist - 1][r - 1]);
1395 sts.set_attr(
"classPath",
1396 "jmt.engine.NetStrategies.ServiceStrategies."
1397 "DisabledServiceTimeStrategy");
1398 sts.set_attr(
"name",
"DisabledServiceTimeStrategy");
1402 sts.set_attr(
"classPath",
1403 "jmt.engine.NetStrategies.ServiceStrategies.ZeroServiceTimeStrategy");
1404 sts.set_attr(
"name",
"ZeroServiceTimeStrategy");
1407 sts.set_attr(
"classPath",
1408 "jmt.engine.NetStrategies.ServiceStrategies.ServiceTimeStrategy");
1409 sts.set_attr(
"name",
"ServiceTimeStrategy");
1422 void save_arrival_strategy(xml::Element& section, std::size_t ind) {
1423 const std::size_t ist = sn_.nodes[ind - 1].station;
1424 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.ServiceStrategy",
1425 "ServiceStrategy",
true);
1426 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1427 if (!keep_[r - 1])
continue;
1429 xml::Element& sts = p.add_child(
"subParameter");
1430 sts.set_attr(
"classPath",
1431 "jmt.engine.NetStrategies.ServiceStrategies.ServiceTimeStrategy");
1432 sts.set_attr(
"name",
"ServiceTimeStrategy");
1433 const bool closed = std::isfinite(sn_.classes[r - 1].population);
1434 const JmtDistView<T> v =
1435 ist == 0 ? JmtDistView<T>() :
jmt_dist_view(sn_.service[ist - 1][r - 1]);
1437 sts.add_text_child(
"value",
"null");
1441 sts.set_attr(
"classPath",
1442 "jmt.engine.NetStrategies.ServiceStrategies.ZeroServiceTimeStrategy");
1443 sts.set_attr(
"name",
"ZeroServiceTimeStrategy");
1451 void save_preemptive_strategy(xml::Element& section, std::size_t ind) {
1452 const std::size_t ist = sn_.nodes[ind - 1].station;
1453 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.PSStrategy",
"PSStrategy",
1455 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1456 if (!keep_[r - 1])
continue;
1458 const char* nm =
nullptr;
1459 if (ist != 0)
switch (sn_.stations[ist - 1].sched) {
1462 case SchedStrategy::PS:
1463 case SchedStrategy::LPS: nm =
"EPSStrategy";
break;
1464 case SchedStrategy::DPS: nm =
"DPSStrategy";
break;
1465 case SchedStrategy::GPS: nm =
"GPSStrategy";
break;
1466 case SchedStrategy::PSPRIO: nm =
"EPSStrategyPriority";
break;
1467 case SchedStrategy::DPSPRIO: nm =
"DPSStrategyPriority";
break;
1468 case SchedStrategy::GPSPRIO: nm =
"GPSStrategyPriority";
break;
1469 default: nm =
nullptr;
break;
1471 xml::Element& sp = p.add_child(
"subParameter");
1472 if (nm !=
nullptr) {
1473 sp.set_attr(
"classPath", std::string(
"jmt.engine.NetStrategies.PSStrategies.") + nm);
1474 sp.set_attr(
"name", nm);
1480 void save_preemptive_weights(xml::Element& section, std::size_t ind) {
1481 const std::size_t ist = sn_.nodes[ind - 1].station;
1482 xml::Element& p =
jmt_param(section,
"java.lang.Double",
"serviceWeights",
true);
1483 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1484 if (!keep_[r - 1])
continue;
1487 if (ist != 0 && sn_.stations[ist - 1].schedparam.size() >= r)
1488 w = d(sn_.stations[ist - 1].schedparam[r - 1]);
1489 xml::Element& sp = p.add_child(
"subParameter");
1490 sp.set_attr(
"classPath",
"java.lang.Double");
1491 sp.set_attr(
"name",
"serviceWeight");
1492 sp.add_text_child(
"value",
jmt_num(w));
1506 void save_delay_off_strategy(xml::Element& section, std::size_t ind) {
1507 const std::size_t ist = sn_.nodes[ind - 1].station;
1508 if (ist == 0)
return;
1509 const auto it = sn_.setupparam.find(ist);
1510 if (it == sn_.setupparam.end())
return;
1511 const qn::SetupDelayOffParam<T>& sp = it->second;
1513 for (
const lang::Distrib<T>& s : sp.setup)
1514 if (!s.disabled) any =
true;
1521 xml::Element& sw =
jmt_param(section,
"java.lang.Object",
"switchoverStrategies",
true);
1522 sw.add_text_child(
"value",
"null");
1524 const char* names[2] = {
"delayOffTime",
"setUpTime"};
1525 for (
int which = 0; which < 2; ++which) {
1526 const std::vector<lang::Distrib<T>>& tab = which == 0 ? sp.delayoff : sp.setup;
1527 xml::Element& p =
jmt_param(section,
"java.lang.Object", names[which],
true);
1528 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1530 xml::Element& row = p.add_child(
"subParameter");
1531 row.set_attr(
"array",
"true");
1532 row.set_attr(
"classPath",
"jmt.engine.NetStrategies.ServiceStrategy");
1533 row.set_attr(
"name", names[which]);
1534 xml::Element& sts = row.add_child(
"subParameter");
1535 sts.set_attr(
"classPath",
1536 "jmt.engine.NetStrategies.ServiceStrategies.ServiceTimeStrategy");
1537 sts.set_attr(
"name",
"ServiceTimeStrategy");
1538 if (r <= tab.size() && !tab[r - 1].disabled)
1539 append_simple_distribution(sts, tab[r - 1]);
1541 append_zero_time(sts);
1547 void append_zero_time(xml::Element& parent) {
1548 xml::Element& dn = parent.add_child(
"subParameter");
1549 dn.set_attr(
"classPath",
"jmt.engine.random.DeterministicDistr");
1550 dn.set_attr(
"name",
"Deterministic");
1551 xml::Element& par = parent.add_child(
"subParameter");
1552 par.set_attr(
"classPath",
"jmt.engine.random.DeterministicDistrPar");
1553 par.set_attr(
"name",
"distrPar");
1554 jmt_scalar(par,
"java.lang.Double",
"t",
"0.0");
1567 void append_simple_distribution(xml::Element& parent,
const lang::Distrib<T>& dist) {
1569 append_zero_time(parent);
1572 const double mean = d(dist.mean);
1574 xml::Element& dn = parent.add_child(
"subParameter");
1575 dn.set_attr(
"classPath",
"jmt.engine.random.Exponential");
1576 dn.set_attr(
"name",
"Exponential");
1577 xml::Element& par = parent.add_child(
"subParameter");
1578 par.set_attr(
"classPath",
"jmt.engine.random.ExponentialPar");
1579 par.set_attr(
"name",
"distrPar");
1580 jmt_double(par,
"lambda", mean > 0.0 ? 1.0 / mean : 0.0);
1584 const std::size_t ph = dist.phases();
1585 xml::Element& dn = parent.add_child(
"subParameter");
1586 dn.set_attr(
"classPath",
"jmt.engine.random.Erlang");
1587 dn.set_attr(
"name",
"Erlang");
1588 xml::Element& par = parent.add_child(
"subParameter");
1589 par.set_attr(
"classPath",
"jmt.engine.random.ErlangPar");
1590 par.set_attr(
"name",
"distrPar");
1591 jmt_double(par,
"alpha", mean > 0.0 ?
static_cast<double>(ph) / mean : 0.0);
1595 xml::Element& dn = parent.add_child(
"subParameter");
1596 dn.set_attr(
"classPath",
"jmt.engine.random.DeterministicDistr");
1597 dn.set_attr(
"name",
"Deterministic");
1598 xml::Element& par = parent.add_child(
"subParameter");
1599 par.set_attr(
"classPath",
"jmt.engine.random.DeterministicDistrPar");
1600 par.set_attr(
"name",
"distrPar");
1614 void save_routing_strategy(xml::Element& section, std::size_t ind) {
1615 const std::size_t K = sn_.nclasses;
1616 const bool is_cs = sn_.nodes[ind - 1].nodetype == NodeType::ClassSwitch;
1618 jmt_param(section,
"jmt.engine.NetStrategies.RoutingStrategy",
"RoutingStrategy",
true);
1619 for (std::size_t r = 1; r <= K; ++r) {
1620 if (!keep_[r - 1])
continue;
1623 is_cs ? RoutingStrategy::RAND
1624 : (sn_.nodes[ind - 1].routing.size() >= r ? sn_.nodes[ind - 1].routing[r - 1]
1625 : RoutingStrategy::PROB);
1626 xml::Element& sp = p.add_child(
"subParameter");
1628 case RoutingStrategy::RAND:
1629 sp.set_attr(
"classPath",
1630 "jmt.engine.NetStrategies.RoutingStrategies.RandomStrategy");
1631 sp.set_attr(
"name",
"Random");
1633 case RoutingStrategy::RROBIN:
1634 sp.set_attr(
"classPath",
1635 "jmt.engine.NetStrategies.RoutingStrategies.RoundRobinStrategy");
1636 sp.set_attr(
"name",
"Round Robin");
1638 case RoutingStrategy::JSQ:
1639 sp.set_attr(
"classPath",
1640 "jmt.engine.NetStrategies.RoutingStrategies."
1641 "ShortestQueueLengthRoutingStrategy");
1642 sp.set_attr(
"name",
"Join the Shortest Queue (JSQ)");
1644 case RoutingStrategy::SQ: {
1645 sp.set_attr(
"classPath",
1646 "jmt.engine.NetStrategies.RoutingStrategies.PowerOfKRoutingStrategy");
1647 sp.set_attr(
"name",
"Power of k");
1648 const int dpar = sn_.nodes[ind - 1].routing_param.size() >= r
1649 ? sn_.nodes[ind - 1].routing_param[r - 1]
1655 jmt_scalar(sp,
"java.lang.Boolean",
"withMemory",
"false");
1658 case RoutingStrategy::WRROBIN: {
1659 sp.set_attr(
"classPath",
1660 "jmt.engine.NetStrategies.RoutingStrategies."
1661 "WeightedRoundRobinStrategy");
1662 sp.set_attr(
"name",
"Weighted Round Robin");
1664 jmt_param_sub(sp,
"jmt.engine.NetStrategies.RoutingStrategies.WeightEntry",
1665 "WeightEntryArray");
1666 const std::map<std::size_t, double>& w =
1667 sn_.nodes[ind - 1].routing_weights.size() >= r
1668 ? sn_.nodes[ind - 1].routing_weights[r - 1]
1670 for (std::size_t j : outputs_of(ind)) {
1671 const auto wi = w.find(j);
1672 xml::Element& e = arr.add_child(
"subParameter");
1673 e.set_attr(
"classPath",
1674 "jmt.engine.NetStrategies.RoutingStrategies.WeightEntry");
1675 e.set_attr(
"name",
"WeightEntry");
1676 jmt_scalar(e,
"java.lang.String",
"stationName", nname(j));
1678 jmt_int(wi == w.end() ? 0.0 : wi->second));
1682 case RoutingStrategy::PROB: {
1683 sp.set_attr(
"classPath",
1684 "jmt.engine.NetStrategies.RoutingStrategies.EmpiricalStrategy");
1685 sp.set_attr(
"name",
"Probabilities");
1686 xml::Element& arr = jmt_param_sub(sp,
"jmt.engine.random.EmpiricalEntry",
1687 "EmpiricalEntryArray");
1688 for (std::size_t j : outputs_of(ind)) {
1689 const double pr = route_node(ind, r, j, r);
1690 if (!(pr > 0.0))
continue;
1691 xml::Element& e = arr.add_child(
"subParameter");
1692 e.set_attr(
"classPath",
"jmt.engine.random.EmpiricalEntry");
1693 e.set_attr(
"name",
"EmpiricalEntry");
1694 jmt_scalar(e,
"java.lang.String",
"stationName", nname(j));
1702 "jmt.engine.NetStrategies.RoutingStrategies.DisabledRoutingStrategy");
1703 sp.set_attr(
"name",
"Random");
1710 static xml::Element& jmt_param_sub(xml::Element& parent,
const char* cp,
const char* name) {
1711 xml::Element& e = parent.add_child(
"subParameter");
1712 e.set_attr(
"array",
"true");
1713 e.set_attr(
"classPath", cp);
1714 e.set_attr(
"name", name);
1719 double route_node(std::size_t i, std::size_t r, std::size_t j, std::size_t s)
const {
1720 const std::size_t K = sn_.nclasses;
1721 const std::size_t a = (i - 1) * K + (r - 1), b = (j - 1) * K + (s - 1);
1722 if (sn_.rtnodes.rows() <= a || sn_.rtnodes.cols() <= b)
return 0.0;
1723 return d(sn_.rtnodes(a, b));
1735 void save_class_switch_strategy(xml::Element& section, std::size_t ind) {
1736 const std::size_t K = sn_.nclasses;
1737 const std::vector<std::size_t> jset = outputs_of(ind);
1738 xml::Element& p =
jmt_param(section,
"java.lang.Object",
"matrix",
true);
1739 for (std::size_t r = 1; r <= K; ++r) {
1740 if (!keep_[r - 1])
continue;
1742 xml::Element& row = p.add_child(
"subParameter");
1743 row.set_attr(
"array",
"true");
1744 row.set_attr(
"classPath",
"java.lang.Float");
1745 row.set_attr(
"name",
"row");
1746 for (std::size_t s = 1; s <= K; ++s) {
1747 if (!keep_[s - 1])
continue;
1750 for (std::size_t j : jset) acc += route_node(ind, r, j, s);
1751 xml::Element& cell = row.add_child(
"subParameter");
1752 cell.set_attr(
"classPath",
"java.lang.Float");
1753 cell.set_attr(
"name",
"cell");
1754 cell.add_text_child(
"value",
jmt_fmt(acc));
1770 void save_fork_strategy(xml::Element& section, std::size_t ind) {
1771 const qn::ForkParam<T>* fk = sn_.fork_param_of(ind);
1772 const double fan_out = sn_.nodes[ind - 1].tasks_per_link;
1780 bool simplified =
true;
1782 for (std::size_t k = 0; k < fk->fan_out_link.rows() && simplified; ++k)
1783 for (std::size_t r = 0; r < fk->fan_out_link.cols() && simplified; ++r) {
1784 const double p = num_traits<T>::to_double(fk->fan_out_prob(k, r));
1785 if (p == 0.0)
continue;
1786 if (p != 1.0) simplified =
false;
1787 if (num_traits<T>::to_double(fk->fan_out_link(k, r)) != fan_out)
1789 if (!fk->fan_out_dist[k][r].disabled) simplified =
false;
1793 simplified ?
"true" :
"false");
1796 jmt_param(section,
"jmt.engine.NetStrategies.ForkStrategy",
"ForkStrategy",
true);
1797 const std::vector<std::size_t> outs = outputs_of(ind);
1798 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1799 if (!keep_[r - 1])
continue;
1801 xml::Element& cs = p.add_child(
"subParameter");
1802 cs.set_attr(
"classPath",
"jmt.engine.NetStrategies.ForkStrategies.ProbabilitiesFork");
1803 cs.set_attr(
"name",
"Branch Probabilities");
1804 xml::Element& arr = jmt_param_sub(
1805 cs,
"jmt.engine.NetStrategies.ForkStrategies.OutPath",
"EmpiricalEntryArray");
1807 ? sn_.nodes[ind - 1].routing[r - 1]
1808 : RoutingStrategy::PROB;
1809 if (rs != RoutingStrategy::PROB || outs.empty())
continue;
1810 for (std::size_t oi = 0; oi < outs.size(); ++oi) {
1811 xml::Element& entry = arr.add_child(
"subParameter");
1812 entry.set_attr(
"classPath",
"jmt.engine.NetStrategies.ForkStrategies.OutPath");
1813 entry.set_attr(
"name",
"OutPathEntry");
1814 xml::Element& unit = entry.add_child(
"subParameter");
1815 unit.set_attr(
"classPath",
"jmt.engine.random.EmpiricalEntry");
1816 unit.set_attr(
"name",
"outUnitProbability");
1817 jmt_scalar(unit,
"java.lang.String",
"stationName", nname(outs[oi]));
1820 const std::size_t k0 = outs[oi] - 1, r0 = r - 1;
1821 const bool has_fan = fk != 0;
1822 const double branch_p =
1823 has_fan ? num_traits<T>::to_double(fk->fan_out_prob(k0, r0)) : 1.0;
1829 std::vector<double> pts, prs;
1830 if (has_fan && !fk->fan_out_dist[k0][r0].disabled) {
1831 const lang::Distrib<T>& d = fk->fan_out_dist[k0][r0];
1833 for (std::size_t e = 0; e < d.params.size(); ++e)
1834 tot += num_traits<T>::to_double(d.params[e]);
1835 for (std::size_t e = 0; e < d.params.size(); ++e) {
1836 pts.push_back(d.trace.empty()
1837 ?
static_cast<double>(e + 1)
1838 : num_traits<T>::to_double(d.trace[e]));
1839 prs.push_back(num_traits<T>::to_double(d.params[e]) / tot);
1841 }
else if (has_fan) {
1842 pts.push_back(num_traits<T>::to_double(fk->fan_out_link(k0, r0)));
1845 pts.push_back(fan_out);
1850 jmt_param_sub(entry,
"jmt.engine.random.EmpiricalEntry",
"JobsPerLinkDis");
1851 for (std::size_t e = 0; e < pts.size(); ++e) {
1852 xml::Element& jple = jpl.add_child(
"subParameter");
1853 jple.set_attr(
"classPath",
"jmt.engine.random.EmpiricalEntry");
1854 jple.set_attr(
"name",
"EmpiricalEntry");
1870 void save_join_strategy(xml::Element& section, std::size_t ind) {
1871 const auto it = sn_.joindecl.find(ind);
1872 const bool partial =
1873 it != sn_.joindecl.end() && it->second.strategy == JoinStrategy::PARTIAL;
1874 const double quorum = it != sn_.joindecl.end() ? it->second.quorum : 0.0;
1876 jmt_param(section,
"jmt.engine.NetStrategies.JoinStrategy",
"JoinStrategy",
true);
1877 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1879 xml::Element& sp = p.add_child(
"subParameter");
1881 sp.set_attr(
"classPath",
"jmt.engine.NetStrategies.JoinStrategies.PartialJoin");
1882 sp.set_attr(
"name",
"Quorum");
1884 sp.set_attr(
"classPath",
"jmt.engine.NetStrategies.JoinStrategies.NormalJoin");
1885 sp.set_attr(
"name",
"Standard Join");
1887 const double req = partial ? quorum : (quorum > 0.0 ? quorum : -1.0);
1893 void save_log_tunnel(xml::Element& section, std::size_t ind) {
1894 const qn::NodeDef::LoggerParam& lg = sn_.nodes[ind - 1].logger;
1895 std::string path = lg.file_path.empty() ? sn_.log_path : lg.file_path;
1896 if (!path.empty() && path[path.size() - 1] !=
'/') path +=
'/';
1897 const char* bools[7] = {
"logExecTimestamp",
"logLoggerName",
"logTimeStamp",
1898 "logJobID",
"logJobClass",
"logTimeSameClass",
1900 const bool vals[7] = {lg.start_time, lg.logger_name, lg.timestamp, lg.job_id,
1901 lg.job_class, lg.time_same_class, lg.time_any_class};
1902 jmt_param_value(section,
"java.lang.String",
"logfileName", lg.file_name);
1904 for (
int j = 0; j < 7; ++j)
1905 jmt_param_value(section,
"java.lang.Boolean", bools[j], vals[j] ?
"true" :
"false");
1907 jmt_int(
static_cast<double>(sn_.nclasses)));
1920 void save_metrics(xml::Element& sim) {
1924 for (
int k = 0; k < 5; ++k) save_metric(sim, kinds[k]);
1929 save_sys_tard_metrics(sim);
1930 save_fcr_metrics(sim);
1931 save_fj_metrics(sim);
1932 save_cache_hit_rate_metrics(sim);
1940 void save_fj_metrics(xml::Element& sim) {
1941 std::vector<std::size_t> forks;
1942 for (
const auto& e : sn_.fj)
1943 if (e.first != 0 && e.second != 0) forks.push_back(e.first);
1944 std::sort(forks.begin(), forks.end());
1945 forks.erase(std::unique(forks.begin(), forks.end()), forks.end());
1946 static const char* types[2] = {
"Fork Join Response Time",
"Fork Join Number of Customers"};
1947 static const char* tags[2] = {
"FJRespT",
"FJQLen"};
1948 for (std::size_t f : forks)
1949 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1950 if (!keep_[r - 1])
continue;
1951 bool visits =
false;
1952 for (std::size_t c = 0; c < sn_.inchain.size() && c < sn_.nodevisits.size(); ++c) {
1953 const std::vector<std::size_t>& ic = sn_.inchain[c];
1954 if (std::find(ic.begin(), ic.end(), r) == ic.end())
continue;
1955 visits = num_traits<T>::to_double(sn_.nodevisits[c](f - 1, r - 1)) > 0.0;
1958 if (!visits)
continue;
1959 for (
int k = 0; k < 2; ++k) {
1960 xml::Element& m = sim.add_child(
"measure");
1961 m.set_attr(
"alpha",
jmt_sig2(1.0 - opt_.sim_conf_int));
1962 m.set_attr(
"name", std::string(tags[k]) +
"_" + nname(f) +
"_" + cname(r));
1963 m.set_attr(
"nodeType",
"station");
1964 m.set_attr(
"precision",
jmt_sig2(opt_.sim_max_rel_err));
1965 m.set_attr(
"referenceNode", nname(f));
1966 m.set_attr(
"referenceUserClass", cname(r));
1967 m.set_attr(
"type", types[k]);
1968 m.set_attr(
"verbose",
"false");
1974 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist)
1975 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1976 if (!keep_[r - 1])
continue;
1978 xml::Element& m = sim.add_child(
"measure");
1979 m.set_attr(
"alpha",
jmt_sig2(1.0 - opt_.sim_conf_int));
1980 m.set_attr(
"name", std::string(
"Performance_") +
1981 jmt_int(
static_cast<double>(ist)));
1982 m.set_attr(
"nodeType",
"station");
1983 m.set_attr(
"precision",
jmt_sig2(opt_.sim_max_rel_err));
1984 m.set_attr(
"referenceNode", nname(sn_.station_to_node[ist - 1]));
1985 m.set_attr(
"referenceUserClass", cname(r));
1987 m.set_attr(
"verbose",
"false");
1992 void save_sys_tard_metrics(xml::Element& sim) {
1993 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
1994 if (!keep_[r - 1])
continue;
1995 xml::Element& m = sim.add_child(
"measure");
1996 m.set_attr(
"alpha",
jmt_sig2(1.0 - opt_.sim_conf_int));
1997 m.set_attr(
"name",
"Performance_1");
1998 m.set_attr(
"nodeType",
"");
1999 m.set_attr(
"precision",
jmt_sig2(opt_.sim_max_rel_err));
2000 m.set_attr(
"referenceNode",
"");
2001 m.set_attr(
"referenceUserClass", cname(r));
2003 m.set_attr(
"verbose",
"false");
2015 void save_class_soft_deadlines(xml::Element& node, std::size_t ind) {
2016 const std::size_t ist = sn_.nodes[ind - 1].station;
2017 if (ist == 0)
return;
2019 if (sc != SchedStrategy::EDD && sc != SchedStrategy::EDF)
return;
2021 if (!reason.empty())
throw UnsupportedError(ErrorKind{
"Structure"}, reason);
2022 xml::Element& dl = node.add_child(
"classSoftDeadlines");
2023 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2024 if (!keep_[r - 1])
continue;
2027 const double d = sn_.classes[r - 1].deadline;
2029 std::snprintf(buf,
sizeof(buf),
"%.12f", std::isfinite(d) ? d : 0.0);
2030 dl.add_text_child(
"softDeadline", buf);
2035 void save_cache_hit_rate_metrics(xml::Element& sim) {
2036 for (
const auto& kv : sn_.nodeparam) {
2037 const std::size_t ind = kv.first;
2038 if (sn_.nodes[ind - 1].nodetype != NodeType::Cache)
continue;
2039 const qn::CacheParam<T>& cp = kv.second;
2040 for (std::size_t r = 0; r < cp.hitclass.size(); ++r) {
2041 if (cp.hitclass[r] == 0)
continue;
2042 xml::Element& m = sim.add_child(
"measure");
2043 m.set_attr(
"alpha",
jmt_sig2(1.0 - opt_.sim_conf_int));
2044 m.set_attr(
"name",
"CacheHitRate_" + nname(ind) +
"_" + cname(cp.hitclass[r]));
2045 m.set_attr(
"nodeType",
"station");
2046 m.set_attr(
"precision",
jmt_sig2(opt_.sim_max_rel_err));
2047 m.set_attr(
"referenceNode", nname(ind));
2048 m.set_attr(
"referenceUserClass", cname(cp.hitclass[r]));
2049 m.set_attr(
"type",
"Cache Hit Rate");
2050 m.set_attr(
"verbose",
"false");
2056 void save_fcr_metrics(xml::Element& sim) {
2057 static const char* kinds[6] = {
"Number of Customers",
"Response Time",
"Residence Time",
2058 "Throughput",
"FCR Capacity",
"FCR Memory"};
2060 for (std::size_t f = 1; f <= sn_.regions.size(); ++f) {
2061 const std::string fcr =
"FCRegion" +
jmt_int(
static_cast<double>(f));
2062 for (
int k = 0; k < 6; ++k) {
2063 std::string flat(kinds[k]);
2064 flat.erase(std::remove(flat.begin(), flat.end(),
' '), flat.end());
2065 xml::Element& m = sim.add_child(
"measure");
2066 m.set_attr(
"alpha",
jmt_sig2(1.0 - opt_.sim_conf_int));
2067 m.set_attr(
"name",
"FCR_" + fcr +
"_" + flat +
"_" +
2068 jmt_int(
static_cast<double>(counter)));
2069 m.set_attr(
"nodeType",
"region");
2070 m.set_attr(
"precision",
jmt_sig2(opt_.sim_max_rel_err));
2071 m.set_attr(
"referenceNode", fcr);
2072 m.set_attr(
"referenceUserClass",
"");
2073 m.set_attr(
"type", kinds[k]);
2074 m.set_attr(
"verbose",
"false");
2081 void save_links(xml::Element& sim) {
2083 for (std::size_t j = 1; j <= sn_.nodes.size(); ++j)
2084 for (std::size_t i = 1; i <= sn_.nodes.size(); ++i) {
2085 if (!conn_[i - 1][j - 1])
continue;
2086 xml::Element& c = sim.add_child(
"connection");
2087 c.set_attr(
"source", nname(i));
2088 c.set_attr(
"target", nname(j));
2090 for (
const auto& pt : inhibitor_only_arcs()) {
2091 xml::Element& c = sim.add_child(
"connection");
2092 c.set_attr(
"source", nname(pt.first));
2093 c.set_attr(
"target", nname(pt.second));
2106 void save_preload(xml::Element& sim) {
2112 std::vector<std::pair<std::size_t, double>> pops;
2114 std::vector<Row> rows;
2115 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist) {
2116 const std::size_t ind = sn_.station_to_node[ist - 1];
2117 const NodeType ty = sn_.nodes[ind - 1].nodetype;
2118 if (ty == NodeType::Source || ty == NodeType::Join)
continue;
2119 const std::vector<double> nir = initial_marginal(ist);
2122 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2123 const double n = sn_.classes[r - 1].population;
2124 if (std::isfinite(n) && n == 0.0 && nir[r - 1] == 0.0)
continue;
2125 row.pops.emplace_back(r, nir[r - 1]);
2127 if (!row.pops.empty()) rows.push_back(row);
2129 if (rows.empty())
return;
2130 xml::Element& preload = sim.add_child(
"preload");
2131 for (
const Row& row : rows) {
2132 xml::Element& st = preload.add_child(
"stationPopulations");
2133 st.set_attr(
"stationName", nname(row.node));
2134 for (
const auto& pc : row.pops) {
2135 xml::Element& cp = st.add_child(
"classPopulation");
2136 cp.set_attr(
"population",
jmt_int(pc.second));
2137 cp.set_attr(
"refClass", cname(pc.first));
2150 std::vector<double> initial_marginal(std::size_t ist)
const {
2151 std::vector<double> nir(sn_.nclasses, 0.0);
2152 const std::size_t ind = sn_.station_to_node[ist - 1];
2153 const auto im = sn_.initmarking.find(ind);
2154 if (im != sn_.initmarking.end()) {
2155 for (std::size_t r = 0; r < sn_.nclasses && r < im->second.size(); ++r)
2156 nir[r] = d(im->second[r]);
2159 for (std::size_t r = 0; r < sn_.nclasses; ++r) {
2160 const double n = sn_.classes[r].population;
2161 if (std::isfinite(n) && sn_.classes[r].refstat == ist) nir[r] = n;
2169 void save_total_capacity(xml::Element& section, std::size_t ind) {
2170 const std::size_t ist = sn_.nodes[ind - 1].station;
2171 const std::string v =
2172 (ist == 0 || !std::isfinite(sn_.cap[ist - 1])) ?
"-1" :
jmt_int(sn_.cap[ist - 1]);
2177 void save_place_capacities(xml::Element& section, std::size_t ind) {
2178 const std::size_t ist = sn_.nodes[ind - 1].station;
2179 xml::Element& p =
jmt_param(section,
"java.lang.Integer",
"capacities",
true);
2180 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2181 if (!keep_[r - 1])
continue;
2183 const double c = ist == 0 ? std::numeric_limits<double>::infinity()
2184 : sn_.classcap[ist - 1][r - 1];
2185 xml::Element& sp = p.add_child(
"subParameter");
2186 sp.set_attr(
"classPath",
"java.lang.Integer");
2187 sp.set_attr(
"name",
"capacity");
2188 sp.add_text_child(
"value", std::isfinite(c) ?
jmt_int(c) :
"-1");
2196 void save_drop_rule(xml::Element& section, std::size_t ind) {
2197 const std::size_t ist = sn_.nodes[ind - 1].station;
2198 xml::Element& p =
jmt_param(section,
"java.lang.String",
"dropRules",
true);
2199 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2200 if (!keep_[r - 1])
continue;
2202 xml::Element& sp = p.add_child(
"subParameter");
2203 sp.set_attr(
"classPath",
"java.lang.String");
2204 sp.set_attr(
"name",
"dropRule");
2205 sp.add_text_child(
"value", drop_strategy_text(ist, r));
2214 void save_put_strategies(xml::Element& section, std::size_t ind) {
2215 const std::size_t ist = sn_.nodes[ind - 1].station;
2216 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.QueuePutStrategy",
2217 "QueuePutStrategy",
true);
2218 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2219 if (!keep_[r - 1])
continue;
2221 const char* nm =
"TailStrategy";
2223 if (sn_.stations[ist - 1].sched == SchedStrategy::SIRO) nm =
"RandStrategy";
2224 else if (sn_.stations[ist - 1].sched == SchedStrategy::LCFS) nm =
"HeadStrategy";
2226 xml::Element& sp = p.add_child(
"subParameter");
2227 sp.set_attr(
"classPath",
2228 std::string(
"jmt.engine.NetStrategies.QueuePutStrategies.") + nm);
2229 sp.set_attr(
"name", nm);
2236 const qn::TransitionParam<T>& transparam(std::size_t ind)
const {
2237 const auto it = sn_.transparam.find(ind);
2238 if (it == sn_.transparam.end())
2239 throw InputError(
"SolverJMT: transition '" + nname(ind) +
"' carries no mode table");
2256 void save_enabling_conditions(xml::Element& section, std::size_t ind) {
2257 const qn::TransitionParam<T>& tp = transparam(ind);
2259 jmt_param(section,
"jmt.engine.NetStrategies.TransitionUtilities.TransitionMatrix",
2260 "enablingConditions",
true);
2261 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2262 xml::Element& cond = p.add_child(
"subParameter");
2263 cond.set_attr(
"classPath",
2264 "jmt.engine.NetStrategies.TransitionUtilities.TransitionMatrix");
2265 cond.set_attr(
"name",
"enablingCondition");
2266 xml::Element& vecs = jmt_param_sub(
2267 cond,
"jmt.engine.NetStrategies.TransitionUtilities.TransitionVector",
2269 for (std::size_t k = 1; k <= sn_.nodes.size(); ++k) {
2270 bool relevant =
false;
2271 for (std::size_t r = 1; r <= sn_.nclasses && !relevant; ++r) {
2272 const double en = arc(tp.enabling, m, k, r);
2273 const double in = arc(tp.inhibiting, m, k, r);
2274 relevant = (std::isfinite(en) && en > 0.0) ||
2275 (std::isfinite(in) && in > 0.0);
2277 if (!relevant)
continue;
2278 xml::Element& vec = vecs.add_child(
"subParameter");
2279 vec.set_attr(
"classPath",
2280 "jmt.engine.NetStrategies.TransitionUtilities.TransitionVector");
2281 vec.set_attr(
"name",
"enablingVector");
2282 jmt_scalar(vec,
"java.lang.String",
"stationName", nname(k));
2283 xml::Element& entries = jmt_param_sub(vec,
"java.lang.Integer",
"enablingEntries");
2284 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2285 const double en = arc(tp.enabling, m, k, r);
2287 xml::Element& e = entries.add_child(
"subParameter");
2288 e.set_attr(
"classPath",
"java.lang.Integer");
2289 e.set_attr(
"name",
"enablingEntry");
2290 e.add_text_child(
"value", std::isfinite(en) ?
jmt_int(en) :
"-1");
2304 void save_inhibiting_conditions(xml::Element& section, std::size_t ind) {
2305 const qn::TransitionParam<T>& tp = transparam(ind);
2306 std::vector<std::size_t> inputs = inputs_of(ind);
2307 for (
const auto& pt : inhibitor_only_arcs())
2308 if (pt.second == ind && std::find(inputs.begin(), inputs.end(), pt.first) == inputs.end())
2309 inputs.push_back(pt.first);
2311 jmt_param(section,
"jmt.engine.NetStrategies.TransitionUtilities.TransitionMatrix",
2312 "inhibitingConditions",
true);
2313 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2314 xml::Element& cond = p.add_child(
"subParameter");
2315 cond.set_attr(
"classPath",
2316 "jmt.engine.NetStrategies.TransitionUtilities.TransitionMatrix");
2317 cond.set_attr(
"name",
"inhibitingCondition");
2318 xml::Element& vecs = jmt_param_sub(
2319 cond,
"jmt.engine.NetStrategies.TransitionUtilities.TransitionVector",
2320 "inhibitingVectors");
2321 for (std::size_t k : inputs) {
2322 xml::Element& vec = vecs.add_child(
"subParameter");
2323 vec.set_attr(
"classPath",
2324 "jmt.engine.NetStrategies.TransitionUtilities.TransitionVector");
2325 vec.set_attr(
"name",
"inhibitingVector");
2326 jmt_scalar(vec,
"java.lang.String",
"stationName", nname(k));
2327 xml::Element& entries = jmt_param_sub(vec,
"java.lang.Integer",
"inhibitingEntries");
2328 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2329 const double in = arc(tp.inhibiting, m, k, r);
2331 xml::Element& e = entries.add_child(
"subParameter");
2332 e.set_attr(
"classPath",
"java.lang.Integer");
2333 e.set_attr(
"name",
"inhibitingEntry");
2334 e.add_text_child(
"value", std::isfinite(in) ?
jmt_int(in) :
"0");
2341 void save_firing_outcomes(xml::Element& section, std::size_t ind) {
2342 const qn::TransitionParam<T>& tp = transparam(ind);
2343 const std::vector<std::size_t> outs = outputs_of(ind);
2345 jmt_param(section,
"jmt.engine.NetStrategies.TransitionUtilities.TransitionMatrix",
2346 "firingOutcomes",
true);
2347 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2348 xml::Element& out = p.add_child(
"subParameter");
2349 out.set_attr(
"classPath",
2350 "jmt.engine.NetStrategies.TransitionUtilities.TransitionMatrix");
2351 out.set_attr(
"name",
"firingOutcome");
2352 xml::Element& vecs = jmt_param_sub(
2353 out,
"jmt.engine.NetStrategies.TransitionUtilities.TransitionVector",
2355 for (std::size_t k : outs) {
2356 xml::Element& vec = vecs.add_child(
"subParameter");
2357 vec.set_attr(
"classPath",
2358 "jmt.engine.NetStrategies.TransitionUtilities.TransitionVector");
2359 vec.set_attr(
"name",
"firingVector");
2360 jmt_scalar(vec,
"java.lang.String",
"stationName", nname(k));
2361 xml::Element& entries = jmt_param_sub(vec,
"java.lang.Integer",
"firingEntries");
2362 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2363 const double f = arc(tp.firing, m, k, r);
2365 xml::Element& e = entries.add_child(
"subParameter");
2366 e.set_attr(
"classPath",
"java.lang.Integer");
2367 e.set_attr(
"name",
"firingEntry");
2368 e.add_text_child(
"value",
jmt_int(f));
2375 double arc(
const std::vector<Matrix<T>>& tab, std::size_t m, std::size_t k,
2376 std::size_t r)
const {
2377 if (m >= tab.size() || k == 0 || k > tab[m].rows() || r == 0 || r > tab[m].cols())
2379 return d(tab[m](k - 1, r - 1));
2383 void save_mode_names(xml::Element& section, std::size_t ind) {
2384 const qn::TransitionParam<T>& tp = transparam(ind);
2385 xml::Element& p =
jmt_param(section,
"java.lang.String",
"modeNames",
true);
2386 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2387 xml::Element& sp = p.add_child(
"subParameter");
2388 sp.set_attr(
"classPath",
"java.lang.String");
2389 sp.set_attr(
"name",
"modeName");
2390 sp.add_text_child(
"value", m < tp.modenames.size() ? tp.modenames[m] : std::string());
2395 void save_numbers_of_servers(xml::Element& section, std::size_t ind) {
2396 const qn::TransitionParam<T>& tp = transparam(ind);
2397 xml::Element& p =
jmt_param(section,
"java.lang.Integer",
"numbersOfServers",
true);
2398 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2399 const double ns = m < tp.nmodeservers.size() ? tp.nmodeservers[m] : 1.0;
2400 xml::Element& sp = p.add_child(
"subParameter");
2401 sp.set_attr(
"classPath",
"java.lang.Integer");
2402 sp.set_attr(
"name",
"numberOfServers");
2403 sp.add_text_child(
"value", std::isfinite(ns) ?
jmt_int(ns) :
"-1");
2415 void save_timing_strategies(xml::Element& section, std::size_t ind) {
2416 const qn::TransitionParam<T>& tp = transparam(ind);
2417 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.ServiceStrategy",
2418 "timingStrategies",
true);
2419 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2420 xml::Element& sp = p.add_child(
"subParameter");
2421 const bool immediate = m < tp.timing.size() &&
2424 sp.set_attr(
"classPath",
2425 "jmt.engine.NetStrategies.ServiceStrategies.ZeroServiceTimeStrategy");
2426 sp.set_attr(
"name",
"ZeroServiceTimeStrategy");
2429 sp.set_attr(
"classPath",
2430 "jmt.engine.NetStrategies.ServiceStrategies.ServiceTimeStrategy");
2431 sp.set_attr(
"name",
"timingStrategy");
2432 if (m >= tp.firingproc.size())
2434 (m < tp.modenames.size() ? tp.modenames[m] : std::string()) +
2435 "' of transition '" + nname(ind) +
"' has no firing process");
2437 "SolverJMT (transition firing)");
2442 void save_firing_priorities(xml::Element& section, std::size_t ind) {
2443 const qn::TransitionParam<T>& tp = transparam(ind);
2444 xml::Element& p =
jmt_param(section,
"java.lang.Integer",
"firingPriorities",
true);
2445 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2446 const double v = m < tp.firingprio.size() ? tp.firingprio[m] : 1.0;
2447 xml::Element& sp = p.add_child(
"subParameter");
2448 sp.set_attr(
"classPath",
"java.lang.Integer");
2449 sp.set_attr(
"name",
"firingPriority");
2450 sp.add_text_child(
"value", std::isfinite(v) ?
jmt_int(v) :
"-1");
2463 void save_firing_weights(xml::Element& section, std::size_t ind) {
2464 const qn::TransitionParam<T>& tp = transparam(ind);
2465 xml::Element& p =
jmt_param(section,
"java.lang.Double",
"firingWeights",
true);
2466 for (std::size_t m = 0; m < tp.nmodes; ++m) {
2467 const double v = m < tp.fireweight.size() ? d(tp.fireweight[m]) : 1.0;
2468 xml::Element& sp = p.add_child(
"subParameter");
2469 sp.set_attr(
"classPath",
"java.lang.Double");
2470 sp.set_attr(
"name",
"firingWeight");
2471 sp.add_text_child(
"value", std::isfinite(v) ?
jmt_fmt(v) :
"-1");
2487 std::vector<std::vector<double>> class_cap_constraints()
const {
2488 const double inf = std::numeric_limits<double>::infinity();
2489 std::vector<std::vector<double>> con(sn_.nstations, std::vector<double>(sn_.nclasses, inf));
2490 if (sn_.classcap.empty())
return con;
2491 std::vector<double> chainpop(sn_.nclasses, inf);
2492 for (std::size_t c = 0; c < sn_.inchain.size(); ++c) {
2495 for (std::size_t r : sn_.inchain[c]) {
2496 const double n = sn_.classes[r - 1].population;
2497 if (std::isfinite(n))
tot += n;
else open =
true;
2499 for (std::size_t r : sn_.inchain[c]) chainpop[r - 1] = open ? inf :
tot;
2501 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist) {
2502 const NodeType ty = sn_.nodes[sn_.station_to_node[ist - 1] - 1].nodetype;
2503 if (ty == NodeType::Source || ty == NodeType::Place)
continue;
2504 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2505 if (sn_.disabled[ist - 1][r - 1])
continue;
2506 const double cc = sn_.classcap[ist - 1][r - 1];
2507 if (std::isfinite(cc) && cc < 2147483647.0 &&
2508 cc < std::min(sn_.cap[ist - 1], chainpop[r - 1]))
2509 con[ist - 1][r - 1] = cc;
2525 void assert_class_cap_exportable(std::size_t ist, std::size_t r)
const {
2526 const std::string sname = nname(sn_.station_to_node[ist - 1]);
2527 if (std::isfinite(sn_.classes[r - 1].population))
2529 "SolverJMT: station '" + sname +
"' carries a finite capacity " +
2530 jmt_int(sn_.classcap[ist - 1][r - 1]) +
" for the closed class '" + cname(r) +
2531 "'. LINE holds a blocked closed job at its upstream station, whereas JMT can "
2532 "only express a per-class capacity as a blocking region, which parks the job in "
2533 "the region input station instead, freeing the upstream server and losing it "
2534 "from the population count. Use SolverCTMC, SolverSSA or SolverLDES, or express "
2535 "the limit as the station capacity");
2537 if (dr == DropStrategy::BAS || dr == DropStrategy::BBS || dr == DropStrategy::RSRD ||
2538 dr == DropStrategy::RETRIAL || dr == DropStrategy::RETRIAL_WITH_LIMIT)
2540 "SolverJMT: station '" + sname +
"' applies drop strategy '" +
jmt_drop_text(dr) +
2541 "' to class '" + cname(r) +
2542 "' and also carries a finite capacity for it. JMT exports a per-class capacity "
2543 "as a blocking region, which can only drop or defer an arrival. Remove the "
2544 "per-class capacity, or use the station capacity, which is exported with its "
2560 void save_regions(xml::Element& sim) {
2561 const std::vector<std::vector<double>> con = class_cap_constraints();
2562 std::vector<bool> covered(sn_.nstations,
false);
2563 std::size_t lps_idx = sn_.regions.size();
2565 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist) {
2566 if (sn_.stations[ist - 1].sched != SchedStrategy::LPS)
continue;
2568 const std::size_t ind = sn_.station_to_node[ist - 1];
2569 const double limit = sn_.stations[ist - 1].schedparam.empty()
2571 : d(sn_.stations[ist - 1].schedparam[0]);
2572 xml::Element& br = sim.add_child(
"blockingRegion");
2573 br.set_attr(
"name",
"LPSRegion" +
jmt_int(
static_cast<double>(lps_idx)));
2574 br.set_attr(
"type",
"default");
2575 br.add_child(
"regionNode").set_attr(
"nodeName", nname(ind));
2576 br.add_child(
"globalConstraint").set_attr(
"maxJobs",
jmt_num(limit));
2577 br.add_child(
"globalMemoryConstraint").set_attr(
"maxMemory",
"-1");
2578 covered[ist - 1] =
true;
2579 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2580 if (!std::isfinite(con[ist - 1][r - 1]))
continue;
2581 assert_class_cap_exportable(ist, r);
2583 "SolverJMT: station '" + nname(ind) +
2584 "' has both LPS scheduling and a finite capacity for the open class '" +
2586 "'. JMT expresses both through a single blocking region, which admits only "
2587 "one drop rule per class, but LPS requires blocking while the open-class "
2588 "capacity requires dropping. Remove the per-class capacity or use a non-LPS "
2589 "scheduling strategy");
2591 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2592 xml::Element& dr = br.add_child(
"dropRules");
2593 dr.set_attr(
"jobClass", cname(r));
2594 dr.set_attr(
"dropThisClass",
"false");
2598 for (std::size_t f = 1; f <= sn_.regions.size(); ++f) {
2599 const typename qn::NetworkStruct<T>::Region& rg = sn_.regions[f - 1];
2600 std::vector<std::size_t> members;
2601 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist)
2602 if (ist <= rg.members.size() && rg.members[ist - 1]) {
2603 members.push_back(ist);
2604 covered[ist - 1] =
true;
2606 std::vector<double> region_class_cap(sn_.nclasses,
2607 std::numeric_limits<double>::infinity());
2608 for (std::size_t ist : members)
2609 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2610 if (!std::isfinite(con[ist - 1][r - 1]))
continue;
2611 if (members.size() > 1)
2613 "SolverJMT: station '" + nname(sn_.station_to_node[ist - 1]) +
2614 "' carries a finite capacity for class '" + cname(r) +
2615 "' and also belongs to the multi-station region FCRegion" +
2616 jmt_int(
static_cast<double>(f)) +
2617 ". JMT constrains a blocking region as a whole and allows a node to "
2618 "belong to only one region, so a per-station class capacity cannot "
2619 "be expressed alongside it");
2620 assert_class_cap_exportable(ist, r);
2621 if (!(r <= rg.rule.size() && rg.rule[r - 1] == DropStrategy::DROP))
2623 "SolverJMT: station '" + nname(sn_.station_to_node[ist - 1]) +
2624 "' carries a finite capacity for class '" + cname(r) +
2625 "' and also belongs to region FCRegion" +
2626 jmt_int(
static_cast<double>(f)) +
2627 ", whose drop rule for that class is not DROP. A JMT blocking "
2628 "region admits a single drop rule per class, shared by all of its "
2629 "constraints, and the per-class capacity of an open class is a loss "
2631 region_class_cap[r - 1] = con[ist - 1][r - 1];
2634 xml::Element& br = sim.add_child(
"blockingRegion");
2635 br.set_attr(
"name",
"FCRegion" +
jmt_int(
static_cast<double>(f)));
2636 br.set_attr(
"type",
"default");
2637 for (std::size_t ist : members)
2638 br.add_child(
"regionNode")
2639 .set_attr(
"nodeName", nname(sn_.station_to_node[ist - 1]));
2643 members.empty() ? -1.0 : rg.cap[members[0] - 1][sn_.nclasses];
2644 const double gmem = members.empty() ? -1.0 : rg.maxmem[members[0] - 1];
2645 br.add_child(
"globalConstraint").set_attr(
"maxJobs",
jmt_num(gmax));
2646 br.add_child(
"globalMemoryConstraint").set_attr(
"maxMemory",
jmt_num(gmem));
2647 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2648 double cmax = members.empty() ? -1.0 : rg.cap[members[0] - 1][r - 1];
2652 cmax = std::isfinite(region_class_cap[r - 1]) ? region_class_cap[r - 1] : -1.0;
2653 else if (std::isfinite(region_class_cap[r - 1]))
2654 cmax = std::min(cmax, region_class_cap[r - 1]);
2655 if (cmax == -1.0 || !std::isfinite(cmax))
continue;
2656 xml::Element& cc = br.add_child(
"classConstraint");
2657 cc.set_attr(
"jobClass", cname(r));
2658 cc.set_attr(
"maxJobsPerClass",
jmt_num(cmax));
2664 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2665 xml::Element& dr = br.add_child(
"dropRules");
2666 dr.set_attr(
"jobClass", cname(r));
2667 dr.set_attr(
"dropThisClass",
2668 (r <= rg.rule.size() && rg.rule[r - 1] == DropStrategy::DROP)
2672 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2673 if (r > rg.weight.size())
continue;
2674 const double w = d(rg.weight[r - 1]);
2675 if (w == 1.0)
continue;
2676 xml::Element& cw = br.add_child(
"classWeight");
2677 cw.set_attr(
"jobClass", cname(r));
2678 cw.set_attr(
"weight",
jmt_num(w));
2680 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2681 if (r > rg.size.size())
continue;
2682 const double s = d(rg.size[r - 1]);
2683 if (s == 1.0)
continue;
2684 xml::Element& cs = br.add_child(
"classSize");
2685 cs.set_attr(
"jobClass", cname(r));
2686 cs.set_attr(
"size",
jmt_num(s));
2690 std::size_t cap_idx = 0;
2691 for (std::size_t ist = 1; ist <= sn_.nstations; ++ist) {
2692 if (covered[ist - 1])
continue;
2694 for (std::size_t r = 1; r <= sn_.nclasses; ++r)
2695 if (std::isfinite(con[ist - 1][r - 1])) any =
true;
2698 for (std::size_t r = 1; r <= sn_.nclasses; ++r)
2699 if (std::isfinite(con[ist - 1][r - 1])) assert_class_cap_exportable(ist, r);
2700 xml::Element& br = sim.add_child(
"blockingRegion");
2701 br.set_attr(
"name",
"ClassCapRegion" +
jmt_int(
static_cast<double>(cap_idx)));
2702 br.set_attr(
"type",
"default");
2703 br.add_child(
"regionNode")
2704 .set_attr(
"nodeName", nname(sn_.station_to_node[ist - 1]));
2705 br.add_child(
"globalConstraint").set_attr(
"maxJobs",
"-1");
2706 br.add_child(
"globalMemoryConstraint").set_attr(
"maxMemory",
"-1");
2707 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2708 if (!std::isfinite(con[ist - 1][r - 1]))
continue;
2709 xml::Element& cc = br.add_child(
"classConstraint");
2710 cc.set_attr(
"jobClass", cname(r));
2711 cc.set_attr(
"maxJobsPerClass",
jmt_num(con[ist - 1][r - 1]));
2713 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
2714 if (!std::isfinite(con[ist - 1][r - 1]))
continue;
2715 xml::Element& dr = br.add_child(
"dropRules");
2716 dr.set_attr(
"jobClass", cname(r));
2717 dr.set_attr(
"dropThisClass",
"true");
2745 void save_cache_strategy(xml::Element& section, std::size_t ind) {
2746 const auto it = sn_.nodeparam.find(ind);
2747 if (it == sn_.nodeparam.end())
2748 throw InputError(
"SolverJMT: cache node '" + nname(ind) +
"' carries no parameters");
2749 const qn::CacheParam<T>& cp = it->second;
2750 const std::size_t K = sn_.nclasses;
2757 jmt_int(
static_cast<double>(cp.nitems)));
2758 xml::Element& cap =
jmt_param(section,
"java.lang.Integer",
"cacheCapacity",
true);
2759 for (std::size_t l = 0; l < cp.itemcap.size(); ++l) {
2760 xml::Element& sp = cap.add_child(
"subParameter");
2761 sp.set_attr(
"classPath",
"java.lang.Integer");
2762 sp.set_attr(
"name",
"capacity");
2763 sp.add_text_child(
"value",
jmt_int(
static_cast<double>(cp.itemcap[l])));
2766 const std::size_t nlev = cp.itemcap.size();
2767 std::vector<std::size_t> readers;
2768 for (std::size_t r = 0; r < K; ++r)
2769 if ((r < cp.hitclass.size() && cp.hitclass[r] > 0) ||
2770 (r < cp.missclass.size() && cp.missclass[r] > 0))
2771 readers.push_back(r);
2772 const std::vector<std::vector<double>> promo = cache_jmt_promotion(cp, nlev, readers, ind);
2773 xml::Element& mat =
jmt_param(section,
"java.lang.Object",
"matrix",
true);
2774 for (std::size_t a = 0; a < nlev; ++a) {
2775 xml::Element& row = mat.add_child(
"subParameter");
2776 row.set_attr(
"array",
"true");
2777 row.set_attr(
"classPath",
"java.lang.Float");
2778 row.set_attr(
"name",
"row");
2780 for (std::size_t b = 0; b < nlev; ++b) {
2781 cum = std::min(cum + promo[a][b], 1.0);
2782 xml::Element& cell = row.add_child(
"subParameter");
2783 cell.set_attr(
"classPath",
"java.lang.Float");
2784 cell.set_attr(
"name",
"cell");
2786 std::snprintf(buf,
sizeof(buf),
"%.12g", cum);
2787 cell.add_text_child(
"value", buf);
2791 xml::Element& jc =
jmt_param(section,
"jmt.engine.QueueNet.JobClass",
"jobClasses",
true);
2792 for (std::size_t r = 1; r <= K; ++r) {
2793 const bool used = (r <= cp.hitclass.size() && cp.hitclass[r - 1] > 0) ||
2794 (r <= cp.missclass.size() && cp.missclass[r - 1] > 0);
2795 if (!used)
continue;
2796 xml::Element& sp = jc.add_child(
"subParameter");
2797 sp.set_attr(
"classPath",
"jmt.engine.QueueNet.JobClass");
2798 sp.set_attr(
"name",
"jobClass");
2799 sp.add_text_child(
"value", cname(r));
2801 const char* switch_names[2] = {
"hitClasses",
"missClasses"};
2802 const char* entry_names[2] = {
"hitClass",
"missClass"};
2803 for (
int w = 0; w < 2; ++w) {
2804 const std::vector<std::size_t>& tab = w == 0 ? cp.hitclass : cp.missclass;
2806 jmt_param(section,
"jmt.engine.QueueNet.JobClass", switch_names[w],
true);
2807 for (std::size_t r = 1; r <= K && r <= tab.size(); ++r) {
2808 if (tab[r - 1] == 0)
continue;
2809 xml::Element& sp = p.add_child(
"subParameter");
2810 sp.set_attr(
"classPath",
"jmt.engine.QueueNet.JobClass");
2811 sp.set_attr(
"name", entry_names[w]);
2812 sp.add_text_child(
"value", cname(tab[r - 1]));
2816 const char* policy =
nullptr;
2817 switch (cp.replacestrat) {
2819 policy =
"jmt.engine.NetStrategies.CacheStrategies.LRUCache";
2823 policy =
"jmt.engine.NetStrategies.CacheStrategies.FIFOCache";
2826 policy =
"jmt.engine.NetStrategies.CacheStrategies.RandomCache";
2831 xml::Element& rp = section.add_child(
"parameter");
2832 rp.set_attr(
"classPath", policy);
2833 rp.set_attr(
"name",
"replacePolicy");
2843 section,
"jmt.engine.random.discrete.DiscreteDistribution",
"popularity",
true);
2844 for (std::size_t r = 1; r <= K; ++r) {
2846 const bool reads = r <= cp.pread.size() && !cp.pread[r - 1].empty();
2847 const typename qn::CacheParam<T>::Popularity kind =
2848 r <= cp.preadkind.size() ? cp.preadkind[r - 1]
2849 :
typename qn::CacheParam<T>::Popularity();
2850 xml::Element& sp = pop.add_child(
"subParameter");
2852 sp.set_attr(
"classPath",
"jmt.engine.random.discrete.Zipf");
2853 sp.set_attr(
"name",
"popularity");
2855 jmt_scalar(sp,
"java.lang.Integer",
"numberOfElements",
2856 jmt_int(
static_cast<double>(kind.n)));
2859 sp.set_attr(
"classPath",
"jmt.engine.random.discrete.Uniform");
2860 sp.set_attr(
"name",
"popularity");
2861 jmt_scalar(sp,
"java.lang.Integer",
"min",
"1");
2863 jmt_int(
static_cast<double>(kind.n == 0 ? cp.nitems : kind.n)));
2867 sp.set_attr(
"classPath",
"jmt.engine.random.discrete.DiscreteDistribution");
2868 sp.set_attr(
"name",
"null");
2869 sp.add_text_child(
"value",
"null");
2885 std::vector<std::vector<double>> cache_jmt_promotion(
const qn::CacheParam<T>& cp,
2887 const std::vector<std::size_t>& readers,
2888 std::size_t ind)
const {
2889 std::vector<std::vector<double>>
P;
2890 const std::string why = cache_jmt_promotion_reason(cp, h, readers, ind, P);
2908 const auto it = sn_.nodeparam.find(ind);
2909 if (it == sn_.nodeparam.end())
return "SolverJMT: cache node '" + nname(ind) +
"' carries no parameters";
2911 const std::size_t K = sn_.nclasses;
2914 return "SolverJMT: cache '" + nname(ind) +
2915 "' uses a replacement policy JMT has no cache object for (HLRU, CLIMB and "
2916 "QLRU); use SolverLDES, which simulates them directly";
2917 const std::size_t nlev = cp.
itemcap.size();
2918 std::vector<std::size_t> readers;
2919 for (std::size_t r = 0; r < K; ++r)
2922 readers.push_back(r);
2923 std::vector<std::vector<double>> promo;
2925 const std::string why = cache_jmt_promotion_reason(cp, nlev, readers, ind, promo);
2926 if (!why.empty())
return why;
2930 for (std::size_t l = 0; l < nlev; ++l) {
2931 if (promo[l][l] > 0.0 && cp.
itemcap[l] > 1)
2932 return "SolverJMT: cache '" + nname(ind) +
"' uses " +
2934 " replacement, but JMT moves an item hit in list " + std::to_string(l + 1) +
2935 " (capacity " + std::to_string(cp.
itemcap[l]) +
2936 ") to the tail of that list, which is LRU order: the simulation would solve a "
2937 "different policy. JMT is exact for FIFO only when every list an item can stay "
2938 "in has capacity 1. Use SSA, LDES or CTMC.";
2942 for (std::size_t r = 1; r <= K; ++r) {
2943 const bool reads = r <= cp.
pread.size() && !cp.
pread[r - 1].empty();
2944 if (!reads)
continue;
2949 const auto& pm = cp.
pread[r - 1];
2951 for (
const auto& v : pm) psum +=
static_cast<double>(v);
2952 for (
const auto& v : pm)
2953 if (std::abs(
static_cast<double>(v) / psum - 1.0 /
static_cast<double>(pm.size())) > 1e-3)
2954 return "SolverJMT: cache '" + nname(ind) +
"' gives class '" + cname(r) +
2955 "' a non-uniform DiscreteSampler popularity, which JMT cannot express: its Cache "
2956 "section takes a parametric popularity (Zipf or uniform) and has no empirical "
2957 "discrete form, so this would be exported as a uniform draw over all " +
2958 std::to_string(cp.
nitems) +
" items and solved as a different model. Use Zipf, "
2959 "a uniform popularity, or a solver other than JMT (SSA, LDES, CTMC, MVA, NC all take it).";
2964 return "SolverJMT: cache '" + nname(ind) +
"' gives class '" + cname(r) +
2965 "' a popularity that is neither Zipf nor uniform; the JMT Cache section takes Zipf "
2966 "or a uniform popularity only. Use SSA, LDES, CTMC, MVA or NC.";
2968 return std::string();
2973 std::string cache_jmt_promotion_reason(
const qn::CacheParam<T>& cp, std::size_t h,
2974 const std::vector<std::size_t>& readers, std::size_t ind,
2975 std::vector<std::vector<double>>& P)
const {
2976 const double tol = 1e-8;
2977 std::vector<std::vector<double>> ref;
2978 for (
const std::size_t r : readers) {
2979 if (r >= cp.
accost.size())
continue;
2980 for (std::size_t k = 0; k < cp.
nitems && k < cp.
accost[r].size(); ++k) {
2982 if (M.
empty())
continue;
2983 std::vector<std::vector<double>> dm(M.
rows(), std::vector<double>(M.
cols(), 0.0));
2984 for (std::size_t a = 0; a < M.
rows(); ++a)
2985 for (std::size_t b = 0; b < M.
cols(); ++b) dm[a][b] =
static_cast<double>(M(a, b));
2990 bool same = dm.size() == ref.size() && dm[0].size() == ref[0].size();
2991 for (std::size_t a = 0; same && a < dm.size(); ++a)
2992 for (std::size_t b = 0; same && b < dm[a].size(); ++b)
2993 if (std::abs(dm[a][b] - ref[a][b]) > tol) same =
false;
2995 return "SolverJMT: cache '" + nname(ind) +
"' has an access graph that differs across "
2996 "classes or items; the JMT Cache section takes one list-promotion matrix for all "
2997 "of them. Use SSA, LDES or CTMC.";
3000 P.assign(h, std::vector<double>(h, 0.0));
3002 for (std::size_t l = 0; l < h; ++l) P[l][std::min(l + 1, h - 1)] = 1.0;
3003 return std::string();
3005 if (ref.size() != h + 1 || ref[0].size() != h + 1)
3006 return "SolverJMT: cache '" + nname(ind) +
"' has a " + std::to_string(ref.size()) +
"x" +
3007 std::to_string(ref[0].size()) +
" access graph for " + std::to_string(h) +
3008 " lists; expected " + std::to_string(h + 1) +
"x" + std::to_string(h + 1) +
".";
3009 double ins_sum = 0.0;
3010 for (std::size_t b = 1; b <= h; ++b) ins_sum += ref[0][b];
3011 if (ref[0][0] > 0.0 || std::abs(ins_sum - 1.0) > tol || std::abs(ref[0][1] - 1.0) > tol)
3012 return "SolverJMT: cache '" + nname(ind) +
"' inserts a missed item somewhere other than "
3013 "list 1; JMT always inserts a miss into the first list. Use SSA, LDES or CTMC.";
3014 for (std::size_t l = 1; l <= h; ++l) {
3015 if (ref[l][0] > 0.0)
3016 return "SolverJMT: cache '" + nname(ind) +
"' demotes a hit in list " + std::to_string(l) +
3017 " out of the cache; the JMT Cache section has no such move. Use SSA, LDES or CTMC.";
3019 for (std::size_t b = 1; b <= h; ++b) tot += ref[l][b];
3021 P[l - 1][l - 1] = 1.0;
3023 for (std::size_t b = 1; b <= h; ++b) P[l - 1][b - 1] = ref[l][b] / tot;
3026 return std::string();
3039 void save_impatience(xml::Element& section, std::size_t ind) {
3040 const std::size_t ist = sn_.nodes[ind - 1].station;
3042 section,
"jmt.engine.NetStrategies.ImpatienceStrategies.Impatience",
"Impatience",
true);
3043 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
3044 if (!keep_[r - 1])
continue;
3046 xml::Element& sp = p.add_child(
"subParameter");
3047 const qn::Station<T>* st = ist == 0 ? nullptr : &sn_.stations[ist - 1];
3048 const bool balks = st !=
nullptr && r <= st->balking.size() &&
3049 st->balking[r - 1].strategy ==
3052 sp.set_attr(
"classPath",
"jmt.engine.NetStrategies.ImpatienceStrategies.Balking");
3053 sp.set_attr(
"name",
"Balking");
3054 save_balking_strategy(sp, st->balking[r - 1].thresholds, st->nservers);
3057 sp.set_attr(
"classPath",
"jmt.engine.NetStrategies.ImpatienceStrategies.Reneging");
3058 sp.set_attr(
"name",
"Reneging");
3059 const bool renegs = st !=
nullptr && r <= st->impatience.size() &&
3061 r <= st->patience.size() && !st->patience[r - 1].disabled;
3063 sp.add_text_child(
"value",
"null");
3066 const JmtDistView<T> v =
jmt_dist_view(st->patience[r - 1]);
3072 xml::Element& dn = sp.add_child(
"subParameter");
3073 dn.set_attr(
"classPath",
"jmt.engine.random.Uniform");
3074 dn.set_attr(
"name",
"Uniform");
3075 xml::Element& par = sp.add_child(
"subParameter");
3076 par.set_attr(
"classPath",
"jmt.engine.random.UniformPar");
3077 par.set_attr(
"name",
"distrPar");
3078 jmt_scalar(par,
"java.lang.Double",
"min",
"0.0");
3079 jmt_double(par,
"max", v.rate > 0.0 ? 2.0 / v.rate : 0.0);
3098 void save_balking_strategy(xml::Element& balking,
3099 const std::vector<
typename qn::Station<T>::BalkingThreshold>& th,
3104 std::vector<typename qn::Station<T>::BalkingThreshold> sorted = th;
3105 std::sort(sorted.begin(), sorted.end(),
3106 [](
const typename qn::Station<T>::BalkingThreshold& a,
3107 const typename qn::Station<T>::BalkingThreshold& b) {
3108 return a.min_jobs < b.min_jobs;
3111 (!std::isfinite(nservers) || nservers < 1.0) ? 1.0 : nservers;
3112 std::vector<Bp> bps;
3113 for (std::size_t i = 0; i < sorted.size(); ++i) {
3114 const double lo = sorted[i].min_jobs;
3117 const double hi = sorted[i].max_jobs < 0.0
3118 ? std::numeric_limits<double>::infinity()
3119 : sorted[i].max_jobs;
3120 const double pr = d(sorted[i].probability);
3121 bps.push_back(Bp{std::max(0.0, lo - S), pr});
3122 if (!std::isfinite(hi))
continue;
3123 const double next_lo = i + 1 < sorted.size()
3124 ? sorted[i + 1].min_jobs
3125 : std::numeric_limits<double>::infinity();
3126 if (hi + 1.0 < next_lo) bps.push_back(Bp{std::max(0.0, hi + 1.0 - S), 0.0});
3128 xml::Element& ld = balking.add_child(
"subParameter");
3129 ld.set_attr(
"classPath",
"jmt.engine.NetStrategies.ServiceStrategies.LoadDependentStrategy");
3130 ld.set_attr(
"name",
"LoadDependentStrategy");
3131 xml::Element& arr = jmt_param_sub(
3132 ld,
"jmt.engine.NetStrategies.ServiceStrategies.LDParameter",
"LDParameter");
3133 for (
const Bp& b : bps) {
3134 xml::Element& rn = arr.add_child(
"subParameter");
3135 rn.set_attr(
"classPath",
"jmt.engine.NetStrategies.ServiceStrategies.LDParameter");
3136 rn.set_attr(
"name",
"LDParameter");
3140 xml::Element& dn = rn.add_child(
"subParameter");
3141 dn.set_attr(
"classPath",
"jmt.engine.random.Exponential");
3142 dn.set_attr(
"name",
"Exponential");
3143 xml::Element& par = rn.add_child(
"subParameter");
3144 par.set_attr(
"classPath",
"jmt.engine.random.ExponentialPar");
3145 par.set_attr(
"name",
"distrPar");
3146 jmt_scalar(par,
"java.lang.Double",
"lambda",
"1.0");
3149 jmt_scalar(balking,
"java.lang.Boolean",
"priorityActivated",
"false");
3159 void save_retrial_distributions(xml::Element& section, std::size_t ind) {
3160 const std::size_t ist = sn_.nodes[ind - 1].station;
3161 const auto it = ist == 0 ? sn_.retrialparam.end() : sn_.retrialparam.find(ist);
3162 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.ServiceStrategy",
3163 "retrialDistributions",
true);
3164 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
3165 if (!keep_[r - 1])
continue;
3167 xml::Element& sts = p.add_child(
"subParameter");
3168 sts.set_attr(
"classPath",
3169 "jmt.engine.NetStrategies.ServiceStrategies.ServiceTimeStrategy");
3170 sts.set_attr(
"name",
"ServiceTimeStrategy");
3171 const bool has = it != sn_.retrialparam.end() &&
3172 r <= it->second.retrial_proc.size() &&
3173 !it->second.retrial_proc[r - 1].disabled;
3175 xml::Element& dn = sts.add_child(
"subParameter");
3176 dn.set_attr(
"classPath",
"jmt.engine.random.Exponential");
3177 dn.set_attr(
"name",
"Exponential");
3178 xml::Element& par = sts.add_child(
"subParameter");
3179 par.set_attr(
"classPath",
"jmt.engine.random.ExponentialPar");
3180 par.set_attr(
"name",
"distrPar");
3181 jmt_scalar(par,
"java.lang.Double",
"lambda",
"1.000000000000");
3185 "SolverJMT (retrial delay)");
3199 void save_switchover_strategy(xml::Element& section, std::size_t ind) {
3200 const std::size_t ist = sn_.nodes[ind - 1].station;
3201 const typename qn::NetworkStruct<T>::PollingParam pp = sn_.effective_polling(ist);
3202 xml::Element& p =
jmt_param(section,
"jmt.engine.NetStrategies.ServiceStrategy",
3203 "SwitchoverStrategy",
true);
3204 for (std::size_t r = 1; r <= sn_.nclasses; ++r) {
3206 xml::Element& sts = p.add_child(
"subParameter");
3207 sts.set_attr(
"classPath",
3208 "jmt.engine.NetStrategies.ServiceStrategies.ServiceTimeStrategy");
3209 sts.set_attr(
"name",
"ServiceTimeStrategy");
3212 const std::size_t rp = (r + sn_.nclasses - 2) % sn_.nclasses + 1;
3213 const lang::Distrib<T>& so =
3214 rp <= pp.switchover.size() ? pp.switchover[rp - 1] : empty_dist_;
3223 sts.set_attr(
"classPath",
3224 "jmt.engine.NetStrategies.ServiceStrategies.ZeroServiceTimeStrategy");
3225 sts.set_attr(
"name",
"ZeroServiceTimeStrategy");
3232 std::map<std::size_t, double> empty_weights_;
3233 lang::Distrib<T> empty_dist_;