Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit cb73c4d6 authored by boiger_r's avatar boiger_r
Browse files

update minimization

parent 97eeb9d7
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
......@@ -64,7 +64,8 @@ def opt(b_b_function, c_function, x, initial_point = None):
min_dic = {}
for i in range(x.shape[0]):
print(f'Begining of the {i}th iteration')
x0 = x[i,:]
x1 = x.to_numpy()
x0 = x1[i,:]
res = minimize(fun, x0, method='trust-constr', jac='2-point', hess=BFGS(),
constraints=[linear_constraint, nonlinear_constraint],
options={'verbose': 0}, bounds=bounds, tol = 1e-5)
......@@ -100,7 +101,8 @@ def opt_gp(b_b_function, c_function, x, initial_point = None):
min_dic = {}
for i in range(x.shape[0]):
print(f'Begining of the {i}th iteration')
x0 = x[i,:]
x1 = x.to_numpy()
x0 = x1[i,:]
res = minimize(fun, x0, method='trust-constr', jac='2-point', hess=BFGS(),
constraints=[linear_constraint, nonlinear_constraint],
options={'verbose': 0}, bounds=bounds, tol = 1e-5)
......@@ -108,6 +110,45 @@ def opt_gp(b_b_function, c_function, x, initial_point = None):
print(f'Result for the {i}th iteration: {res.x} with CO2 emissions of {res.fun}' )
return min_dic
def opt_gp1(b_b_function, c_function, x, initial_point = None):
''' Standard optimization function '''
def fun(x):
return co2_emission_fct(x)
def con(x):
return c_function.predict(x.reshape(1, -1))[0][1]
print('Initialization of the constraints')
bounds = Bounds([45, 0, 4, 7, 1, 25, 385, 0.3, 1, 0, 0, 0, 0, 0] , [80, 32, 14, 15, 1, 25, 385, 2, 5, 30, 30, 80, 40, 70])
m = [[1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
v = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
linear_constraint = LinearConstraint(m,v,v)
nonlinear_constraint = NonlinearConstraint(con, 10, np.inf, jac='2-point', hess=BFGS())
min_dic = {}
for i in range(x.shape[0]):
print(f'Begining of the {i}th iteration')
x1 = x.to_numpy()
x0 = x1[i,:]
res = minimize(fun, x0, method='trust-constr', jac='2-point', hess=BFGS(),
constraints=[linear_constraint, nonlinear_constraint],
options={'verbose': 0}, bounds=bounds, tol = 1e-2)
min_dic[f'Iteration {i}'] = {'recipe': res.x, 'co2_value': res.fun}
print(f'Result for the {i}th iteration: {res.x} with CO2 emissions of {res.fun}' )
return min_dic
def opt_ismo(c_function, initial_point):
''' Standard optimization function '''
def fun(x):
......
......@@ -17,7 +17,7 @@ bulk_moduli_phase = {'CSHQ' : 14.9, # obtain in Modeling the elastic properties
'Belite': 105.2,
'C2S' : 105.2,
'C3A' : 105.2,
'C4AF': 105.3,
'C4AF': 105.2,
'Portlandite' : 40.0,
'C3AH6' :14.9,
'C4AsH12': 40.0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment