#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 17 14:25:17 2017

@author: hollymandel
"""

from sympy import *
import numpy as np
np.set_printoptions(threshold=1000000000)
import math as math
from IPython import embed
import symbolic_poset_functions

tableauIn = [1,1,1,1,2,2,2,2,3,2,2,2,2,1,1,1,1]
maxRank = len(tableauIn)-1
#fullContentOrbits = [
#        [17,1,1],
#        [18,2,1],
#        [18,18,2],
#        [19,19,30],
#        [20,20,228],
#        [21,7,3],
#        [21,21,1044],
#        [22,22,3053],
#        [22,66,2],
#        [23,23,5813],
#        [23,69,13],
#        [24,8,7],
#        [24,24,7195],
#        [24,48,4],
#        [24,72,26],
#        [25,25,5602],
#        [25,50,8],
#        [25,75,21],
#        [26,2,2],
#        [26,26,2495],
#        [26,52,4],
#        [26,78,6],
#        [27,3,2],
#        [27,9,4],
#        [27,27,484]]
fullContentOrbits = [
        [17,1,1],
        [18,2,1],
        [18,18,2],
        [19,19,30],
        [20,20,228],
        [21,7,3],
        [21,21,1044],
        [22,22,3053],
        [22,66,2],
        [23,23,5813],
        [23,69,13],
        [24,8,7],
        [24,24,7195],
        [24,48,4],
        [24,72,26]]

dList = [1,3]
tabPredictions = np.zeros(len(dList))
rsPredictions = np.zeros(len(dList))


numOrbits = len(fullContentOrbits)
orbRatios = np.zeros(numOrbits)
for k in range(0,numOrbits):
    orbRatios[k] = fullContentOrbits[k][1]/fullContentOrbits[k][0]
truePeriodRatio = int(max(orbRatios))            
m = Symbol('m',int=True)
M = 24
truePeriod = M * truePeriodRatio

for j in range(0,len(dList)):
    d = dList[j]
    for k in range(0,numOrbits):
        getNt = fullContentOrbits[k][0]
        getTau = fullContentOrbits[k][1]
        getN = fullContentOrbits[k][2]
        dCheck = 0
        if int(np.ceil(getNt/getTau)) % truePeriodRatio == 0:
            if int(np.ceil(getNt/getTau)) % (truePeriodRatio*d) == 0:
                dCheck = 1
        else:
            if int(np.ceil(getNt/getTau)) % d == 0:
                dCheck = 1
        
        if dCheck == 1:
            if d == 3:
                print(getNt)
                print(getTau)
            tabPredictions[j] += getTau * getN * int(binomial(M/d,getNt/d))
            
    [a,b,getRushShiPeriod] = symbolic_poset_functions.rushShiSymbolic(d,tableauIn)
    rsPeriod = sympify(getRushShiPeriod)
    rsPeriod = rsPeriod.subs(m,M-17)
    rsPredictions[j] = rsPeriod

print(tabPredictions)
print(rsPredictions)

