#!/usr/bin/env python3
|
|
|
|
from . import randomSAT
|
|
|
|
class Random_instance_pool:
|
|
|
|
def __init__(self, parameter_range):
|
|
self.__parameter_range = parameter_range
|
|
|
|
def __iter__(self):
|
|
return self
|
|
|
|
def __next__(self):
|
|
return self.Random(self.__parameter_range.next())
|
|
|
|
class Random:
|
|
def __init__(self, parameters):
|
|
self.__params = parameters
|
|
|
|
def random(self):
|
|
return randomSAT.generateRandomKSAT(self.__params.number_of_clauses,
|
|
self.__params.number_of_variables,
|
|
self.__params.variables_per_clause)
|
|
|
|
|
|
|
|
class Instance_parameters:
|
|
|
|
def __init__(self,
|
|
number_of_clauses,
|
|
number_of_variables,
|
|
variables_per_clause = 3):
|
|
|
|
self.number_of_clauses = number_of_clauses
|
|
self.number_of_variables = number_of_variables
|
|
self.variables_per_clause = variables_per_clause
|
|
|
|
def __str__(self):
|
|
return ("number of clauses: {}\n"
|
|
"number of variables: {}\n"
|
|
"variables per clause: {}").format(self.number_of_clauses,
|
|
self.number_of_variables,
|
|
self.variables_per_clause)
|
|
|
|
class Instance_parameter_variable_range:
|
|
|
|
def __init__(self, start_parameter, variable_range):
|
|
self.start_parameter = start_parameter
|
|
self.__variable_range = variable_range
|
|
|
|
def __iter__(self):
|
|
return self
|
|
|
|
def __next__(self):
|
|
self.start_parameter.number_of_variables = self.__variable_range.next()
|
|
|
|
return self.start_parameter
|
|
|
|
def next(self):
|
|
return self.__next__()
|
|
|
|
|
|
class Manual_range:
|
|
|
|
def __init__(self, start, stop, step = 1):
|
|
self.start = start
|
|
self.stop = stop
|
|
self.step = step
|
|
|
|
self.__current = start
|
|
|
|
def __iter__(self):
|
|
return self
|
|
|
|
def __next__(self):
|
|
if self.__current >= self.stop:
|
|
raise StopIteration
|
|
|
|
self.__current += self.step
|
|
|
|
return self.__current
|
|
|
|
def next(self):
|
|
return self.__next__()
|
|
|
|
|
|
|