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
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
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(', ')})"
|
||||
Reference in New Issue
Block a user