Files
lr_miad_nn/generate_excel.rb
Dmitry 422cb49b31 Add initial implementation of Hopfield and Hamming networks with web interface
- Create Dockerfile and entrypoint script for application setup
- Implement pattern loading from Excel and weight caching
- Develop core functions for Hopfield and Hamming networks
- Add Sinatra web server for user interaction
- Create HTML interface for displaying patterns and results
- Include necessary gems in Gemfile and lockfile
- Add .dockerignore and .gitignore files
2026-05-16 22:13:26 +03:00

59 lines
1.4 KiB
Ruby

require 'rubyXL'
require 'rubyXL/convenience_methods'
PATTERNS = {
'T' => [
[ 1, 1, 1, 1, 1, 1, 1, 1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1]
],
'H' => [
[ 1,-1,-1,-1,-1,-1,-1, 1],
[ 1,-1,-1,-1,-1,-1,-1, 1],
[ 1,-1,-1,-1,-1,-1,-1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1],
[ 1,-1,-1,-1,-1,-1,-1, 1],
[ 1,-1,-1,-1,-1,-1,-1, 1],
[ 1,-1,-1,-1,-1,-1,-1, 1]
],
'E' => [
[ 1, 1, 1, 1, 1, 1, 1, 1],
[ 1,-1,-1,-1,-1,-1,-1,-1],
[ 1,-1,-1,-1,-1,-1,-1,-1],
[ 1, 1, 1, 1, 1, 1,-1,-1],
[ 1, 1, 1, 1, 1, 1,-1,-1],
[ 1,-1,-1,-1,-1,-1,-1,-1],
[ 1,-1,-1,-1,-1,-1,-1,-1],
[ 1, 1, 1, 1, 1, 1, 1, 1]
],
'X' => [
[ 1,-1,-1,-1,-1,-1,-1, 1],
[-1, 1,-1,-1,-1,-1, 1,-1],
[-1,-1, 1,-1,-1, 1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1,-1, 1, 1,-1,-1,-1],
[-1,-1, 1,-1,-1, 1,-1,-1],
[-1, 1,-1,-1,-1,-1, 1,-1],
[ 1,-1,-1,-1,-1,-1,-1, 1]
]
}
wb = RubyXL::Workbook.new
wb.worksheets.delete_at(0)
PATTERNS.each do |name, matrix|
sheet = wb.add_worksheet(name)
matrix.each_with_index do |row, r|
row.each_with_index do |val, c|
sheet.add_cell(r, c, val == 1 ? 'x' : nil)
end
end
end
wb.write('patterns.xlsx')
puts "Создан patterns.xlsx (листы: #{PATTERNS.keys.join(', ')})"