SkillAgentSearch skills...

PyOLHS

python code for Optimal LatinHyperCube Sampling algorithm

Install / Use

/learn @open2333/PyOLHS
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

pyOLHS


pyOLHS is a Python package that provides Optimal LatinHyperCube sampling.

The introduction of Algorithms is on my WeChat Official Account.

The Python version of the OLHS algorithm is less efficient. In the future, I will release an open-source C++ version optimized with openMP and TBB.

Additionally, I plan to update other multi-disciplinary optimization algorithms, such as Kriging models and other optimization algorithms like Bayesian Optimization.

Record

2024.6.21 更新了采样结果去重方法 unique=True进行去重

 bound = [[1, 6, 1], [2, 10, 2], [4, 100, 4]]
    a = OLHS(bound, 50, 20, initseed=1, optseed=1,unique=True)
    c = a.sampling()

Getting Started

discrete variable

bound = [[0, 1.0, 0.01], [0, 1.0, 0.01]]
#2024.1.4:initseed means to fix the origin lathin sampling result optseed means to fix the optimization method
#if you want to get the same optimization method , fix them both, 
a = OLHS(bound, 20, 100,initseed=1,optseed=1) 
#if you want to see different optimization result from the same origin latin result, only fix initseed
a = OLHS(bound, 20, 100,initseed=1)

c = a.sampling()
<img src="https://github.com/open2333/pyOLHS/assets/43056772/65a9ff70-8442-46c8-85bb-d8b2048bd433" width="500" height="400">

continuous variable

bound = [[0, 1.0,], [0, 1.0]]
a = OLHS(bound, 20, 1000,"center")
c = a.sampling()
<img src="https://github.com/open2333/pyOLHS/assets/43056772/39a1c425-0a24-4190-ab87-3042d31c4ceb" width="500" height="400">

Notes:I convert my C++ code into this Python version, but for some reason, the performance is not as good as the C++ version. Below are the results of the C++ execution.

olhs

<img src="https://github.com/open2333/pyOLHS/assets/43056772/fdbbc989-6e4b-4c98-a5c3-8223109cd4ff" width="600" height="400">

Release Note:

-2024.1.4 add random seed to both origin latin sampling and optimization algorithm

Communication

  • BiliBili: allenalexyan
  • Email:yanjz111@gmail.com
  • 微信公众号 <img src="https://github.com/open2333/pyOLHS/assets/43056772/bfe5eaed-8af3-4d3d-9473-a2fb763343f9" width="200" height="200">

References

Jin R, Chen W, Sudjianto A. An efficient algorithm for constructing optimal design of computer experiments[C]//International design engineering technical conferences and computers and information in engineering conference. 2003, 37009: 545-554.

License

PyOLHS has a BSD-style license, as found in the LICENSE file.

View on GitHub
GitHub Stars27
CategoryDevelopment
Updated15d ago
Forks0

Languages

Python

Security Score

90/100

Audited on Mar 25, 2026

No findings