### Import necessary libraries Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_pareto.ipynb Initial setup for the Pareto optimization example, including matplotlib and oapackage. ```python import matplotlib.pyplot as plt import numpy as np %matplotlib inline import oapackage ``` -------------------------------- ### Create example arrays Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oa_files.ipynb Generates a list containing two example arrays. ```python lst = [oapackage.exampleArray(32), oapackage.exampleArray(33)] print(lst) ``` ```text Output: [array_link: 18, 4, array_link: 18, 4] ``` -------------------------------- ### Build and install Python interface Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage-intro.rst Commands to compile and install the Python interface from source. ```console $ python setup.py build $ python setup.py install --user ``` -------------------------------- ### Create and display example array Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oapackage.ipynb Creates an example orthogonal array using oapackage.exampleArray(0) and displays it with showarray(). ```python array = oapackage.exampleArray(0) array.showarray() ``` ```text Output: array: 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 ``` -------------------------------- ### Show a specific example array with exampleArray(2, 1) and showarray() Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_designs.ipynb Selects the example array with index 2 and parameter 1, then displays it using the showarray() method. The output shows the array description and its 16 rows of 6 binary values. ```python al = oapackage.exampleArray(2, 1) al.showarray() ``` ```text Output: exampleArray 2: array 6 in OA(16, 2, 2^6) array: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 0 1 1 0 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 ``` -------------------------------- ### List example arrays with exampleArray(-1, 1) Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_designs.ipynb Retrieves a list of all available example arrays by calling exampleArray with index -1 and parameter 1. The output enumerates each example with its index and description, such as 'exampleArray 0: array in OA(8,2, 2^2)'. The last line indicates that no example array exists for index 55. ```python import oapackage al = oapackage.exampleArray(-1, 1) ``` ```text Output: exampleArray 0: array in OA(8,2, 2^2) exampleArray 1: array 3 in OA(16, 2, 2^5) exampleArray 2: array 6 in OA(16, 2, 2^6) exampleArray 3: array ? in OA(32, 3, 2^7) exampleArray 4: array 4 in OA(16, 2, 2^7) exampleArray 5: array 0 in OA(24, 2, 4 3 2^a) exampleArray 6: array in OA(4, 2, 2^a) exampleArray 7: array 0 in OA(4, 2, 2^a)? exampleArray 8: array in OA(40, 3, 2^7) exampleArray 9: array in A(40, 2^7), D-optimal exampleArray 10: array in OA(9, 3^3) exampleArray 11: D-optimal array in OA(44, 2^8) exampleArray 12: even-odd array OA(64, 2^13) exampleArray 13: array in OA(25, 2^5) exampleArray 14: design in D(28, 2^5), D-efficiency is low exampleArray 15: design in D(56, 2^10), D-efficiency is low exampleArray 16: array in OA(32, 2, 2^5) exampleArray 17: unique array in OA(64, 4, 2^7) exampleArray 18: conference matrix of size 16, 7 exampleArray 19: conference matrix of size 4, 3 exampleArray 20: first LMC-0 double conference matrix in DC(24,3) exampleArray 21: second LMC-0 double conference matrix in DC(16,4) exampleArray 22: LMC-0 double conference matrix in DC(32,4) exampleArray 23: LMC-0 double conference matrix in DC(32,6) exampleArray 24: design in OA(64, 3, 2^16) (even-odd) exampleArray 25: design in OA(64, 3, 2^16) (even-odd) exampleArray 26: design in OA(64, 3, 2^16) (even-odd) exampleArray 27: design in OA(64, 3, 2^16) (even-odd) exampleArray 28: conference design in C(4, 3) in LMC0 form exampleArray 29: conference design in C(4, 3) exampleArray 30: conference design in C(8,4) exampleArray 31: conference design in C(8,4) exampleArray 32: first double conference design in DC(18,4) exampleArray 33: second double conference design in DC(18,4) exampleArray 34: third double conference design in DC(18,4) exampleArray 35: first double conference design in DC(20,4) exampleArray 36: second double conference design in DC(20,4) exampleArray 37: third double conference design in DC(20,4) exampleArray 38: LMC0 conference design in C(30,3) exampleArray 39: first LMC0 conference design in C(8,6) exampleArray 40: first conference design in C(14, 5) exampleArray 41: second conference design in C(14, 5) exampleArray 42: third conference design in C(14, 5) exampleArray 43: 2x2 array with zeros and a singe value -1 exampleArray 44: D-optimal strength 3 ortogonal array in OA(40,3, 2^7) exampleArray 45: first conference design in C(20,8) exampleArray 46: second conference design in C(20,8) exampleArray 47: third conference design in C(20,8) exampleArray 48: last conference design in C(20,8) exampleArray 49: array 4347 C(20,8) exampleArray 50: array 4506 C(20,8) exampleArray 51: first array in C(12,4) exampleArray 52: second array in C(12,4) exampleArray 53: third array in C(12,4) exampleArray 54: root array in OA(6,2,3^1 2^1) exampleArray: no example array with index 55 exists ``` -------------------------------- ### Run extension algorithm Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Example of running the extension algorithm to generate designs. ```pycon >>> import oapackage >>> designs = oapackage.oahelper.runExtend(16, 5, 3, verbose=0) ``` -------------------------------- ### Calculate GWLP for another example array Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oapackage.ipynb Creates example array 11 and prints its generalized word length pattern using oahelper.gwlp2str. ```python array = oapackage.exampleArray(11) print(f"Generalized wordlength pattern: {oapackage.oahelper.gwlp2str(array.GWLP())}") ``` ```text Output: Generalized wordlength pattern: 1.00,0.02273,0.03926,0.5434,0.8244,2.217,1.043,0.126,0.002066 ``` -------------------------------- ### Plain text array file (.oa) example Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/data.rst Example of a plain text array file with extension .oa. The first line contains the number of columns, rows, and arrays (or -1 if unknown). Then for each array, a line with the array index followed by N lines of array data. This file contains exactly 1 array with 8 rows and 5 columns. ```c 5 8 1 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 1 1 0 1 0 -1 ``` -------------------------------- ### Install OApackage via pip Source: https://github.com/eendebakpt/oapackage/blob/dev/README.md Standard command to install the OApackage from the Python Package Index. ```console $ pip install OApackage ``` -------------------------------- ### Build and install C++ library and tools Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage-intro.rst Commands to build the command line utilities and C++ library using cmake. ```console $ mkdir -p build $ cd build $ cmake .. $ make $ make install ``` -------------------------------- ### Create and print an arrayclass object Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/tests.md Example from the autodoctest() docstring showing how to create an arrayclass object and print it. The output is shown as part of the example. ```pycon >>> import oapackage >>> arrayclass=oapackage.arraydata_t(2, 40, 0, 7) >>> print(arrayclass) arrayclass: N 40, k 7, strength 0, s {2,2,2,2,2,2,2}, order 0 ``` -------------------------------- ### oainfo command example Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/data.rst Shows the output of the oainfo command when run on a data file. The output reports the package version, the file being read, and the file's properties (rows, columns, arrays, mode, bits). ```console $ oainfo result-8.2-2-2-2.oa Orthogonal Array package 1.8.7 oainfo: reading 1 file(s) file result-8.2-2-2.oa: 8 rows, 3 columns, 2 arrays, mode text, nbits 0 $ ``` -------------------------------- ### Analyze an Orthogonal Array in Python Source: https://github.com/eendebakpt/oapackage/blob/dev/README.md Demonstrates how to import the oapackage, generate an example array, display it, and calculate its D-efficiency and generalized wordlength pattern. ```python >>> import oapackage >>> al=oapackage.exampleArray(0) >>> al.showarraycompact() 00 00 01 01 10 10 11 11 >>> print('D-efficiency %f, rank %d' % (al.Defficiency(), al.rank()) ) D-efficiency 1.000000, rank 2 >>> print('Generalized wordlength pattern: %s' % str(al.GWLP())) Generalized wordlength pattern: (1.0, 0.0, 0.0) ``` -------------------------------- ### Import numpy and oapackage Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_mixed_level_gwlp.ipynb Imports the required libraries for the example: numpy for array handling and oapackage for design generation and GWLP computation. ```python import numpy as np import oapackage ``` -------------------------------- ### Get help on reduceConference Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/conference_design_isomorphism.ipynb Displays the help documentation for the reduceConference function, which reduces a conference matrix to normal form using Nauty. ```python help(oapackage.reduceConference) ``` ```text Output: Help on function reduceConference in module oalib: reduceConference(arg1, verbose=0) reduceConference(array_link arg1, int verbose=0) -> array_link reduceConference(array_link arg1) -> array_link Reduce conference matrix to normal form using Nauty See also: reduceConferenceTransformation ``` -------------------------------- ### Reduce an example array to delete-one-factor projection form Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_delete_one_factor_projections.ipynb Loads an example orthogonal array with 16 runs and 7 factors, reduces it to delete-one-factor projection form using reduceDOPform, and displays the resulting array. ```python import oapackage al = oapackage.exampleArray(4) al = oapackage.reduceDOPform(al) al.showarray() ``` ```text Output: array: 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 1 1 0 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 ``` -------------------------------- ### Create root array for mixed-level arrays Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_design_generation.ipynb Creates the starting root array for the mixed-level enumeration and displays it compactly. ```python al = arrayclass.create_root() al.showarraycompact() ``` ```text Output: 00 00 01 01 10 10 11 11 20 20 21 21 30 30 31 31 ``` -------------------------------- ### Create root array for three-level arrays Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_design_generation.ipynb Creates the starting root array for the enumeration of three-level arrays using create_root() and displays it in compact format. ```python ll2 = [arrayclass.create_root()] ll2[0].showarraycompact() ``` ```text Output: 00 00 00 01 01 01 02 02 02 10 10 10 11 11 11 12 12 12 20 20 20 21 21 21 22 22 22 ``` -------------------------------- ### Print oapackage version Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oapackage.ipynb Imports oapackage and prints its version. Useful to verify installation and version compatibility. ```python import numpy as np import oapackage print(f"oapackage version: {oapackage.version()}") ``` ```text Output: oapackage version: 2.6.0 ``` -------------------------------- ### Build Python SWIG module with oalib Source: https://github.com/eendebakpt/oapackage/blob/dev/CMakeLists.txt Builds the Python SWIG module when BUILD_PYTHON_MODULE is enabled. Requires Python (with NumPy) and SWIG 4.0, sets SWIG flags for C++ and Doxygen, creates the oalib module, links Python::Module, Python::NumPy, ZLIB::ZLIB (if found), and the math library on non-Windows, and installs the resulting _oalib library and oalib.py for scikit-build-core. ```cmake if(BUILD_PYTHON_MODULE) find_package(Python REQUIRED COMPONENTS Interpreter Development.Module NumPy) find_package(SWIG 4.0 REQUIRED COMPONENTS python) message(STATUS "Python executable: ${Python_EXECUTABLE}") message(STATUS "Python include: ${Python_INCLUDE_DIRS}") message(STATUS "NumPy include: ${Python_NumPy_INCLUDE_DIRS}") message(STATUS "SWIG executable: ${SWIG_EXECUTABLE}") message(STATUS "SWIG version: ${SWIG_VERSION}") include(${SWIG_USE_FILE}) # Set SWIG properties set_property(SOURCE oalib.i PROPERTY CPLUSPLUS ON) set_property(SOURCE oalib.i PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON) # SWIG flags set(SWIG_MODULE_FLAGS -c++ -doxygen -w503,401,362,302,389,446,509,305 -DSWIGCODE -DFULLPACKAGE ) if(ZLIB_FOUND) list(APPEND SWIG_MODULE_FLAGS -DUSEZLIB) else() list(APPEND SWIG_MODULE_FLAGS -DNOZLIB) endif() if(WIN32) list(APPEND SWIG_MODULE_FLAGS -DWIN32 -D_WIN32) endif() list(APPEND SWIG_MODULE_FLAGS -DNOOMP) set_property(SOURCE oalib.i PROPERTY SWIG_FLAGS ${SWIG_MODULE_FLAGS}) # Create SWIG module swig_add_library(oalib TYPE MODULE LANGUAGE python SOURCES oalib.i ${OA_SOURCES} ${NAUTY_SOURCES} ) # Include directories target_include_directories(oalib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/nauty ${CMAKE_CURRENT_SOURCE_DIR}/src/Eigen ${Python_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS} ) # Compile definitions target_compile_definitions(oalib PRIVATE ${OA_COMPILE_DEFINITIONS} SWIGCODE NOOMP ) # Link libraries target_link_libraries(oalib PRIVATE Python::Module Python::NumPy) if(ZLIB_FOUND) target_link_libraries(oalib PRIVATE ZLIB::ZLIB) endif() if(NOT WIN32) target_link_libraries(oalib PRIVATE m) endif() # Set output name set_target_properties(oalib PROPERTIES OUTPUT_NAME "_oalib" PREFIX "" ) if(WIN32) set_target_properties(oalib PROPERTIES SUFFIX ".pyd") endif() # Install targets for scikit-build-core install(TARGETS oalib LIBRARY DESTINATION .) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/oalib.py DESTINATION .) endif() ``` -------------------------------- ### Calculate D-efficiency, rank, and GWLP Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oapackage.ipynb Calculates and prints the D-efficiency, rank, and generalized word length pattern (GWLP) of the example array. ```python print("D-efficiency %f, rank %d" % (array.Defficiency(), array.rank())) print(f"Generalized wordlength pattern: {str(array.GWLP())}") ``` ```text Output: D-efficiency 1.000000, rank 2 Generalized wordlength pattern: (1.0, 0.0, 0.0) ``` -------------------------------- ### oapackage.oahelper.mkdirc(directory_name: str) → str Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Create a directory. ```APIDOC ## oapackage.oahelper.mkdirc(directory_name: str) → str ### Description Create directory. ### Parameters - **directory_name** (str) - Required - Name of the directory to create. ### Returns - **str** - The directory name. ``` -------------------------------- ### Get help on Jcharacteristics_conference Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/conference_design_isomorphism.ipynb Displays the help documentation for the Jcharacteristics_conference function, which computes J-characteristics for conference designs. ```python help(oapackage.Jcharacteristics_conference) ``` ```text Output: Help on function Jcharacteristics_conference in module oalib: Jcharacteristics_conference(array, number_of_columns, verbose=0) Jcharacteristics_conference(array_link array, int number_of_columns, int verbose=0) -> intVector Jcharacteristics_conference(array_link array, int number_of_columns) -> intVector ``` -------------------------------- ### Create oaconfig.txt with runs, strength, and factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Creates a configuration file for the OA generation. The content specifies 24 runs, strength 2, and 7 factors with 2 levels each. ```text # First create oaconfig.txt with the following content: # # runs 24 # strength 2 # nfactors 7 #2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ``` -------------------------------- ### Convert orthogonal array to graph representation Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Example usage of the oa2graph function to convert an orthogonal array into a graph representation. ```python im, colors, r = oa2graph( A, oadata ); ``` -------------------------------- ### Import OAPackage and tempfile Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oa_files.ipynb Initializes the necessary modules for file handling and OAPackage operations. ```python import tempfile import oapackage ``` -------------------------------- ### Run oaextendsingle to generate initial designs Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle with level 2 and maxk 5 to generate orthogonal arrays. The output is stored in files matching 'oa*'. ```bash oaextendsingle -l 2 --maxk 5 ``` -------------------------------- ### oapackage.oahelper.findfilesR(directory: str, pattern) → list[str] Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Get a list of files recursively in a directory that match a pattern. ```APIDOC ## oapackage.oahelper.findfilesR(directory: str, pattern) → list[str] ### Description Get a list of files (recursive). ### Parameters - **directory** (str) - Required - Directory to search. - **pattern** (str) - Required - Pattern to match. ### Returns - **list[str]** - List of matched files. ``` -------------------------------- ### Build OApackage from Source Source: https://github.com/eendebakpt/oapackage/blob/dev/README.md Commands to compile the package using the cmake build system. ```bash $ mkdir -p build; cd build $ cmake .. $ make $ make install ``` -------------------------------- ### Extend selected designs to 7 factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle on selected6.oa to extend to maxk 7 with level 2, output in binary format. ```bash oaextendsingle -r selected6.oa --maxk 7 -l 2 -f B ``` -------------------------------- ### Extend subset to 8 factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle on selected7sub.oa to extend to maxk 8 with level 2, output in binary format. ```bash oaextendsingle -r selected7sub.oa --maxk 8 -l 2 -f B ``` -------------------------------- ### oapackage.oahelper.findfiles(directory: str, pattern: str | None = None) → list[str] Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Get a list of files in a given directory that match a pattern. ```APIDOC ## oapackage.oahelper.findfiles(directory: str, pattern: str | None = None) → list[str] ### Description Get a list of files. ### Parameters - **directory** (str) - Required - Directory to search. - **pattern** (str | None) - Optional - Pattern to match. Default is None. ### Returns - **list[str]** - List of matched files. ``` -------------------------------- ### oapackage.oahelper.guitest_monitorSizes() Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Test function for monitor sizes in GUI. ```APIDOC ## oapackage.oahelper.guitest_monitorSizes() ### Description Test function for monitor sizes in GUI. ### Parameters None ### Returns None ``` -------------------------------- ### oapackage.oahelper.finddirectories(directory: str, pattern: str | None = None) → list[str] Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Get a list of directories in a given directory that match a pattern. ```APIDOC ## oapackage.oahelper.finddirectories(directory: str, pattern: str | None = None) → list[str] ### Description Get a list of directories. ### Parameters - **directory** (str) - Required - Directory to search. - **pattern** (str | None) - Optional - Pattern to match. Default is None. ### Returns - **list[str]** - List of matched directories. ``` -------------------------------- ### Initialize conference design class Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_conference_designs.ipynb Load the oapackage library and define a conference design class with 12 rows and 6 columns. ```python import oapackage conference_class = oapackage.conference_t(12, 6, 0) print(conference_class) ``` -------------------------------- ### Extend mixed-level arrays to 3 and 4 columns Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_design_generation.ipynb Shows extending a list of arrays (starting with the root) to 3 columns and then to 4 columns, using extend_arraylist repeatedly. ```python array_list = [arrayclass.create_root()] array_list_3columns = oapackage.extend_arraylist(array_list, arrayclass) array_list_4columns = oapackage.extend_arraylist(array_list_3columns, arrayclass) print("extended to %d arrays with 3 columns" % len(array_list_3columns)) print("extended to %d arrays with 4 columns" % len(array_list_4columns)) ``` ```text Output: extended to 3 arrays with 3 columns extended to 10 arrays with 4 columns ``` -------------------------------- ### oapackage.oahelper.runExtend(N: int, k: int, t: int = 3, l: int = 2, verbose: int = 1, initsols=None, nums=[], algorithm=None) Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Run extension algorithm and return arrays. This function extends orthogonal arrays to a specified number of columns. ```APIDOC ## oapackage.oahelper.runExtend(N: int, k: int, t: int = 3, l: int = 2, verbose: int = 1, initsols=None, nums=[], algorithm=None) ### Description Run extension algorithm and return arrays. ### Parameters - **N** (int) - Required - Number of rows. - **k** (int) - Required - Number of columns to extend to. - **t** (int) - Optional - Strength of the arrays. Default is 3. - **l** (int) - Optional - Factors of the designs. Default is 2. - **verbose** (int) - Optional - Verbosity level. Default is 1. - **initsols** (None or list) - Optional - List of arrays to extend, None to start with root. - **nums** (list) - Optional - List of numbers. - **algorithm** - Optional - Algorithm to use. ### Returns - **list** - List of generated designs. ### Example ```pycon >>> import oapackage >>> designs = oapackage.oahelper.runExtend(16, 5, 3, verbose=0) ``` ``` -------------------------------- ### Extend list of three-level arrays column by column Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_design_generation.ipynb Uses extend_arraylist to add one column at a time. Starting from the root list, it extends to 9 arrays with 3 columns and then to 711 arrays with 4 columns. ```python list3columns = oapackage.extend_arraylist(ll2, arrayclass) print("extended to %d arrays with 3 columns" % len(list3columns)) list4columns = oapackage.extend_arraylist(list3columns, arrayclass) print("extended to %d arrays with 4 columns" % len(list4columns)) ``` ```text Output: extended to 9 arrays with 3 columns extended to 711 arrays with 4 columns ``` -------------------------------- ### oapackage.oahelper.choose(n, k) Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Returns n choose k. ```APIDOC ## oapackage.oahelper.choose(n: int, k: int) → int ### Description Return n choose k. ### Parameters - **n** (int) - Required - Total number of items. - **k** (int) - Required - Number of items to choose. ### Returns - int - The binomial coefficient. ``` -------------------------------- ### Index array_link with slicing Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oapackage.ipynb Shows that array_link objects can be indexed like normal arrays. The first example returns a new array_link of shape 5x1, the second displays the sliced subarray, and the third prints a single element. ```python array[0:5, 2:3] ``` ```text Result: array_link: 5, 1 ``` ```python array[0:5, 2:4].showarray() ``` ```text Output: array: 1 1 0 1 1 0 0 0 1 1 ``` ```python print(array[0, 2]) ``` ```text Output: 1 ``` -------------------------------- ### Import libraries for orthogonal array generation Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_optimal_orthogonal_arrays.ipynb Imports the required libraries for the example: matplotlib for plotting, numpy for numerical operations, and oapackage for orthogonal array generation. The %matplotlib inline magic command ensures plots are displayed inline in the notebook. ```python import matplotlib.pyplot as plt import numpy as np import oapackage %matplotlib inline ``` -------------------------------- ### Display file information Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_oa_files.ipynb Uses oapackage.oainfo to retrieve and display metadata about the created file. ```python oapackage.oainfo(filename) ``` ```text Output: file C:\Users\EENDEB~1\AppData\Local\Temp\tmpxc4dnsl6.oa: 18 rows, 4 columns, 2 arrays, mode text, nbits 0 ``` -------------------------------- ### Extend selected10 to 11 factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle on selected10.oa to extend to maxk 11 with level 2, output in binary format. ```bash # extend oaextendsingle -r selected10.oa --maxk 11 -l 2 -f B ``` -------------------------------- ### Show information about generated OA files Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Displays information about all files matching the pattern 'oa*'. ```bash oainfo *oa* ``` -------------------------------- ### Extend selected designs to 6 factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle on selected5.oa to extend to maxk 6 with level 2. ```bash # extend oaextendsingle -r selected5.oa --maxk 6 -l 2 ``` -------------------------------- ### Extend subset to 9 factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle on selected8sub.oa to extend to maxk 9 with level 2, output in binary format. ```bash # extend oaextendsingle -r selected8sub.oa --maxk 9 -l 2 -f B ``` -------------------------------- ### oapackage.oahelper.tilefigs(lst, geometry, ww=None, raisewindows=False, tofront=False, verbose=0) Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Tiles figure windows on a specified area. ```APIDOC ## oapackage.oahelper.tilefigs(lst, geometry, ww=None, raisewindows=False, tofront=False, verbose=0) ### Description Tiles figure windows on a specified area. ### Parameters - **lst** - Required - List of figures. - **geometry** - Required - Geometry specification. - **ww** - Optional - Window width. - **raisewindows** (bool) - Optional - Whether to raise windows. - **tofront** (bool) - Optional - Whether to bring to front. - **verbose** (int) - Optional - Verbosity level. ### Returns - **None** ``` -------------------------------- ### Generate and plot random input data Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_pareto.ipynb Create a dataset of 50 random vectors with two objectives and visualize them. ```python datapoints = np.random.rand(2, 50) for ii in range(0, datapoints.shape[1]): w = datapoints[:, ii] fac = 0.6 + 0.4 * np.linalg.norm(w) datapoints[:, ii] = (1 / fac) * w h = plt.plot(datapoints[0, :], datapoints[1, :], ".b", markersize=16, label="Non Pareto-optimal") _ = plt.title("The input data", fontsize=15) plt.xlabel("Objective 1", fontsize=16) plt.ylabel("Objective 2", fontsize=16) ``` -------------------------------- ### Extend selected9 to 10 factors Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/oaselect/exampleselect.txt Runs oaextendsingle on selected9.oa to extend to maxk 10 with level 2, output in binary format. ```bash # extend oaextendsingle -r selected9.oa --maxk 10 -l 2 -f B ``` -------------------------------- ### Generate D-efficient designs with alpha=(1,2,0) Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/examples/example_generation_optimal_designs.ipynb Calls oapackage.Doptim.Doptimize with nrestarts=30, optimfunc=[1,2,0], and selectpareto=True. The output shows the optimization progress and the number of designs generated. ```python alpha = [1, 2, 0] scores, design_efficiencies, designs, ngenerated = oapackage.Doptim.Doptimize( arrayclass, nrestarts=30, optimfunc=alpha, selectpareto=True ) ``` -------------------------------- ### oapackage.oahelper.runcommand(cmd: str, dryrun=0, idstr: str | None = None, verbose: int = 1, logfile: str | None = None, shell: bool = True) Source: https://github.com/eendebakpt/oapackage/blob/dev/docs/oapackage.md Run specified command in external environment. ```APIDOC ## oapackage.oahelper.runcommand(cmd: str, dryrun=0, idstr: str | None = None, verbose: int = 1, logfile: str | None = None, shell: bool = True) ### Description Run specified command in external environment. ### Parameters - **cmd** (str) - Required - Command to execute. - **dryrun** (int) - Optional - If non-zero, do not actually run the command. Default is 0. - **idstr** (str | None) - Optional - Identifier string. - **verbose** (int) - Optional - Verbosity level. Default is 1. - **logfile** (str | None) - Optional - Log file path. - **shell** (bool) - Optional - Whether to run in shell. Default is True. ### Returns - **int** - Return value of the shell command. ``` -------------------------------- ### Build executables with oalib_static and precompiled headers Source: https://github.com/eendebakpt/oapackage/blob/dev/CMakeLists.txt Conditionally builds command-line executables when BUILD_EXECUTABLES is enabled. Creates a static library oalib_static from OA_EXEC_SOURCES and Nauty sources, links ZLIB and math library on non-Windows, then compiles each program in PROGS if its source exists in utils/. Also builds oaextendsingle with OAEXTEND_SINGLECORE and NEWINTERFACE definitions. ```cmake if(BUILD_EXECUTABLES) # Additional sources for executables set(OA_EXEC_SOURCES ${OA_SOURCES} src/anyoption.cpp src/InfInt.cpp src/depth_extend.cpp ) # Static library for executables add_library(oalib_static STATIC ${OA_EXEC_SOURCES} ${NAUTY_SOURCES}) target_include_directories(oalib_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/nauty ) target_compile_definitions(oalib_static PUBLIC ${OA_COMPILE_DEFINITIONS}) if(ZLIB_FOUND) target_link_libraries(oalib_static PUBLIC ZLIB::ZLIB) endif() if(NOT WIN32) target_link_libraries(oalib_static PUBLIC m) endif() # List of executables set(PROGS oacat oajoin oapareto oasplit oaanalyse oainfo oaunittest oaconvert oafilter oareduceDOP pareto_example oaconference oaconfcheck oacheck oastreaming oaranktest oatest oaclustergather oa_depth_extend oa_select_maxj ) foreach(prog ${PROGS}) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/utils/${prog}.cpp") add_executable(${prog} utils/${prog}.cpp) target_link_libraries(${prog} PRIVATE oalib_static) target_precompile_headers(${prog} PRIVATE src/arraytools.h ) message(STATUS "Adding executable: ${prog}") endif() endforeach() # oaextendsingle if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/utils/oaextend.cpp") add_executable(oaextendsingle utils/oaextend.cpp) target_link_libraries(oaextendsingle PRIVATE oalib_static) target_compile_definitions(oaextendsingle PRIVATE OAEXTEND_SINGLECORE NEWINTERFACE) message(STATUS "Adding executable: oaextendsingle") endif() endif() ```