Add files via upload
This commit is contained in:
parent
7ee026cb1c
commit
41f66199b1
34 changed files with 70577 additions and 0 deletions
38
Code/S_combine_pareto.py
Normal file
38
Code/S_combine_pareto.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Combines 2 pareto fromtier obtained from the separability test into a new one.
|
||||
|
||||
from get_pareto import Point, ParetoSet
|
||||
from RPN_to_pytorch import RPN_to_pytorch
|
||||
from RPN_to_eq import RPN_to_eq
|
||||
from S_get_symbolic_expr_error import get_symbolic_expr_error
|
||||
from sympy.parsing.sympy_parser import parse_expr
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import os
|
||||
from os import path
|
||||
from sympy import Symbol, lambdify, N
|
||||
from get_pareto import Point, ParetoSet
|
||||
|
||||
def combine_pareto(pathdir,filename,PA1,PA2,idx_list_1,idx_list_2,PA,sep_type = "+"):
|
||||
possible_vars = ["x%s" %i for i in np.arange(0,30,1)]
|
||||
PA1 = np.array(PA1.get_pareto_points()).astype('str')
|
||||
PA2 = np.array(PA2.get_pareto_points()).astype('str')
|
||||
for i in range(len(PA1)):
|
||||
for j in range(len(PA2)):
|
||||
try:
|
||||
complexity = float(PA1[i][0])+float(PA2[j][0])
|
||||
# replace the variables from the separated parts with the variables reflecting the new combined equation
|
||||
exp1 = PA1[i][2]
|
||||
exp2 = PA2[j][2]
|
||||
for k in range(len(idx_list_1)-1,-1,-1):
|
||||
exp1 = exp1.replace(possible_vars[k],possible_vars[idx_list_1[k]])
|
||||
for k in range(len(idx_list_2)-1,-1,-1):
|
||||
exp2 = exp2.replace(possible_vars[k],possible_vars[idx_list_2[k]])
|
||||
new_eq = "(" + exp1 + ")" + sep_type + "(" + exp2 + ")"
|
||||
PA.add(Point(x=complexity,y=get_symbolic_expr_error(pathdir,filename,new_eq),data=new_eq))
|
||||
except:
|
||||
continue
|
||||
return PA
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue