import time
from HumanTime import TimeAutoShort
'''Usage:
When creating a dadabase, simply call Frobenius(n) where n is the largest such d for
It will store one of four messages depending on 3 and 4 element reduction
If gcd(a,b,c,d) != 1, it will say all four elements share a common factor (there is no Frobenius number in this case)
If gcd(x,y,z) != 1 for and three x,y,z in {a,b,c,d} it will say three elements have a common factor and we know
has symmetry iff does
Otherwise, if is symmetric it will say True and False if its not'''
class Frobenius(object):
'''a Frobenius object used for research on Frobenius symmetry, specifically the symetry of attainables and unattainables
less than or equal to the Frobenius number it's main method allows for the checking of all sets of the form {a,b,c,d} where,
a, b, c, d < num with F.main(num) and num is some natural number such that F is a Frobeinius object
The constructor calls the main method for convenience and can easily be adjusted for command line use'''
def __init__(self, n, t = 1.5):
'''constructor for the Frobenius object. mode = N for normal mode with sets obaying three way reletive primality
or mode = PW for piecewise reletively prime sets only'''
self.fractions = [] # a list that will contain the ratio of attainables to total as floating point numbers
self.fractionsDict = {} # a dictionary whos keys are the contents of self.fractions and whos values are strings representing their corrisponding sets
self.itime = time.time(); self.progCounter = self.itime # two floats initialized to unix time in seconds for use in the progress method
self.valsList = []
self.data = dict()
self.main(n, t)
def main(self, n, t):
num = n + 1 # makes the sets include all values up to and including num
valsCovered = self.checkVals(n, t)
b = open(f'{n}quad.txt', 'w')
for key, value in self.data.items():
#if value in [True, False]:
b.write(f'{key[0]}\n{key[1]}\n{key[2]}\n{key[3]}\n{value}\n\n')
b.close()
def checkVals(self, n, inc = 1):
'''checkVals acts as an iterator of sorts going though each value for a, b, c, and d between xmin and xmax for x in [a, b, c, d]'
totalVals is calculated using the formula for the tetrahedral (or triangular pyramidal) numbers shifted two
this is only accurate because a** y:
smaller = y
else:
smaller = x
for i in range(1, smaller+1):
if((x % i == 0) and (y % i == 0)):
hcf = i
return hcf
def progress(self, valsCovered, totalVals, inc):
'displays to the screen both the percentage of completion and the execution time formatted with TimeAutoShort from a module i created'
if self.progCounter < time.time() - inc:
self.progCounter = time.time()
print(f'{valsCovered*100/float(totalVals):.4f} % {TimeAutoShort(time.time() - self.itime, 2)}')
R = Frobenius(180)
#for val in range(10, 110, 10):
# Frobenius(val)
**