mopti 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2004be9554ae15d2abbd7a9f5cdf7e0b7583cb725c0d3b40ffc50b1b92636961
4
- data.tar.gz: ccbe1ce7c56ecabb25ce491e91075ba83c4ab9379faca954eb9315cab5c4b05c
3
+ metadata.gz: 00c061fd0bbe6751f39dbc139de732990c02915c650b5c25cafb1469162372b3
4
+ data.tar.gz: c8df3190b009acc36393615791e0baa1045ccc026f3c3c61444b0f96f4afe7ac
5
5
  SHA512:
6
- metadata.gz: 7f35b91e05fbe5d459078de1bb7e1fb662e8328c835f62f5eced2f03dccbb58b5c702987df24471cc9c4a4c18c2325904bbee0b7a5ee280591c1ec0305c4762d
7
- data.tar.gz: b09f2757113dedfd7ad4c7634a87b1fcc42aaf96139d40080e500ff32a73b35d34fc5b21457e412884d3f25bcaf1ab73065a1dcabf89b752d6a4a0fb17ecf56c
6
+ metadata.gz: 5d27e97704610889a028b98541a282292cdea04313b37346af32ecc6732c5d947ee169f558679ab1048f5d4176b34c25d3f0aa7f497c9a0e212252b16863920c
7
+ data.tar.gz: 14808c545bba9ce60ee1fd0825391ef7cd280fe1a6a4d2afd7de02be101faaa45a7a457d487ff47597e9350e5cb6daef80a6c80330889678f700d14e90a85eea
@@ -6,17 +6,15 @@ jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
+ fail-fast: false
9
10
  matrix:
10
- ruby: [ '2.6', '2.7', '3.0' ]
11
+ ruby: [ '2.7', '3.0', '3.1' ]
11
12
  steps:
12
- - uses: actions/checkout@v2
13
- - name: Set up Ruby
13
+ - uses: actions/checkout@v3
14
+ - name: Set up Ruby ${{ matrix.ruby }}
14
15
  uses: ruby/setup-ruby@v1
15
16
  with:
16
17
  ruby-version: ${{ matrix.ruby }}
17
18
  bundler-cache: true
18
19
  - name: Build and test with Rake
19
- run: |
20
- gem install bundler
21
- bundle install --jobs 4 --retry 3
22
- bundle exec rake
20
+ run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,13 +1,24 @@
1
1
  require:
2
2
  - rubocop-performance
3
+ - rubocop-rake
3
4
  - rubocop-rspec
4
5
 
5
6
  AllCops:
6
7
  NewCops: enable
8
+ DisplayCopNames: true
9
+ DisplayStyleGuide: true
10
+ Exclude:
11
+ - 'ext/**/*'
12
+ - 'tmp/**/*'
13
+ - 'vendor/**/*'
14
+ - 'Steepfile'
15
+
16
+ Gemspec/RequiredRubyVersion:
17
+ Enabled: false
7
18
 
8
19
  Layout/LineLength:
9
20
  Max: 145
10
- IgnoredPatterns: ['(\A|\s)#']
21
+ AllowedPatterns: ['(\A|\s)#']
11
22
 
12
23
  Metrics/ModuleLength:
13
24
  Max: 200
@@ -37,3 +48,9 @@ Metrics/ParameterLists:
37
48
 
38
49
  Naming/MethodParameterName:
39
50
  Enabled: false
51
+
52
+ Style/SlicingWithRange:
53
+ Enabled: false
54
+
55
+ RSpec/MultipleMemoizedHelpers:
56
+ Max: 12
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.2.3
2
+ - Refactor codes and configs with RuboCop.
3
+
1
4
  # 0.2.2
2
5
  - Remove dependent gem's type declaration file from installation files.
3
6
 
