Skip to content

Commit

Permalink
Add poly_design example
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Oct 15, 2024
1 parent d277900 commit 403b2fa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions test-data/ert/poly_design/POLY_EVAL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXECUTABLE poly_eval.py
16 changes: 16 additions & 0 deletions test-data/ert/poly_design/poly.ert
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
QUEUE_SYSTEM LOCAL
QUEUE_OPTION LOCAL MAX_RUNNING 10

RUNPATH poly_out/realization-<IENS>/iter-<ITER>

REALIZATION_MEMORY 50mb

NUM_REALIZATIONS 10
MIN_REALIZATIONS 1

GEN_DATA POLY_RES RESULT_FILE:poly.out

DESIGN_MATRIX poly_design.xlsx DESIGN_SHEET:DesignSheet01 DEFAULT_SHEET:DefaultSheet

INSTALL_JOB poly_eval POLY_EVAL
FORWARD_MODEL poly_eval
Binary file added test-data/ert/poly_design/poly_design.xlsx
Binary file not shown.
18 changes: 18 additions & 0 deletions test-data/ert/poly_design/poly_eval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import json


def _load_coeffs(filename):
with open(filename, encoding="utf-8") as f:
return json.load(f)["DESIGN_MATRIX"]


def _evaluate(coeffs, x):
return coeffs["a"] * x**2 + coeffs["b"] * x + coeffs["c"]


if __name__ == "__main__":
coeffs = _load_coeffs("parameters.json")
output = [_evaluate(coeffs, x) for x in range(10)]
with open("poly.out", "w", encoding="utf-8") as f:
f.write("\n".join(map(str, output)))

0 comments on commit 403b2fa

Please sign in to comment.