You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

python_code.py 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. elif opt_name == 'random-inits':
  2. try:
  3. num_random_inits_ = std::stoul(opt_val)
  4. desired_num_random_inits_ = num_random_inits_
  5. except:
  6. raise Error('Invalid argument "' + opt_val + '" for option random-inits. Usage: options = "[--random-inits <convertible to int greater 0>]"')
  7. if num_random_inits_ <= 0:
  8. raise Error('Invalid argument "' + opt_val + '" for option random-inits. Usage: options = "[--random-inits <convertible to int greater 0>]"')
  9. }
  10. elif opt_name == 'randomness':
  11. if opt_val == 'PSEUDO':
  12. use_real_randomness_ = False
  13. elif opt_val == 'REAL':
  14. use_real_randomness_ = True
  15. else:
  16. raise Error('Invalid argument "' + opt_val + '" for option randomness. Usage: options = "[--randomness REAL|PSEUDO] [...]"')
  17. }
  18. elif opt_name == 'stdout':
  19. if opt_val == '0':
  20. print_to_stdout_ = 0
  21. elif opt_val == '1':
  22. print_to_stdout_ = 1
  23. elif opt_val == '2':
  24. print_to_stdout_ = 2
  25. else:
  26. raise Error('Invalid argument "' + opt_val + '" for option stdout. Usage: options = "[--stdout 0|1|2] [...]"')
  27. }
  28. elif opt_name == 'refine':
  29. if opt_val == 'TRUE':
  30. refine_ = True
  31. elif opt_val == 'FALSE':
  32. refine_ = False
  33. else:
  34. raise Error('Invalid argument "' + opt_val + '" for option refine. Usage: options = "[--refine TRUE|FALSE] [...]"')
  35. }
  36. elif opt_name == 'time-limit':
  37. try:
  38. time_limit_in_sec_ = std::stod(opt_val)
  39. except:
  40. raise Error('Invalid argument "' + opt_val + '" for option time-limit. Usage: options = "[--time-limit <convertible to double>] [...]')
  41. }
  42. elif opt_name == 'max-itrs':
  43. try:
  44. max_itrs_ = std::stoi(opt_val)
  45. except:
  46. raise Error('Invalid argument "' + opt_val + '" for option max-itrs. Usage: options = "[--max-itrs <convertible to int>] [...]')
  47. }
  48. elif opt_name == 'max-itrs-without-update':
  49. try:
  50. max_itrs_without_update_ = std::stoi(opt_val)
  51. except:
  52. raise Error('Invalid argument "' + opt_val + '" for option max-itrs-without-update. Usage: options = "[--max-itrs-without-update <convertible to int>] [...]')
  53. }
  54. elif opt_name == 'seed':
  55. try:
  56. seed_ = std::stoul(opt_val)
  57. except:
  58. raise Error('Invalid argument "' + opt_val + '" for option seed. Usage: options = "[--seed <convertible to int greater equal 0>] [...]')
  59. }
  60. elif opt_name == 'epsilon':
  61. try:
  62. epsilon_ = std::stod(opt_val)
  63. except:
  64. raise Error('Invalid argument "' + opt_val + '" for option epsilon. Usage: options = "[--epsilon <convertible to double greater 0>] [...]')
  65. if epsilon_ <= 0:
  66. raise Error('Invalid argument "' + opt_val + '" for option epsilon. Usage: options = "[--epsilon <convertible to double greater 0>] [...]')
  67. }
  68. elif opt_name == 'inits-increase-order':
  69. try:
  70. num_inits_increase_order_ = std::stoul(opt_val)
  71. except:
  72. raise Error('Invalid argument "' + opt_val + '" for option inits-increase-order. Usage: options = "[--inits-increase-order <convertible to int greater 0>]"')
  73. if num_inits_increase_order_ <= 0:
  74. raise Error('Invalid argument "' + opt_val + '" for option inits-increase-order. Usage: options = "[--inits-increase-order <convertible to int greater 0>]"')
  75. }
  76. elif opt_name == 'init-type-increase-order':
  77. init_type_increase_order_ = opt_val
  78. if opt_val != 'CLUSTERS' and opt_val != 'K-MEANS++':
  79. raise Exception(std::string('Invalid argument ') + opt_val + ' for option init-type-increase-order. Usage: options = "[--init-type-increase-order CLUSTERS|K-MEANS++] [...]"')
  80. }
  81. elif opt_name == 'max-itrs-increase-order':
  82. try:
  83. max_itrs_increase_order_ = std::stoi(opt_val)
  84. except:
  85. raise Error('Invalid argument "' + opt_val + '" for option max-itrs-increase-order. Usage: options = "[--max-itrs-increase-order <convertible to int>] [...]')
  86. }
  87. else:
  88. std::string valid_options('[--init-type <arg>] [--random-inits <arg>] [--randomness <arg>] [--seed <arg>] [--stdout <arg>] ')
  89. valid_options += '[--time-limit <arg>] [--max-itrs <arg>] [--epsilon <arg>] '
  90. valid_options += '[--inits-increase-order <arg>] [--init-type-increase-order <arg>] [--max-itrs-increase-order <arg>]'
  91. raise Error(std::string('Invalid option "') + opt_name + '". Usage: options = "' + valid_options + '"')

A Python package for graph kernels, graph edit distances and graph pre-image problem.