Skip to content

Commit 73a70b9

Browse files
authored
Merge pull request #87 from sandialabs/dev-weh
Various performance improvements
2 parents 7bd17b6 + 0730fd1 commit 73a70b9

File tree

7 files changed

+47
-23
lines changed

7 files changed

+47
-23
lines changed

Diff for: build.sh

+19-3
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,40 @@
66
# This uses Spack to install third-party dependencies in the `_spack` directory.
77
#
88
with_python="OFF"
9+
python_exe=""
910
spack_reinstall=0
1011
spack_dev=0
1112
clang=0
13+
debug="OFF"
1214
spack_home=`pwd`/_spack
15+
with_valgrind=""
1316
while [[ $# -gt 0 ]]; do
1417
case $1 in
1518
--help)
16-
echo "build.sh [--python] [--clang] [--spack-reinstall] [--spack-dev] [--spack-home <dir>] [--help]"
19+
echo "build.sh [--help] [--clang] [--debug] [--python] [--python-exe <file>] [--spack-dev] [--spack-home <dir>] [--spack-reinstall] [--valgrind]"
1720
exit
1821
;;
1922
--python)
2023
with_python="ON"
2124
shift
2225
;;
26+
--python-exe)
27+
python_exe="-DPython_EXECUTABLE=$2"
28+
shift
29+
shift
30+
;;
2331
--clang)
2432
clang=1
2533
shift
2634
;;
35+
--debug)
36+
debug="ON"
37+
shift
38+
;;
39+
--valgrind)
40+
with_valgrind="valgrind"
41+
shift
42+
;;
2743
--spack-reinstall)
2844
spack_reinstall=1
2945
shift
@@ -87,7 +103,7 @@ else
87103
. ${SPACK_HOME}/share/spack/setup-env.sh
88104
spack env create coekenv
89105
spack env activate coekenv
90-
spack add asl cppad fmt rapidjson catch2 highs
106+
spack add asl cppad fmt rapidjson catch2 highs $with_valgrind
91107
spack install
92108
spack env deactivate
93109
fi
@@ -102,5 +118,5 @@ echo "Building Coek"
102118
echo ""
103119
mkdir _build
104120
cd _build
105-
cmake -DCMAKE_PREFIX_PATH=${SPACK_HOME}/var/spack/environments/coekenv/.spack-env/view -Dwith_python=${with_python} -Dwith_gurobi=$with_gurobi -Dwith_highs=ON -Dwith_cppad=ON -Dwith_fmtlib=ON -Dwith_rapidjson=ON -Dwith_catch2=ON -Dwith_tests=ON -Dwith_asl=ON -Dwith_openmp=OFF ..
121+
cmake -DCMAKE_PREFIX_PATH=${SPACK_HOME}/var/spack/environments/coekenv/.spack-env/view -Dwith_debug=${debug} -Dwith_python=${with_python} $python_exe -Dwith_gurobi=$with_gurobi -Dwith_highs=ON -Dwith_cppad=ON -Dwith_fmtlib=ON -Dwith_rapidjson=ON -Dwith_catch2=ON -Dwith_tests=ON -Dwith_asl=ON -Dwith_openmp=OFF ..
106122
make -j20

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

Diff for: test/aml_comparisons/coek/models/jump/fac_array.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ void fac_array(coek::Model& model, size_t F)
88
size_t G = F;
99

1010
// Create variables
11-
auto d = model.add(coek::variable("d")).bounds(0, COEK_INFINITY).value(1.0);
11+
auto d = model.add(coek::variable("d").bounds(0, COEK_INFINITY).value(1.0));
1212

13-
auto y = model.add(coek::variable("y", {F, 2})).bounds(0, 1).value(1.0);
13+
auto y = model.add(coek::variable("y", {F, 2}).bounds(0, 1).value(1.0));
1414

15-
auto z = model.add(coek::variable("z", {G + 1, G + 1, F}))
15+
auto z = model.add(coek::variable("z", {G + 1, G + 1, F})
1616
.bounds(0, 1)
1717
.value(1.0)
18-
.within(coek::VariableTypes::Boolean);
18+
.within(coek::VariableTypes::Boolean));
1919

20-
auto s = model.add(coek::variable("s", {G + 1, G + 1, F})).bounds(0, COEK_INFINITY).value(0);
20+
auto s = model.add(coek::variable("s", {G + 1, G + 1, F}).bounds(0, COEK_INFINITY).value(0));
2121

22-
auto r = model.add(coek::variable("r", {G + 1, G + 1, F, 2}))
22+
auto r = model.add(coek::variable("r", {G + 1, G + 1, F, 2})
2323
.bounds(-COEK_INFINITY, COEK_INFINITY)
24-
.value(0);
24+
.value(0));
2525

2626
// Add objective
2727

Diff for: test/aml_comparisons/coek/models/jump/lqcp_array.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void lqcp_array(coek::Model& model, size_t n)
2020
// double h2 = dx*dx;
2121
double a = 0.001;
2222

23-
auto y = model.add(coek::variable("y", {m + 1, n + 1})).bounds(0, 1).value(0);
24-
auto u = model.add(coek::variable("u", m + 1)).bounds(-1, 1).value(0);
23+
auto y = model.add(coek::variable("y", {m + 1, n + 1}).bounds(0, 1).value(0));
24+
auto u = model.add(coek::variable("u", m + 1).bounds(-1, 1).value(0));
2525

2626
// OBJECTIVE
2727
// First term

Diff for: test/aml_comparisons/coek/models/jump/lqcp_map.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ void lqcp_map(coek::Model& model, size_t n)
2424

2525
auto M = coek::RangeSet(0, m);
2626
auto N = coek::RangeSet(0, n);
27-
auto y = model.add(coek::variable("y", M * N)).bounds(0, 1).value(0);
28-
auto u = model.add(coek::variable("u", coek::RangeSet(1, m))).bounds(-1, 1).value(0);
27+
auto y = model.add(coek::variable("y", M * N).bounds(0, 1).value(0));
28+
auto u = model.add(coek::variable("u", coek::RangeSet(1, m)).bounds(-1, 1).value(0));
2929

3030
// OBJECTIVE
3131
// First term

Diff for: test/aml_comparisons/coek/models/misc/pmedian_array.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ void pmedian_array(coek::Model& model, size_t N, size_t P)
1313
d[n][m] = 1.0 + 1.0 / (n + m + 1);
1414
}
1515

16-
auto x = model.add(coek::variable("x", {N, M})).bounds(0, 1).value(0);
16+
auto x = model.add(coek::variable("x", {N, M}).bounds(0, 1).value(0));
1717

18-
auto y = model.add(coek::variable("y", N)).bounds(0, 1).value(0);
18+
auto y = model.add(coek::variable("y", N).bounds(0, 1).value(0));
1919

2020
// obj
2121
auto obj = coek::expression();

0 commit comments

Comments
 (0)