<commit_before>#!/usr/bin/env ruby

require_relative '../lib/rams'

# 0 indicates a cell value is not given
problem = [
    [0, 0, 0,   6, 9, 2,   0, 4, 0],
    [7, 0, 0,   0, 0, 0,   8, 9, 0],
    [0, 0, 0,   0, 0, 0,   0, 0, 6],

    [0, 0, 9,   0, 1, 7,   0, 0, 3],
    [0, 0, 7,   0, 8, 0,   5, 0, 0],
    [8, 0, 0,   4, 6, 0,   1, 0, 0],

    [5, 0, 0,   0, 0, 0,   0, 0, 0],
    [0, 8, 6,   0, 0, 0,   0, 0, 1],
    [0, 3, 0,   7, 2, 8,   0, 0, 0]
]

# Indexes for creating variables and constraints
rows = (0..(problem.size - 1)).to_a
cols = rows
vals = (1..9).to_a
groups = [0, 3, 6]

# 9x9x9 structure for storing all binary variables
# If x[[i, j, k]] == 1, then problem[i][j] == k.
m = RAMS::Model.new
x = rows.map do |r|
  cols.map do |c|
    vals.map do |v|
      low = problem[c][r] == v ? 1 : 0
      [[r, c, v], m.variable(type: :binary, low: low)]
    end<commit_msg>Correcting row column order<commit_after>#!/usr/bin/env ruby

require_relative '../lib/rams'

# 0 indicates a cell value is not given
problem = [
    [0, 0, 0,   6, 9, 2,   0, 4, 0],
    [7, 0, 0,   0, 0, 0,   8, 9, 0],
    [0, 0, 0,   0, 0, 0,   0, 0, 6],

    [0, 0, 9,   0, 1, 7,   0, 0, 3],
    [0, 0, 7,   0, 8, 0,   5, 0, 0],
    [8, 0, 0,   4, 6, 0,   1, 0, 0],

    [5, 0, 0,   0, 0, 0,   0, 0, 0],
    [0, 8, 6,   0, 0, 0,   0, 0, 1],
    [0, 3, 0,   7, 2, 8,   0, 0, 0]
]

# Indexes for creating variables and constraints
rows = (0..(problem.size - 1)).to_a
cols = rows
vals = (1..9).to_a
groups = [0, 3, 6]

# 9x9x9 structure for storing all binary variables
# If x[[r, c, v]] == 1, then problem[r][c] == k.
m = RAMS::Model.new
x = rows.map do |r|
  cols.map do |c|
    vals.map do |v|
      low = problem[c][r] == v ? 1 : 0
      [[r, c, v], m.variable(type: :binary, low: low)]
    end
{'fraction_non_alphanumeric': 0.21773288439955107, 'fraction_numerical': 0.10662177328843996, 'mean_word_length': 2.0426621160409555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1310561', 'n_tokens_mistral': 984, 'n_tokens_neox': 838, 'n_words': 304}