data/Gemfile CHANGED
@@ -1,9 +1,15 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in mopti.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem "rbs", "~> 1.2"
9
- gem "steep", "~> 0.44"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rbs', '~> 1.2'
10
+ gem 'rspec', '~> 3.0'
11
+ gem 'rubocop', '~> 1.33'
12
+ gem 'rubocop-performance', '~> 1.14'
13
+ gem 'rubocop-rake', '~> 0.6.0'
14
+ gem 'rubocop-rspec', '~> 2.12'
15
+ gem 'steep', '~> 0.44'
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020-2021 Atsushi Tatsuma
1
+ Copyright (c) 2020-2022 Atsushi Tatsuma
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ![Ruby](https://github.com/yoshoku/mopti/workflows/Ruby/badge.svg)
4
4
  [![Gem Version](https://badge.fury.io/rb/mopti.svg)](https://badge.fury.io/rb/mopti)
5
5
  [![BSD 3-Clause License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://github.com/yoshoku/mopti/blob/main/LICENSE.txt)
6
- [![Documentation](http://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/mopti/doc/)
6
+ [![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/mopti/doc/)
7
7
 
8
8
  Mopti is a multivariate optimization library in Ruby.
9
9
  Mopti supports Nelder-Mead simplex method and Scaled Conjugate Gradient.
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[rubocop spec]
@@ -61,7 +61,7 @@ module Mopti
61
61
 
62
62
  x = @x_init.dup
63
63
  n = x.size
64
- max_iter = @max_iter || 200 * n
64
+ max_iter = @max_iter || (200 * n)
65
65
 
66
66
  alpha = 1.0
67
67
  beta = n > 1 ? 1 + 2.fdiv(n) : 2.0
@@ -90,13 +90,13 @@ module Mopti
90
90
  break if ((sim[1..-1, true] - sim[0, true]).abs.flatten.max <= @xtol) && ((fsim[0] - fsim[1..-1]).abs.max <= @ftol)
91
91
 
92
92
  xbar = sim[0...-1, true].sum(0) / n
93
- xr = xbar + alpha * (xbar - sim[-1, true])
93
+ xr = xbar + (alpha * (xbar - sim[-1, true]))
94
94
  fr = func(xr, @args)
95
95
  n_fev += 1
96
96
 
97
97
  shrink = true
98
98
  if fr < fsim[0]
99
- xe = xbar + beta * (xr - xbar)
99
+ xe = xbar + (beta * (xr - xbar))
100
100
  fe = func(xe, @args)
101
101
  n_fev += 1
102
102
  shrink = false
@@ -112,7 +112,7 @@ module Mopti
112
112
  sim[-1, true] = xr
113
113
  fsim[-1] = fr
114
114
  elsif fr < fsim[-1]
115
- xoc = xbar + gamma * (xr - xbar)
115
+ xoc = xbar + (gamma * (xr - xbar))
116
116
  foc = func(xoc, @args)
117
117
  n_fev += 1
118
118
  if foc <= fr
@@ -121,7 +121,7 @@ module Mopti
121
121
  fsim[-1] = foc
122
122
  end
123
123
  else
124
- xic = xbar - gamma * (xr - xbar)
124
+ xic = xbar - (gamma * (xr - xbar))
125
125
  fic = func(xic, @args)
126
126
  n_fev += 1
127
127
  if fic < fsim[-1]
@@ -133,7 +133,7 @@ module Mopti
133
133
 
134
134
  if shrink
135
135
  (1..n).to_a.each do |j|
136
- sim[j, true] = sim[0, true] + delta * (sim[j, true] - sim[0, true])
136
+ sim[j, true] = sim[0, true] + (delta * (sim[j, true] - sim[0, true]))
137
137
  fsim[j] = func(sim[j, true], @args)
138
138
  n_fev += 1
139
139
  end
@@ -108,13 +108,13 @@ module Mopti
108
108
  break if kappa < 1e-16
109
109
 
110
110
  sigma = SIGMA_INIT / Math.sqrt(kappa)
111
- x_plus = x + sigma * d
111
+ x_plus = x + (sigma * d)
112
112
  j_plus = jacb(x_plus, @args)
113
113
  n_jev += 1
114
114
  theta = d.dot(j_plus - j_next) / sigma
115
115
  end
116
116
 
117
- delta = theta + beta * kappa
117
+ delta = theta + (beta * kappa)
118
118
  if delta <= 0
119
119
  delta = beta * kappa
120
120
  # TODO: Investigate the cause of the type error.
@@ -124,7 +124,7 @@ module Mopti
124
124
  end
125
125
  alpha = -mu / delta
126
126
 
127
- x_next = x + alpha * d
127
+ x_next = x + (alpha * d)
128
128
  f_next = func(x_next, @args)
129
129
  n_fev += 1
130
130
 
@@ -165,7 +165,7 @@ module Mopti
165
165
  n_successes = 0
166
166
  elsif success
167
167
  gamma = (j_prev - j_next).dot(j_next) / mu
168
- d = -j_next + gamma * d
168
+ d = -j_next + (gamma * d)
169
169
  end
170
170
  end
171
171
  end
data/lib/mopti/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mopti
4
4
  # The version of Mopti you are using.
5
- VERSION = '0.2.2'
5
+ VERSION = '0.2.3'
6
6
  end
data/mopti.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/mopti/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -18,6 +20,7 @@ Gem::Specification.new do |spec|
18
20
  spec.metadata['source_code_uri'] = 'https://github.com/yoshoku/mopti'
19
21
  spec.metadata['changelog_uri'] = 'https://github.com/yoshoku/mopti/blob/master/CHANGELOG.md'
20
22
  spec.metadata['documentation_url'] = 'https://yoshoku.github.io/mopti/doc/'
23
+ spec.metadata['rubygems_mfa_required'] = 'true'
21
24
 
22
25
  # Specify which files should be added to the gem when it is released.
23
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mopti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-10 00:00:00.000000000 Z
11
+ date: 2022-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -60,7 +60,8 @@ metadata:
60
60
  source_code_uri: https://github.com/yoshoku/mopti
61
61
  changelog_uri: https://github.com/yoshoku/mopti/blob/master/CHANGELOG.md
62
62
  documentation_url: https://yoshoku.github.io/mopti/doc/
63
- post_install_message:
63
+ rubygems_mfa_required: 'true'
64
+ post_install_message:
64
65
  rdoc_options: []
65
66
  require_paths:
66
67
  - lib
@@ -75,8 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
- rubygems_version: 3.2.21
79
- signing_key:
79
+ rubygems_version: 3.2.33
80
+ signing_key:
80
81
  specification_version: 4
81
82
  summary: Multivariate Optimization Library in Ruby.
82
83
  test_files: []