Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply adaptive sampling patch to code #13

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ get-dakota-src:
git submodule update --init packages/pecos && \
git submodule update --init packages/surfpack && \
git apply ../src_patches/dakota-src.patch && \
git apply --whitespace=nowarn ../src_patches/adaptsampl_batch.patch && \
find . \( -name \*.cpp -o -name \*.hpp -o -name \*.c -o -name \*.h \) -exec \
sed -i -E -f ../src_patches/replace_old_macros_numpy.sed {} +
43 changes: 43 additions & 0 deletions src_patches/adaptsampl_batch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/src/NonDAdaptiveSampling.cpp b/src/NonDAdaptiveSampling.cpp
index 5a43bdf31..3d22b7418 100644
--- a/src/NonDAdaptiveSampling.cpp
+++ b/src/NonDAdaptiveSampling.cpp
@@ -298,14 +298,30 @@ namespace Dakota
// add new_X to the build points and append approximation
VariablesArray points_to_add;
IntResponseMap responses_to_add;
- for(int i = 0; i < new_Xs.size(); i++)
- {
- iteratedModel.continuous_variables(new_Xs[i]);
- iteratedModel.evaluate();
- responses_to_add.insert(IntResponsePair(iteratedModel.evaluation_id(),
- iteratedModel.current_response()));
- points_to_add.push_back(iteratedModel.current_variables());
- }
+ if (iteratedModel.asynch_flag())
+ {
+ fout << "\nUsing async evaluation" << std::endl;
+
+ for(int i = 0; i < new_Xs.size(); i++)
+ {
+ iteratedModel.continuous_variables(new_Xs[i]);
+ iteratedModel.evaluate_nowait();
+ points_to_add.push_back(iteratedModel.current_variables());
+ }
+
+ // Wait for the responses.
+ responses_to_add = iteratedModel.synchronize();
+ }
+ else {
+ for(int i = 0; i < new_Xs.size(); i++)
+ {
+ iteratedModel.continuous_variables(new_Xs[i]);
+ iteratedModel.evaluate();
+ responses_to_add.insert(IntResponsePair(iteratedModel.evaluation_id(),
+ iteratedModel.current_response()));
+ points_to_add.push_back(iteratedModel.current_variables());
+ }
+ }

gpModel.append_approximation(points_to_add,responses_to_add, true);

Loading