def randomize(self): """Randomize tranformations. """ cpool = model_constraintpool.ConstraintPool.get_pool() symmetry_constraint = cpool.get(self, SYMMETRY_CONSTRAINT) #TODO symmetry 0, 25 Binominal self.symmetry = model_random.randint_constrained(symmetry_constraint) Dn_constraint = cpool.get(self, DN_CONSTRAINT) self.Dn = model_random.randint_constrained(Dn_constraint) orbit_constraint = cpool.get(self, ORBIT_CONSTRAINT) self.orbits = model_random.randint_constrained(orbit_constraint) self.random_seed = random.randint(1, 65535) num_transformations_constraint = cpool.get(self, NUM_TRANSFORMATION_CONSTRAINT) self.num_transformations = model_random.randint_constrained(num_transformations_constraint) self._fill_pol_transf() for tix in range(self.num_transformations): #translation -2.0, 2.0 self.pol_transf[tix][0] = model_random.uniform_constrained([-2.0, 2.0]) self.pol_transf[tix][1] = model_random.uniform_constrained([-2.0, 2.0]) #rotation -math.pi, math.pi self.pol_transf[tix][2] = model_random.uniform_constrained([-math.pi, math.pi]) self.pol_transf[tix][3] = model_random.uniform_constrained([-math.pi, math.pi]) #scaling 0.0, 1.0 self.pol_transf[tix][4] = model_random.uniform_constrained([-1.0, 1.0]) self.pol_transf[tix][5] = model_random.uniform_constrained([-1.0, 1.0]) # self._prepare_transient_members() x_stamp_size_constraint = cpool.get(self, X_STAMP_SIZE_CONSTRAINT) self.x_stamp_size = model_random.uniform_constrained(x_stamp_size_constraint) y_stamp_size_constraint = cpool.get(self, Y_STAMP_SIZE_CONSTRAINT) self.y_stamp_size = model_random.uniform_constrained(y_stamp_size_constraint)
def randomize(self): """Randomize the layers components. post: len(self.cell_colors) == self.states post: forall(self.rules, lambda f: 0 <= f < self.states) """ super(LcaLayer, self).randomize() cpool = model_constraintpool.ConstraintPool.get_pool() size_constraint = cpool.get(self, SIZE_CONSTRAINT) self.size = model_random.randint_constrained(size_constraint) states_constraint = cpool.get(self, STATES_CONSTRAINT) self.states = model_random.randint_constrained(states_constraint) left_neighbors_constraint = cpool.get(self, LEFT_NEIGHBORS_CONSTRAINT) self.left_neighbors = model_random.randint_constrained(left_neighbors_constraint) right_neighbors_constraint = cpool.get(self, RIGHT_NEIGHBORS_CONSTRAINT) self.right_neighbors = model_random.randint_constrained(right_neighbors_constraint) self.rules = [random.randrange(0, self.states) \ for dummy in xrange(self.get_numberof_rules())] self.sequence_ordering = random.uniform(0.0, 1.0) colorgamut_factory = ka_factory.get_factory('colorgamut') colorgamuttype_constraint = cpool.get(self, COLORGAMUTTYPE_CONSTRAINT) self.colorgamut = colorgamut_factory.create_random(colorgamuttype_constraint, self.path) self.colorgamut.randomize() self.cell_colors = [] for dummy in range(self.states): site_color = self.colorgamut.get_randomized_color(self.path) self.cell_colors.append(site_color)
def randomize(self): """Randomizes the number of tiles.""" cpool = model_constraintpool.ConstraintPool.get_pool() x_tiles_constraint = cpool.get(self, X_TILES_CONSTRAINT) self.x_tiles = model_random.randint_constrained(x_tiles_constraint) y_tiles_constraint = cpool.get(self, Y_TILES_CONSTRAINT) self.y_tiles = model_random.randint_constrained(y_tiles_constraint)
def randomize(self): """Randomize""" cpool = model_constraintpool.ConstraintPool.get_pool() x_center_constraint = cpool.get(self, X_CENTER_CONSTRAINT) self.x_center = model_random.uniform_constrained(x_center_constraint) y_center_constraint = cpool.get(self, Y_CENTER_CONSTRAINT) self.y_center = model_random.uniform_constrained(y_center_constraint) steps_constraint = cpool.get(self, STEPS_CONSTRAINT) self.start = model_random.randint_constrained(steps_constraint) self.end = model_random.randint_constrained(steps_constraint) angle_constraint = cpool.get(self, ANGLE_CONSTRAINT) self.angle = model_random.uniform_constrained(angle_constraint) c_constraint = cpool.get(self, C_CONSTRAINT) self.c = model_random.uniform_constrained(c_constraint)
def randomize(self): """Randomize the layers components.""" super(MarkovChainLayer, self).randomize() cpool = model_constraintpool.ConstraintPool.get_pool() colorgamut_factory = ka_factory.get_factory('colorgamut') colorgamuttype_constraint = cpool.get(self, COLORGAMUTTYPE_CONSTRAINT) self.colorgamut = colorgamut_factory.create_random( colorgamuttype_constraint, self.path) self.colorgamut.randomize() number_of_states_constraint = cpool.get(self, NUMBER_OF_STATES_CONSTRAINT) self._init_states( model_random.randint_constrained(number_of_states_constraint)) sampler_factory = ka_factory.get_factory('sampler') samplertype_constraint = cpool.get(self, SAMPLERTYPE_CONSTRAINT) self.sampler = sampler_factory.create_random(samplertype_constraint, self.path) self.sampler.randomize() stamp_factory = ka_factory.get_factory('stamp') stamptype_constraint = cpool.get(self, STAMPTYPE_CONSTRAINT) self.stamp = stamp_factory.create_random(stamptype_constraint, self.path, self.states) self.stamp.randomize()
def randomize(self): """Randomize the layers components.""" super(QuadTreeLayer, self).randomize() cpool = model_constraintpool.ConstraintPool.get_pool() depth_constraint = cpool.get(self, DEPTH_CONSTRAINT) self.depth = model_random.randint_constrained(depth_constraint) border_width_constraint = cpool.get(self, BORDER_WIDTH_CONSTRAINT) self.border_width = model_random.uniform_constrained( border_width_constraint) propability_constraint = cpool.get(self, PROBABILITY_CONSTRAINT) self.propability = model_random.uniform_constrained( propability_constraint) colorgamut_factory = ka_factory.get_factory('colorgamut') colorgamuttype_constraint = cpool.get(self, COLORGAMUTTYPE_CONSTRAINT) self.colorgamut = colorgamut_factory.create_random( colorgamuttype_constraint, self.path) self.colorgamut.randomize() self.tile_colors = [] for dummy in range(self.depth): site_color = self.colorgamut.get_randomized_color(self.path) self.tile_colors.append(site_color)
def mutate(self): """Make small random changes to the layers components. post: len(self.cell_colors) == self.states post: forall(self.rules, lambda f: 0 <= f < self.states) """ super(LcaLayer, self).mutate() cpool = model_constraintpool.ConstraintPool.get_pool() size_constraint = cpool.get(self, SIZE_CONSTRAINT) self.size = model_random.jitter_discret_constrained( self.size, size_constraint) states_constraint = cpool.get(self, STATES_CONSTRAINT) self.states = model_random.jitter_discret_constrained( self.states, states_constraint) left_neighbors_constraint = cpool.get(self, LEFT_NEIGHBORS_CONSTRAINT) self.left_neighbors = model_random.randint_constrained(left_neighbors_constraint) self.left_neighbors = model_random.jitter_discret_constrained( self.left_neighbors, left_neighbors_constraint) right_neighbors_constraint = cpool.get(self, RIGHT_NEIGHBORS_CONSTRAINT) self.right_neighbors = model_random.jitter_discret_constrained( self.right_neighbors, right_neighbors_constraint) self.patch_rulesize() self.patch_colorsize() self.colorgamut.mutate() for cix in range(len(self.cell_colors)): self.colorgamut.adjust_color(self.cell_colors[cix])
def randomize(self): """Randomizes the walk.""" cpool = model_constraintpool.ConstraintPool.get_pool() sections_constraint = cpool.get(self, SECTIONS_CONSTRAINT) for dummy in range( model_random.randint_constrained(sections_constraint)): direction = exon_direction.Direction(self.path, 0.0, 0.0) direction.randomize() self.direction_steps.append(direction)
def randomize(self): """Randomize the layers components.""" super(VoronoiDiagramLayer, self).randomize() cpool = model_constraintpool.ConstraintPool.get_pool() number_of_constraint = cpool.get(self, NUMBER_OF_SITES_CONSTRAINT) order_constraint = cpool.get(self, ORDER_CONSTRAINT) self.order = model_random.uniform_constrained(order_constraint) sampler_factory = ka_factory.get_factory('sampler') samplertype_constraint = cpool.get(self, SAMPLERTYPE_CONSTRAINT) self.sampler = sampler_factory.create_random(samplertype_constraint, self.path) self.sampler.randomize() colorgamut_factory = ka_factory.get_factory('colorgamut') colorgamuttype_constraint = cpool.get(self, COLORGAMUTTYPE_CONSTRAINT) self.colorgamut = colorgamut_factory.create_random( colorgamuttype_constraint, self.path) self.colorgamut.randomize() self.sites_point = [] for dummy in range( model_random.randint_constrained(number_of_constraint)): site_point = exon_position.Position(self.path, 0.0, 0.0) site_point.randomize() self.sites_point.append(site_point) self.sites_color = [] for dummy in range( model_random.randint_constrained(number_of_constraint)): site_color = self.colorgamut.get_randomized_color(self.path) self.sites_color.append(site_color) stamp_factory = ka_factory.get_factory('stamp') stamptype_constraint = cpool.get(self, STAMPTYPE_CONSTRAINT) self.stamp = stamp_factory.create_random(stamptype_constraint, self.path, len(self.sites_point)) self.stamp.randomize()
def randomize(self): """Randomize the layers components.""" super(LetterPress, self).randomize() cpool = model_constraintpool.ConstraintPool.get_pool() self.textcolor.randomize() family_constraint = cpool.get(self, FONTFAMILY_CONSTRAINT) self.family = random.choice(family_constraint) style_constraint = cpool.get(self, FONTSTYLE_CONSTRAINT) self.style = random.choice(style_constraint) size_constraint = cpool.get(self, FONTSIZE_CONSTRAINT) self.size = model_random.randint_constrained(size_constraint) weight_constraint = cpool.get(self, FONTWEIGHT_CONSTRAINT) self.weight = model_random.randint_constrained(weight_constraint) self.center.randomize() sampler_factory = ka_factory.get_factory('sampler') samplertype_constraint = cpool.get(self, SAMPLERTYPE_CONSTRAINT) self.sampler = sampler_factory.create_random(samplertype_constraint, self.path) self.sampler.randomize() self.buzzwords.randomize()
def randomize(self): """Randomize""" cpool = model_constraintpool.ConstraintPool.get_pool() x_center_constraint = cpool.get(self, X_CENTER_CONSTRAINT) self.x_center = model_random.uniform_constrained(x_center_constraint) y_center_constraint = cpool.get(self, Y_CENTER_CONSTRAINT) self.y_center = model_random.uniform_constrained(y_center_constraint) steps_constraint = cpool.get(self, STEPS_CONSTRAINT) self.steps = model_random.randint_constrained(steps_constraint) turns_constraint = cpool.get(self, TURNS_CONSTRAINT) self.turns = model_random.uniform_constrained(turns_constraint) a_constraint = cpool.get(self, A_CONSTRAINT) self.a = model_random.uniform_constrained(a_constraint) b_constraint = cpool.get(self, B_CONSTRAINT) self.b = model_random.uniform_constrained(b_constraint)
def randomize(self): """Randomize the layers components.""" cpool = model_constraintpool.ConstraintPool.get_pool() order_constraint = cpool.get(self, ORDER_CONSTRAINT) self.order = model_random.randint_constrained(order_constraint) radius_constraint = cpool.get(self, RADIUS_CONSTRAINT) self.radius = model_random.uniform_constrained(radius_constraint) scatter_constraint = cpool.get(self, SCATTER_CONSTRAINT) self.scatter = model_random.uniform_constrained(scatter_constraint) start_angle_constraint = cpool.get(self, START_ANGLE_CONSTRAINT) self.start_angle = model_random.uniform_constrained( start_angle_constraint) line_width_constraint = cpool.get(self, LINE_WIDTH_CONSTRAINT) self.line_width = model_random.uniform_constrained( line_width_constraint) self.random_seed = random.randint(1, 65535)