Skip to content

Commit 6d85b77

Browse files
committed
Several performance optimiziations
1 parent 0cdab15 commit 6d85b77

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Diff for: lib/coek/coek/api/parameter_assoc_array.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ void ParameterAssocArrayRepn::value(double value)
3636
{
3737
parameter_template.value(value);
3838
if (values.size() > 0) {
39+
Expression e(value);
3940
for (auto& var : values)
40-
var.value(value);
41+
var.value(e);
4142
}
4243
}
4344

Diff for: lib/coek/coek/api/variable_assoc_array.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ void VariableAssocArrayRepn::value(double value)
4646
{
4747
variable_template.value(value);
4848
if (values.size() > 0) {
49+
coek::Expression e(value);
4950
for (auto& var : values)
50-
var.value(value);
51+
var.value(e);
5152
}
5253
}
5354

@@ -64,8 +65,9 @@ void VariableAssocArrayRepn::lower(double value)
6465
{
6566
variable_template.lower(value);
6667
if (values.size() > 0) {
68+
coek::Expression e(value);
6769
for (auto& var : values)
68-
var.lower(value);
70+
var.lower(e);
6971
}
7072
}
7173

@@ -82,8 +84,9 @@ void VariableAssocArrayRepn::upper(double value)
8284
{
8385
variable_template.upper(value);
8486
if (values.size() > 0) {
87+
coek::Expression e(value);
8588
for (auto& var : values)
86-
var.upper(value);
89+
var.upper(e);
8790
}
8891
}
8992

@@ -100,26 +103,30 @@ void VariableAssocArrayRepn::bounds(double lb, double ub)
100103
{
101104
variable_template.bounds(lb, ub);
102105
if (values.size() > 0) {
106+
coek::Expression lower(lb);
107+
coek::Expression upper(ub);
103108
for (auto& var : values)
104-
var.bounds(lb, ub);
109+
var.bounds(lower,upper);
105110
}
106111
}
107112

108113
void VariableAssocArrayRepn::bounds(const Expression& lb, double ub)
109114
{
110115
variable_template.bounds(lb, ub);
111116
if (values.size() > 0) {
117+
coek::Expression upper(ub);
112118
for (auto& var : values)
113-
var.bounds(lb, ub);
119+
var.bounds(lb,upper);
114120
}
115121
}
116122

117123
void VariableAssocArrayRepn::bounds(double lb, const Expression& ub)
118124
{
119125
variable_template.bounds(lb, ub);
120126
if (values.size() > 0) {
127+
coek::Expression lower(lb);
121128
for (auto& var : values)
122-
var.bounds(lb, ub);
129+
var.bounds(lower,ub);
123130
}
124131
}
125132

0 commit comments

Comments
 (0)