def f_main(): # just функция с лестницей Ламерея r = 2 x_start = 1.2 count = 100 start = 0 end = 2 delta = 0.0001 func = get_ricker_function(r) #func = get_ricker_composition(r) xl, yl = get_ladder(x_start, func, count) xl = xl[1:] yl = yl[1:] xpath = 'files/xlad.txt' ypath = 'files/ylad.txt' write_to_files(xl, yl, xpath, ypath) x, y = get_function_points(get_range(start, end, delta), func) xpath = 'files/fx.txt' ypath = 'files/fy.txt' write_to_files(x, y, xpath, ypath)
def extinction_cycle_main(): epsilon = 3 r = 0.125 curr = 10 f = get_ricker_function(r) values = [] while True: curr = f(curr) + get_noise(epsilon) values.append(curr) if curr <= 0: break indexes = [i for i in range(1, len(values) + 1)] xpath = 'files/pointst.txt' ypath = 'files/pointsv.txt' write_to_files(indexes, values, xpath, ypath) erf_value = 2.33 c1, c2 = get_cycle2_points(r) ys = get_cycle_boundaries(c1, c2, r, erf_value, epsilon) print(ys)
def bif_main(): # главная бифуркационная delta = 0.0001 start = 0.2 + delta end = 0.5 offset = 1000 count = 300 epsilon = 1.0 rs = get_range(start, end, delta) x_stoch, y_stoch = get_bif(rs, offset, count, get_start_point, epsilon, True, 1000) xpath = 'files/bifx.txt' ypath = 'files/bify.txt' write_to_files(x_stoch, y_stoch, xpath, ypath) erf_value = 1.83 x_b, y_b = get_boundaries_for_range(rs, epsilon, erf_value) xbpath = 'files/boundx.txt' ybpath = 'files/boundy.txt' write_to_files(x_b, y_b, xbpath, ybpath)
def generate(self): def validate(type_tuples): new_tuples = [] for stype, name, desc in type_tuples: new_tuples.append((stype, name, desc.capitalize())) return new_tuples for (pnum, pname), _, params, ret in self.examples: pname = toCamelCase(pname) params = validate(params) [ret] = validate(ret) code = '\n'.join(b for b in self._generate( pnum, pname, params, ret) if not b.isspace()) filename = 'Problem{}.{}'.format(pnum, self.SUFFIX) write_to_files(OUT_DIR, filename, code)
def cycle2_main(): delta = 0.00005 start = 0.12 end = 0.1788 offset = 10000 count = 1000 stoch_offset = 1000 epsilon = 0.5 erf_value = 2.33 rs = get_range(start, end, delta) end_if_ext = True xc, yc = get_bif(rs, offset, count, get_start_point, epsilon, end_if_ext, stoch_offset) xcpath = 'files/cx.txt' ycpath = 'files/cy.txt' write_to_files(xc, yc, xcpath, ycpath) xbc = [] ybc = [] for r in rs: c1, c2 = get_cycle2_points(r) ys = get_cycle_boundaries(c1, c2, r, erf_value, epsilon) for y in ys: xbc.append(r) ybc.append(y) xbcpath = 'files/cbx.txt' ybcpath = 'files/cby.txt' write_to_files(xbc, ybc, xbcpath, ybcpath)
def export_examples(dicts, io_type, suffix): io_type = '_' + io_type if io_type else '' for d in dicts: write_to_files(OUT_DIR, 'problem{}{}.{}'.format(d.pop(PBLM_NUM), io_type, suffix), to_json(d))