Esempio n. 1
0
 def _check_values(self, v):
     if not 1 <= len(v) <= SETTINGS.get("string_parameter_max_size"):
         misc.error("Categorical_Parameter::__check_values() -> " +
                    self._name +
                    ": values array size is out of range [1 ;" +
                    str(SETTINGS.get("string_parameter_max_size")) + "]")
         raise ValueError
Esempio n. 2
0
	def __partial_solver(self, constraints):
		s = SMT_Interface()
		variables = {}

		for constraint in constraints:
			constraint.process()
			self.__add_variables_to_solver(s, constraint)
			self.__add_constraint_to_solver(s, constraint)
			variables.update(constraint.variables)
		
		if not s.check():
			return False

		max_additional_constraints = []
		for i in range(int(SETTINGS.get("max_diversity"))):
			s.push()
			additional_constraints = self.__add_randomness(s, variables)
			if len(additional_constraints) > len(max_additional_constraints):
				max_additional_constraints = additional_constraints
			s.pop()
			if len(max_additional_constraints) == len(variables):
				break

		if self.__verbose:
			print(misc.get_separator())
			print("additional contraint(s): ")
			print(max_additional_constraints)
			print(misc.get_separator())

		for constraint in max_additional_constraints:
			s.add_constraint(constraint)
		self.__assign_solver_results(s, variables)
		return True
Esempio n. 3
0
	def generate(self):
		depth = 0
		counter = 0
		nodes, parameters = self.__tree.get_depth_elements(depth)

		#debug
		#for i in range(10):
		#	print("*************************************************" + str(i))
		#	nodes, parameters = self.__tree.get_depth_elements(i)
		#	for node in nodes:
		#		print("node -> " + node.name)
		#		node.change_nb_instances(1)
		#	for parameter in parameters:
		#		print("parameter -> " + parameter.name)

		#for i, constraint in enumerate(self.__constraints):
		#	print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" + str(i))
		#	for c in constraint:
		#		print(c.raw_expressions)

		while True:
			if counter == int(SETTINGS.get("max_backtracking")):
				print("--> false")
				return False
			if not(parameters or nodes):
				return True
			if len(self.__constraints) > depth:
				constraints = self.__constraints[depth]
			else:
				constraints = []

			if self.__generate_depth(nodes, parameters, constraints):
				depth += 1
			elif depth > 0:
				counter += 1
				depth -= 1
				self.__reset_depth(nodes, parameters)
			else:
				misc.error("Generator::generate() -> unable to generate the current template")
				return False
			self.__tree.build_constraints()
			nodes, parameters = self.__tree.get_depth_elements(depth)
			self.__constraints = [[]]
			self.__set_constraints()
Esempio n. 4
0
 def __check_nb_instances(self, nb):
     if not 0 <= nb <= SETTINGS.get("parameter_max_nb_instances"):
         misc.error("Parameter::__check_nb_instances() -> " + self._name +
                    ": nb_instances parameter is out of range [0 ; " +
                    str(SETTINGS.get("parameter_max_nb_instances")) + "]")
         raise ValueError
Esempio n. 5
0
	def set_timeout(self):
		self.__solver.set("timeout", int(SETTINGS.get("z3_timeout")))
Esempio n. 6
0
	def increase_timeout(self):
		self.__solver.set("timeout", 100*int(SETTINGS.get("z3_timeout")))
Esempio n. 7
0
 def __check_nb_instances(self, nb):
     if not 0 <= nb <= SETTINGS.get("node_max_nb_instances"):
         misc.error("Node::__check_nb_instances() -> " + self._name +
                    ": nb_instances is out of range [0;" +
                    str(SETTINGS.get("node_max_nb_instances")) + "]")