Commit a8660942 authored by Lie-Piang, Anouk's avatar Lie-Piang, Anouk
Browse files

Update Formulation_Tool.py

parent 171a1316
......@@ -21,7 +21,8 @@ problem.addVariable('p', [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,
7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8,
8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9,
9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9,
10.0])
10.0
])
problem.addVariable('s', [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,
1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,
2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,
......@@ -32,21 +33,24 @@ problem.addVariable('s', [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,
7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8,
8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9,
9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9,
10.0])
10.0
])
problem.addVariable('f', [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,
1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,
2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,
3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,
4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5,
5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,
6])
6
])
problem.addVariable('r', [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,
1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,
2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,
3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,
4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5,
5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,
6])
6
])
#Setting desired viscosity add in a range of + and - 2.5%
var_mean = 1500
......@@ -56,11 +60,13 @@ low_vis = math.log(var_mean * (1 - var_boundary))
#Inserting the coefficients of the visocisty regression model
def lower_constraint(p, s, f, r):
if (p * 0.3064) + (s * 1.10001) + (f * 1.63015) + (r * 0.45714) + (p * s * -0.03559) + (p * f * -0.0691) + (s * f * -0.22083) >= low_vis:
if (p * 0.3064) + (s * 1.10001) + (f * 1.63015) + (r * 0.45714) + (p * s * -0.03559) + (p * f * -0.0691) + (s * f * -0.22083
) >= low_vis:
return True
def upper_constraint(p, s, f, r):
if (p * 0.3064) + (s * 1.10001) + (f * 1.63015) + (r * 0.45714) + (p * s * -0.03559) + (p * f * -0.0691) + (s * f * -0.22083) <= up_vis:
if (p * 0.3064) + (s * 1.10001) + (f * 1.63015) + (r * 0.45714) + (p * s * -0.03559) + (p * f * -0.0691) + (s * f * -0.22083
) <= up_vis:
return True
#defining the upper dry matter limit of the training set of the regression model
......@@ -80,7 +86,8 @@ SolutionList = [list(t) for t in SolutionsList_order]
SolutionList.insert(0,['Protein (DM%)', 'Starch (DM%)', 'Fibre (DM%)', 'Rest (DM%)'])
df_comp = pd.DataFrame(SolutionList[1:],columns=SolutionList[0])
df = pd.DataFrame(df_comp.sum(axis = 1))
df_comp.to_csv (r'C:\ModelsLocal\Functionality models\Ternary plots\1500_0.025mPas_22%dm.csv', index = False, header=True)
df_comp.to_csv(r'C:\ModelsLocal\Functionality models\Ternary plots\1500_0.025mPas_22%dm.csv', index = False, header=True
)
#Creating a 3D scatterplot of all possible combinations of components
......@@ -102,11 +109,11 @@ fig_comp.show(renderer = 'png') #in python
#Convert the found composition into possible combinations of fractions using linear optimisation
#Convert the found composition into possible combinations of ingredients using linear optimisation
import pulp
OptimalSolutions = [] #empty list to store the outcome of the variables
Fractions = ['CF','FF','FI', 'PF', 'PI', 'SI']
#Compositions fractions with Eurofins report isolates and Nienkes results MRF
#Compositions ingredients
protein = {'CF': 0.153,
'FF': 0.407,
'FI': 0.078,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment