It's not clear to me that this is always better, though it might be. Let's make it an option: introduce a strict_cmp: bool
argument to _get_dominated_indices
and attribute to GreedyRouter
.
Update dominated_indices in greedy.py
Previously, the condition is if all(v>=w)
. Suppose that the vectors are just scalars and there are two minimal value v1 and v2. Now, because v1 >= v2 and v2 >= v1, they are both added to dominated_indices
. This means that the corresponding swap candidates both won't be considered. Additionally for any w >= v1 = v2, the corresponding swap candidate for w won't be considered. In the end, this means that none the swap candidates will be considered. In stead, the algorithm falls back everytime on bring_farthest_pair_together
.
该提问来源于开源项目：quantumlib/Cirq
 点赞
 写回答
 关注问题
 收藏
 复制链接分享
 邀请回答
5条回答

采纳
点赞 评论 复制链接分享

采纳
any opinion here?
点赞 评论 复制链接分享 
采纳
I didn't have a chance to use this code yet but having another option to tune the heuristic is something that I would definitely appreciate very much.
点赞 评论 复制链接分享 
采纳
Hi  are you planning to work on this still? In case yes, would you mind adding a parameter to tune the heuristic as suggested by and ? Also a test case covering it would be great.
点赞 评论 复制链接分享 
采纳
It seems like this has stalled out. I'm going to close, but if there is a desire to revive this, please reopen.
点赞 评论 复制链接分享
相关推荐
 4年前回答 1 已采纳 Problem Description An investor invests a certain percentage of his assets into NINSTRUMENTS financial instruments. After each term, these instruments deduct a certain fixed administrative cost, followed by a fee that is a percentage of the amount that was invested at the beginning of the term, and then add a return, which is a (positive or negative) percentage of the amount invested at the beginning of the term. If any account drops to zero or below after such a transaction, it is considered closed (no fees are charged against it, and is treated as simply zero) until a rebalancing occurs. Rebalancing occurs after every NREBALANCE terms, where the total assets of the investor are redistributed according to the original ratios for the instruments. Without rebalancing, the investor's assets would become dominated by the higher return instruments, which would expose them to more risk compared to a balanced investment plan. Note that it is possible that all instruments drop to zero, in which case they all remain closed for the remaining terms. You are to model the value of such an investment strategy and report the ending value in each instrument (before rebalancing, if it happens to land on a term when a rebalance is due). Compute your results using double precision (do not round intermediate values to pennies), but round your final answers to pennies. Input The first line of the input contains the three positive integers: NINSTRUMENTS NTERMS NREBALANCE There are no more than 10 instruments, and the number of terms is at most 20. This is followed by 3 lines of floatingpoint numbers separated by spaces, in the following format: FIXED_FEE(1) .. FIXED_FEE(NINSTRUMENTS) PERCENTAGE_FEE(1) .. PERCENTAGE_FEE(NINSTRUMENTS) PRINCIPAL_START(1) .. PRINCIPAL_START(NINSTRUMENTS) Finally, there are NTERMS lines each containing NINSTRUMENTS floatingpoint numbers indicating the percentage return of each instrument in each term: RETURN(1,1) .. RETURN(1,NINSTRUMENTS) RETURN(2,1) .. RETURN(2,NINSTRUMENTS) . . RETURN(NTERMS,1) .. RETURN(NTERMS,NINSTRUMENTS) All percentages (PERCENTAGE_FEE and RETURN) are given as ratios, up to 4 decimal places. For example, a fee of 0.0002 means 0.02% of the investment in this instrument is deducted as a fee each term. FIXED_FEE and PRINCIPAL_START are nonnegative floatingpoint numbers that are specified to 2 decimal places. At least one of the PRINCIPAL_START values is positive. Output Write on a single line the principal of each investment (separated by a space) at the end of NTERMS terms. Round each principal to the nearest penny. PRINCIPAL_END(1) .. PRINCIPAL_END(NINSTRUMENTS) Sample Input 4 10 5 5.00 10.00 20.00 50.00 0.002 0.001 0.0008 0.0005 150000.00 100000.00 75000.00 50000.00 0.10 0.05 0.05 0.85 0.10 0.05 0.10 0.85 0.10 0.05 0.20 0.85 0.10 0.05 0.40 0.85 0.10 0.05 0.80 0.85 0.10 0.05 0.05 0.90 0.10 0.05 0.05 0.90 0.10 0.05 0.05 0.90 0.10 0.05 0.05 0.85 0.10 0.05 0.05 0.85 Sample Output 237698.69 126086.01 57298.74 0.00
 4年前回答 2 已采纳 A student named Round Square loved to play with cones. He would arrange cones with different base radii arbitrarily on the floor and would admire the intrinsic beauty of the arrangement. The student even began theorizing about how some cones dominate other cones: a cone A dominates another cone B when cone B is completely within the cone A. Furthermore, he noted that there are some cones that not only dominate others, but are themselves dominated, thus creating complex domination relations. After studying the intricate relations of the cones in more depth, the student reached an important conclusion: there exist some cones, allpowerful cones, that have unique properties: an allpowerful cone is not dominated by any other cone. The student became so impressed by the mightiness of the allpowerful cones that he decided to worship these allpowerful cones. Unfortunately, after having arranged a huge number of cones and having worked hard on developing this grandiose cone theory, the student become quite confused with all these cones, and he now fears that he might worship the wrong cones (what if there is an evil cone that tries to trick the student into worshiping it?). You need to help this student by finding the cones he should worship. Input There are several test cases in the input. Each case specifies an arrangement of the cones. There are in total N cones (1 <= N <= 40000). Cone i has radius and height equal to Ri, i = 1 ... n. Each cone is hollow on the inside and has no base, so it can be placed over another cone with smaller radius. No two cones touch. The first line of each test case contains the integer N. The next N lines each contain three real numbers Ri, xi, yi separated by spaces, where (xi, yi) are the coordinates of the center of the base of cone i. Proceed until a case that N = 0. Output The first line of each test case should contain the number of cones that the student should worship. The second line contains the indices of the cones that the student should worship in increasing order. Two consecutive numbers should be separated by a single space. Sample Input 5 1 0 2 3 0 3 10 0 0 1 0 1.5 10 50 50 0 Sample Output 2 3 5
 4年前回答 2 已采纳 The mobile network market in country XYZ used to be dominated by two large corporations, XYZ Telecom and XYZ Mobile. The central government recently has realized that radio frequency spectrum is a scarce resource and wants to regulate its usage. The spectrum currently in use is divided into 300,000 channels. Any wireless service provider who wishes to use certain spectrum should apply for licenses on these channels. While some services may require use of multiple channels, a single channel can not be shared by different services. The central government wants to maximize its revenue from the spectrum by putting the channels up to an auction. The only two bidders are XYZ Telecom and XYZ Mobile. They are allowed to place bids on combinations of channels, through which their services can communicate with the customers. Furthermore, the government stipulates that a company can only place at most one bid on a specific channel. The government can only accept a subset of the bids so none of them would conflict with each other. However, officials soon find out that it is a difficult task to determine the winning bids in order to maximize the revenue, and they are asking for your help. Input Description Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 10) which is the number of test cases. T test cases follow, each preceded by a single blank line. Each test case has two bid description sections, which are for XYZ Telecom and XYZ Mobile, respectively. Each section starts with an integer N (1 <= N <= 3,000), which is the number of bids that follow. The next N lines each contain the description for one bid, the first integer P (1 <= P <= 1,000) gives the price of that bid, followed by the channel numbers required by this service. A service would require at least 1 channel and at most 32 channels. Each channel number is a positive integer and will never exceed 300,000. Output Description Results should be directed to standard output. Start each case with "Case #:" on a single line, where # is the case number starting from 1. Two consecutive cases should be separated by a single blank line. No blank line should be produced after the last test case. For each test case, print the maximized revenue the government is able to collect by issuing licenses on the channels. Sample Input 2 3 45 1 51 2 62 3 4 54 1 15 2 33 3 2 4 5 5 20 1 18 2 23 4 54 3 5 6 17 7 4 36 1 2 3 28 5 47 4 7 16 6 Sample Output Case 1: 169 Case 2: 139
 2年前沙漠糊涂的博客 In the same way that a child must be able to move his arms and legs before he can learn to walk, the child must physiologically be capable of producing and experiencing particular emotions b...
 weixin_33919950的博客 The reason why I talk about the transformation from electric power to computing power is that we can compute all the things that were not computed or deemed as computing objects in the past thanks to ...
 lmb633的博客 super(ConvBNReLU, self).__init__( nn.Conv2d(in_planes, out_planes, kernel_size, stride, padding, groups=groups, bias=False), nn.BatchNorm2d(out_planes, momentum=0.1), nn.ReLU(inplace=False) ) ...
 cumei1658的博客 At Dataquest, we strongly advocate portfolio projects as a means of getting a first data science ... In this blog post, we’ll walk you through an example portfolio project. This is the third project...
 1年前谷公子的博客 // // // Copyright 20072011 Mentor Graphics Corporation // Copyright 20072011 Cadence Design Systems, Inc. // Copy...
 穷源溯流的博客 Let's call an arrayttdominatedby valuevvin the next situation. At first, arrayttshould have at least22elements. Now, let's calculate number of occurrences of each ... Thenttis dominated (byvv)...
 weixin_39765588的博客 刷过了English Prepositions Explained的in部分，我大概说一下in的概念是这样的 o 也就是有一个东西被围在边界里面了，和into相比，更加强调状态而不是动作说一下几个困难的地方吧其中一种是in ...
 @范恒宾的博客 # # Note that in order to read the configuration file, Redis must be # started with the file path as first argument: # # ./redisserver /path/to/redis.conf # Note on units: when memory size is needed...
 weixin_33762130的博客 They dominated racing during that period because their cars turned better than the competition. Today, with a better understanding of Ackermann and the amounts needed by the cars, we can measure ...
 weixin_39585691的博客 IBL with Multiple Scattering implemented in Three.jsOnline demo & source code (Copy the link and open it in Chrome browser):https://codesandbox.io/s/multiplescatteringiblk4990试着写了英文版的，...
 chen_zan_yu_的博客 In the fourth test case, all subarrays of length more than one are dominated. 题意： 给出组数，问出现相同的两个数的最短距离，over~ #include <bits/stdc++.h> using ...
 皮卡丘的忧伤的博客 for tag in tags: print("tag:%s\t\t weight:%f"%(tag[0],tag[1])) 2.3.基于 TextRank 算法的关键词抽取 1.基本介绍： TextRank 算法是一种用于文本的基于图的排序算法，通过把文本分割成若干组成...
 10月前张博208的博客 This is used for situations where the model execution time is dominated by loading weights from memory rather than computing the matrix multiplications. This is true for for LSTM and Transformer type...
 汪湜的博客 2019年12月六级真题(第二套)阅读 Section B Twenty years ago, the Urban Land Institute defined the two types of cities that dominated the US landscape: smaller cities that operated around standard 95 ...
 culh2177的博客 They were masters of the vector game format and dominated the first arcades with classics such as Asteroids, Battle Zone, Lunar Lander, Gravitar, Tempest, and the stunning Star Wars. Unlike many of ...
 Noire02的博客 全部四级六级高考考研Where are you in the cycle of renewal: Are you actively preserving the present, or selectively forgetting the past, or boldly creating the future? What advice would Leah give you ...
 cumifi2519的博客 vue.js手册Get this post in PDF/ePub/MOBI format at vuehandbook.com 在vuehandbook.com上以PDF / ePub / MOBI格式获取此帖子 Vue is a very popular JavaScript frontend framework, one that’s experiencing a...