| 1135 | } |
| 1136 | |
| 1137 | CSample *parse_distribution(bool oldstyle = false) |
| 1138 | { |
| 1139 | CSample *distribution = nullptr; |
| 1140 | const char *distname; |
| 1141 | const char *ptr = 0; |
| 1142 | |
| 1143 | if(!(distname = xp_get_value("distribution"))) { |
| 1144 | if (!oldstyle) { |
| 1145 | ERROR("statistically distributed actions or pauses requires 'distribution' parameter"); |
| 1146 | } |
| 1147 | if ((ptr = xp_get_value("normal"))) { |
| 1148 | distname = "normal"; |
| 1149 | } else if ((ptr = xp_get_value("exponential"))) { |
| 1150 | distname = "exponential"; |
| 1151 | } else if ((ptr = xp_get_value("lognormal"))) { |
| 1152 | distname = "lognormal"; |
| 1153 | } else if ((ptr = xp_get_value("weibull"))) { |
| 1154 | distname = "weibull"; |
| 1155 | } else if ((ptr = xp_get_value("pareto"))) { |
| 1156 | distname = "pareto"; |
| 1157 | } else if ((ptr = xp_get_value("gamma"))) { |
| 1158 | distname = "gamma"; |
| 1159 | } else if ((ptr = xp_get_value("min"))) { |
| 1160 | distname = "uniform"; |
| 1161 | } else if ((ptr = xp_get_value("max"))) { |
| 1162 | distname = "uniform"; |
| 1163 | } else if ((ptr = xp_get_value("milliseconds"))) { |
| 1164 | double val = get_double(ptr, "Pause milliseconds"); |
| 1165 | return new CFixed(val); |
| 1166 | } else { |
| 1167 | return new CDefaultPause(); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | if (!strcmp(distname, "fixed")) { |
| 1172 | double value = xp_get_double("value", "Fixed distribution"); |
| 1173 | distribution = new CFixed(value); |
| 1174 | } else if (!strcmp(distname, "uniform")) { |
| 1175 | double min = xp_get_double("min", "Uniform distribution"); |
| 1176 | double max = xp_get_double("max", "Uniform distribution"); |
| 1177 | distribution = new CUniform(min, max); |
| 1178 | #ifdef HAVE_GSL |
| 1179 | } else if (!strcmp(distname, "normal")) { |
| 1180 | double mean = xp_get_double("mean", "Normal distribution"); |
| 1181 | double stdev = xp_get_double("stdev", "Normal distribution"); |
| 1182 | distribution = new CNormal(mean, stdev); |
| 1183 | } else if (!strcmp(distname, "lognormal")) { |
| 1184 | double mean = xp_get_double("mean", "Lognormal distribution"); |
| 1185 | double stdev = xp_get_double("stdev", "Lognormal distribution"); |
| 1186 | distribution = new CLogNormal(mean, stdev); |
| 1187 | } else if (!strcmp(distname, "exponential")) { |
| 1188 | double mean = xp_get_double("mean", "Exponential distribution"); |
| 1189 | distribution = new CExponential(mean); |
| 1190 | } else if (!strcmp(distname, "weibull")) { |
| 1191 | double lambda = xp_get_double("lambda", "Weibull distribution"); |
| 1192 | double k = xp_get_double("k", "Weibull distribution"); |
| 1193 | distribution = new CWeibull(lambda, k); |
| 1194 | } else if (!strcmp(distname, "pareto")) { |
no test coverage detected