Skip to content

Commit e4eaaa0

Browse files
authored
Merge pull request #29 from IEE-TUGraz/feature/sqlite_objective_terms
Add var_value and objective impact to SQLiteWriter.py
2 parents 91e8229 + 7d8ba90 commit e4eaaa0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

SQLiteWriter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ def add_objective_decomposition_to_sqlite(filename: str, model: pyo.ConcreteMode
201201
var_names = [var.parent_component().name for var in repn.linear_vars]
202202
var_indices = [str(var.index()) for var in repn.linear_vars]
203203
coefs = list(repn.linear_coefs)
204+
var_values = [pyo.value(var) for var in repn.linear_vars]
205+
var_times_coefficient = [var_value * coef for var_value, coef in zip(var_values, coefs)]
204206
df_terms = pd.DataFrame({
205207
'var_name': var_names,
206208
'var_index': var_indices,
207-
'coefficient': coefs
209+
'coefficient': coefs,
210+
'var_value': var_values,
211+
'var_times_coefficient': var_times_coefficient,
208212
})
209213
df_terms.to_sql('objective_terms', cnx, if_exists='replace', index=False)
210214

0 commit comments

Comments
 (0)