sports-manager 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c758d344e9f382f5f1490e5a561b9985bac567cab55277644a0ae48374150f43
4
- data.tar.gz: 1e8f37239ca689cb3103112a868ec9add0e1b7e95f7fb14a291a80a70b2e856d
3
+ metadata.gz: b731114e4613bcf2ba9f6f094379b2a96d8f14cadcd960e3b2c431abcacb5fbe
4
+ data.tar.gz: 5855311009ef5e3515ed7e8dc1eec7a0230dba4286eeeafbd21aac4a9a94dd58
5
5
  SHA512:
6
- metadata.gz: 2d27aa5f4eb1b3ca85708b9f15139a73e31c5fabd35a47396caf7a59c51cfd0f04bb948d86f7cd57aa70de9436634f091472d75b6354b7e4946b895b4d980458
7
- data.tar.gz: 742a411241704d99cbe9b4d6410ccf5a4d5dbb829a96210eac778dc9105ba31c0e1adafbe6308d05e257f50fef2ee0c4fccd5d0db222ec4fb43ead9545f87778
6
+ metadata.gz: 5f28109152d33f3261bad872f0692abd4c12211ccfed951f6398e6cf2d42856b6e10a6f0805e90918871b78e0f61ffd74b00bccaa77c56abff96ad280a3d63f1
7
+ data.tar.gz: 9c5dbc73ea1cb60a4861f1c7a4e3fb5eeb3415675b2f7d2e9e0babfa410534bab7ea545837e292c4c7f7a8182a8231741f35095c67e20a725721f229bc1c4b21
data/README.md CHANGED
@@ -16,6 +16,11 @@ You can install using the following command:
16
16
  gem install "sports-manager"
17
17
  ```
18
18
 
19
+ Or add the following line to your Gemfile:
20
+ ```bash
21
+ gem "sports-manager"
22
+ ```
23
+
19
24
  Then install it:
20
25
 
21
26
  ```bash
@@ -8,7 +8,9 @@ module SportsManager
8
8
  attr_reader :matches
9
9
 
10
10
  def self.for_tournament(tournament:, csp:)
11
- csp.add_constraint(new(tournament.matches.values.flatten))
11
+ matches = tournament.matches.values.flatten
12
+
13
+ csp.add_constraint(new(matches))
12
14
  end
13
15
 
14
16
  def initialize(matches)
@@ -10,9 +10,11 @@ module SportsManager
10
10
  def self.for_tournament(tournament:, csp:)
11
11
  tournament.matches.each do |(_category, matches)|
12
12
  matches.select(&:previous_matches?).each do |match|
13
- csp.add_constraint(
14
- new(target_match: match, matches: match.previous_matches)
15
- )
13
+ match.previous_matches.each do |previous_match|
14
+ csp.add_constraint(
15
+ new(target_match: match, matches: [previous_match])
16
+ )
17
+ end
16
18
  end
17
19
  end
18
20
  end
@@ -7,19 +7,22 @@ module SportsManager
7
7
  :match_time, :break_time, :minimum_match_gap
8
8
 
9
9
  MINUTE = 60
10
+ IN_PAIRS = 2
10
11
 
11
12
  def self.for_tournament(tournament:, csp:)
12
13
  tournament.multi_tournament_participants.each do |participant|
13
14
  matches = tournament.find_participant_matches(participant)
14
15
 
15
- constraint = new(
16
- target_participant: participant,
17
- matches: matches,
18
- match_time: tournament.match_time,
19
- break_time: tournament.break_time
20
- )
16
+ matches.combination(IN_PAIRS) do |match1, match2|
17
+ constraint = new(
18
+ target_participant: participant,
19
+ matches: [match1, match2],
20
+ match_time: tournament.match_time,
21
+ break_time: tournament.break_time
22
+ )
21
23
 
22
- csp.add_constraint(constraint)
24
+ csp.add_constraint(constraint)
25
+ end
23
26
  end
24
27
  end
25
28
 
@@ -13,12 +13,14 @@ module SportsManager
13
13
  .matches.values.flatten
14
14
  .select(&:previous_matches?)
15
15
  .each do |match|
16
- csp.add_constraint new(
17
- target_match: match,
18
- matches: match.previous_matches,
19
- match_time: tournament.match_time,
20
- break_time: tournament.break_time
21
- )
16
+ match.previous_matches.each do |previous_match|
17
+ csp.add_constraint new(
18
+ target_match: match,
19
+ matches: [previous_match],
20
+ match_time: tournament.match_time,
21
+ break_time: tournament.break_time
22
+ )
23
+ end
22
24
  end
23
25
  end
24
26
 
@@ -5,13 +5,17 @@ module SportsManager
5
5
  class NoOverlappingConstraint < ::CSP::Constraint
6
6
  attr_reader :matches, :match_time
7
7
 
8
+ IN_PAIRS = 2
9
+
8
10
  def self.for_tournament(tournament:, csp:)
9
- csp.add_constraint(
10
- new(
11
- matches: tournament.matches.values.flatten,
12
- match_time: tournament.match_time
11
+ matches = tournament.matches.values.flatten
12
+ match_time = tournament.match_time
13
+
14
+ matches.combination(IN_PAIRS) do |match1, match2|
15
+ csp.add_constraint(
16
+ new(matches: [match1, match2], match_time: match_time)
13
17
  )
14
- )
18
+ end
15
19
  end
16
20
 
17
21
  def initialize(matches:, match_time:)
@@ -22,7 +22,7 @@ module SportsManager
22
22
  extend Forwardable
23
23
 
24
24
  attr_reader :format, :tournament, :variables, :domains,
25
- :ordering, :filtering, :csp
25
+ :ordering, :filtering, :lookahead, :csp
26
26
 
27
27
  attr_accessor :days, :subscriptions, :matches, :courts, :game_length, :rest_break, :single_day_matches,
28
28
  :tournament_type
@@ -50,6 +50,7 @@ module SportsManager
50
50
  @matches = {}
51
51
  @ordering = Algorithms::Ordering::MultipleMatchesParticipant
52
52
  @filtering = Algorithms::Filtering::NoOverlap
53
+ @lookahead = CSP::Algorithms::Lookahead::Ac3
53
54
  end
54
55
 
55
56
  def add_day(day, start, finish)
@@ -153,6 +154,7 @@ module SportsManager
153
154
  .add_domains(domains)
154
155
  .add_ordering(ordering)
155
156
  .add_filtering(filtering)
157
+ .add_lookahead(lookahead)
156
158
  .add_constraint(Constraints::AllDifferentConstraint)
157
159
  .add_constraint(Constraints::NoOverlappingConstraint)
158
160
  .add_constraint(Constraints::MatchConstraint)
@@ -20,7 +20,8 @@ module SportsManager
20
20
  # csp = builder.build
21
21
  class TournamentProblemBuilder
22
22
  attr_reader :variables, :domains, :constraints, :max_solutions,
23
- :filtering_algorithm, :ordering_algorithm, :tournament
23
+ :filtering_algorithm, :ordering_algorithm, :lookahead_algorithm,
24
+ :tournament
24
25
 
25
26
  MINIMUM_SOLUTIONS = 1
26
27
 
@@ -31,6 +32,7 @@ module SportsManager
31
32
 
32
33
  @filtering_algorithm = nil
33
34
  @ordering_algorithm = nil
35
+ @lookahead_algorithm = nil
34
36
 
35
37
  @max_solutions = MINIMUM_SOLUTIONS
36
38
 
@@ -61,6 +63,12 @@ module SportsManager
61
63
  self
62
64
  end
63
65
 
66
+ def add_lookahead(lookahead_algorithm_class)
67
+ @lookahead_algorithm = lookahead_algorithm_class
68
+
69
+ self
70
+ end
71
+
64
72
  # TODO: change to pass symbol instead of class?
65
73
  def add_constraint(constraint_class)
66
74
  @constraints |= Utils::Array.wrap(constraint_class)
@@ -79,8 +87,11 @@ module SportsManager
79
87
  variables.each do |variable|
80
88
  problem.add_variable(variable, domains: domains[variable])
81
89
  end
82
- problem.add_ordering ordering(problem)
83
- problem.add_filtering filtering(problem)
90
+
91
+ problem.add_ordering(ordering(problem))
92
+ problem.add_filtering(filtering(problem))
93
+ problem.add_lookahead(lookahead(problem))
94
+
84
95
  build_constraint(problem)
85
96
  end
86
97
  end
@@ -92,13 +103,23 @@ module SportsManager
92
103
  end
93
104
 
94
105
  def ordering(problem)
106
+ return if ordering_algorithm.nil?
107
+
95
108
  ordering_algorithm.for(problem: problem, dependency: tournament)
96
109
  end
97
110
 
98
111
  def filtering(problem)
112
+ return if filtering_algorithm.nil?
113
+
99
114
  filtering_algorithm.for(problem: problem, dependency: tournament)
100
115
  end
101
116
 
117
+ def lookahead(problem)
118
+ return if lookahead_algorithm.nil?
119
+
120
+ lookahead_algorithm.new(problem)
121
+ end
122
+
102
123
  def build_constraint(csp)
103
124
  ConstraintBuilder.build(tournament: tournament, csp: csp, constraints: constraints)
104
125
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SportsManager
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.files = Dir.chdir(__dir__) do
22
22
  `git ls-files -z`.split("\x0").reject do |f|
23
23
  (File.expand_path(f) == __FILE__) ||
24
- f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
24
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile .rspec .rubocop])
25
25
  end
