|
|
@ -2,6 +2,12 @@ |
|
|
|
|
|
|
|
from . import randomSAT |
|
|
|
|
|
|
|
import math |
|
|
|
import random |
|
|
|
import numpy as np |
|
|
|
import seaborn as sns |
|
|
|
import matplotlib.pyplot as plt |
|
|
|
|
|
|
|
class Random_instance_pool: |
|
|
|
|
|
|
|
def __init__(self, parameter_range): |
|
|
@ -83,5 +89,90 @@ class Manual_range: |
|
|
|
def next(self): |
|
|
|
return self.__next__() |
|
|
|
|
|
|
|
|
|
|
|
class Random_range: |
|
|
|
|
|
|
|
def __init__(self, random_generator, steps): |
|
|
|
self.__random_generator = random_generator |
|
|
|
self.__steps = steps |
|
|
|
self.__current_step = 0 |
|
|
|
|
|
|
|
def __iter__(self): |
|
|
|
return self |
|
|
|
|
|
|
|
def __next__(self): |
|
|
|
if self.__current_step < self.__steps: |
|
|
|
self.__current_step += 1 |
|
|
|
return self.__random_generator.random() |
|
|
|
else: |
|
|
|
raise StopIteration |
|
|
|
|
|
|
|
def next(self): |
|
|
|
return self.__next__() |
|
|
|
|
|
|
|
class Random_logistic_variable_distribution: |
|
|
|
|
|
|
|
def __init__(self, |
|
|
|
number_of_clauses, |
|
|
|
min_variables, |
|
|
|
max_variables, |
|
|
|
alpha_point_of_interest, |
|
|
|
steepnesss): |
|
|
|
self.__number_of_clauses = number_of_clauses |
|
|
|
self.__min_variables = min_variables |
|
|
|
self.__max_variables = max_variables |
|
|
|
self.__alpha_point_of_interest = alpha_point_of_interest |
|
|
|
self.__steepnesss = steepnesss |
|
|
|
|
|
|
|
def random(self): |
|
|
|
number_of_variables = 0 |
|
|
|
|
|
|
|
while (number_of_variables < self.__min_variables or |
|
|
|
number_of_variables > self.__max_variables): |
|
|
|
|
|
|
|
alpha = inv_logistic(random.random(), |
|
|
|
1, |
|
|
|
self.__steepnesss, |
|
|
|
self.__alpha_point_of_interest) |
|
|
|
|
|
|
|
number_of_variables = int(self.__number_of_clauses / alpha) |
|
|
|
|
|
|
|
return number_of_variables |
|
|
|
|
|
|
|
def inv_logistic(x, L, k, x0): |
|
|
|
return math.log(math.pow(x / (L-x), 1/k)) + x0 |
|
|
|
|
|
|
|
def test(): |
|
|
|
sns.set() |
|
|
|
|
|
|
|
data = [] |
|
|
|
|
|
|
|
logistic_distr = Random_logistic_variable_distribution(42, 5, 84, 4.5, 1) |
|
|
|
rnd_range = Random_range(logistic_distr, 500) |
|
|
|
|
|
|
|
for i in range(500): |
|
|
|
#data.append(50/math.exp(random.uniform(5, 50))) |
|
|
|
#v = 0 |
|
|
|
|
|
|
|
#while v < 5 or v > 84: |
|
|
|
#v = int(42 / inv_logistic(random.random(), 1, 1, 4.5)) |
|
|
|
|
|
|
|
data.append(rnd_range.next()) |
|
|
|
|
|
|
|
data = np.array(data) |
|
|
|
|
|
|
|
sns.distplot(data, |
|
|
|
#bins=30, |
|
|
|
norm_hist=True) |
|
|
|
#sns.lineplot(list(range(2, 100)), data) |
|
|
|
plt.show() |
|
|
|
|
|
|
|
sns.distplot(42/data, |
|
|
|
#bins=30, |
|
|
|
norm_hist=True) |
|
|
|
#sns.lineplot(list(range(2, 100)), data) |
|
|
|
plt.show() |
|
|
|
|
|
|
|
return data |
|
|
|
|
|
|
|
|
|
|
|
|