65 placement_number_distrib_ = std::discrete_distribution<size_t>(
69 placement_path_length_distrib_ = std::discrete_distribution<size_t>(
87 edge_proximities_.clear();
88 edge_proximities_.resize( edge_dist_matrix.rows() );
89 for(
size_t edge_idx = 0; edge_idx < edge_dist_matrix.rows(); ++edge_idx ) {
90 for(
size_t prox_idx = 0; prox_idx < edge_dist_matrix.cols(); ++prox_idx ) {
91 size_t level = edge_dist_matrix( edge_idx, prox_idx );
96 assert( edge_idx == prox_idx );
107 if( edge_proximities_[ edge_idx ].candidates_per_level.size() < level + 1 ) {
108 edge_proximities_[ edge_idx ].candidates_per_level.resize( level + 1 );
110 edge_proximities_[ edge_idx ].candidates_per_level[ level ].push_back( prox_idx );
111 edge_proximities_[ edge_idx ].total_candidates += 1;
123 auto result = std::vector<size_t>( placement_num );
126 if( placement_num == 0 ) {
134 auto edge_prox = edge_proximities_[ edge.
index() ];
135 for(
auto& candidates : edge_prox.candidates_per_level ) {
136 std::random_shuffle( candidates.begin() , candidates.end() );
141 if( placement_num > edge_prox.total_candidates ) {
142 placement_num = edge_prox.total_candidates;
146 for(
size_t i = 0; i < placement_num; ++i ) {
154 size_t path_len = placement_path_length_distrib_(
157 assert( path_len > 0 );
161 if( edge_prox.candidates_per_level[ path_len ].size() == 0 ) {
165 auto place_edge_num = edge_prox.candidates_per_level[ path_len ].back();
166 edge_prox.candidates_per_level[ path_len ].pop_back();
168 result[i] = place_edge_num;
183 for(
size_t edge_idx = 0; edge_idx < edge_proximities_.size(); ++edge_idx ) {
184 auto& prox = edge_proximities_[ edge_idx ];
187 for(
size_t cand_idx = 0; cand_idx < prox.candidates_per_level.size(); ++cand_idx ) {
188 auto& cand = prox.candidates_per_level[ cand_idx ];
203 auto result = std::vector<size_t>();
205 for(
auto const& prox : edge_proximities_ ) {
206 for(
size_t cand_idx = 0; cand_idx < prox.candidates_per_level.size(); ++cand_idx ) {
207 auto& cand = prox.candidates_per_level[ cand_idx ];
209 if( result.size() < cand_idx + 1 ) {
210 result.resize( cand_idx + 1 );
212 result[ cand_idx ] = std::max( result[ cand_idx ], cand.size() );
229 throw std::logic_error(
230 "The number of intervals and weights has to identical for "
231 "SimulatorLikeWeightRatioDistribution."
235 throw std::logic_error(
236 "Intervals need to be sorted in SimulatorLikeWeightRatioDistribution."
239 if( std::any_of(
weights.begin(),
weights.end(), [] (
double v ) { return v < 0.0; } )) {
240 throw std::logic_error(
241 "Weights need to be non-negative in SimulatorLikeWeightRatioDistribution."
246 distrib_ = std::piecewise_linear_distribution<double>(