26
26
  end
27
27
  spec.bindir = 'exe'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sports-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Benjamim
8
8
  - Gustavo Alberto
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-07-16 00:00:00.000000000 Z
12
+ date: 2024-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: csp-resolver
@@ -33,8 +33,6 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
- - ".rspec"
37
- - ".rubocop.yml"
38
36
  - CODE_OF_CONDUCT.md
39
37
  - CONTRIBUTING.md
40
38
  - MIT-LICENSE
@@ -98,7 +96,7 @@ licenses: []
98
96
  metadata:
99
97
  homepage_uri: https://github.com/Rebase-BR/sports-manager
100
98
  source_code_uri: https://github.com/Rebase-BR/sports-manager
101
- post_install_message:
99
+ post_install_message:
102
100
  rdoc_options: []
103
101
  require_paths:
104
102
  - lib
@@ -113,8 +111,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  - !ruby/object:Gem::Version
114
112
  version: '0'
115
113
  requirements: []
116
- rubygems_version: 3.0.8
117
- signing_key:
114
+ rubyforge_project:
115
+ rubygems_version: 2.7.6.2
116
+ signing_key:
118
117
  specification_version: 4
119
118
  summary: A Ruby tournament schedule generator tool.
120
119
  test_files: []
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,32 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.5
3
- NewCops: enable
4
- SuggestExtensions: false
5
- Metrics/BlockLength:
6
- Exclude:
7
- - spec/**/*.rb
8
- Metrics/ClassLength:
9
- Max: 200
10
- Metrics/MethodLength:
11
- Max: 20
12
- Layout/FirstArrayElementIndentation:
13
- EnforcedStyle: consistent
14
- Layout/FirstHashElementIndentation:
15
- EnforcedStyle: consistent
16
- Layout/HashAlignment:
17
- EnforcedLastArgumentHashStyle: always_inspect
18
- Layout/MultilineMethodCallIndentation:
19
- EnforcedStyle: indented
20
- Style/Documentation:
21
- Enabled: false
22
- Layout/EndAlignment:
23
- EnforcedStyleAlignWith: variable
24
- Style/ObjectThen:
25
- EnforcedStyle: yield_self
26
- Naming/FileName:
27
- Exclude:
28
- - 'lib/sports-manager.rb'
29
- Style/OpenStructUse:
30
- Enabled: false
31
- Gemspec/RequireMFA:
32
- Enabled: false