Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Aero-Spec authored Sep 22, 2024
1 parent c7035e0 commit 5bb9e7c
Showing 1 changed file with 8 additions and 54 deletions.
62 changes: 8 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,7 @@
**DividedRectangles.jl** provides an implementation of the DIRECT (DIvided RECTangles) [algorithm for global optimization](https://scholar.google.com/scholar?hl=en&as_sdt=0%2C5&q=Lipschitzian+optimization+without+the+Lipschitz+constant&btnG=). The DIRECT algorithm is particularly useful for optimizing functions where the Lipschitz constant is unknown. This package allows users to perform both univariate and multivariate optimization efficiently.

---

Example Objective Function:
As an example of an objective function, consider:

```julia
f(x) = dot(coeffs, x)
```
where:
- `x`: represents the variables.
- `coeffs`: represents the coefficients corresponding to each variable.

This is just one possible objective function that could be optimized using the DIRECT algorithm. The algorithm works by dividing the search space into smaller rectangles and evaluating the function at specific points within these rectangles to find the optimal solution.
![page_11](https://github.com/user-attachments/assets/b833bedd-41aa-40c5-a27f-26188a171797)

---

Expand All @@ -36,29 +25,31 @@ using Pkg
Pkg.add(url="https://github.com/sisl/DividedRectangles.jl")

```
# Usage
# Usage

To use the `DividedRectangles` module, start your code with:

```julia
using DividedRectangles
```
---

## Core Functions

### `optimize`
The `optimize` function is the primary function of the `DividedRectangles` module. It implements the DIRECT algorithm to find the minimum of a given objective function within specified bounds.

To use the `optimize` function with a custom mathematical function:
To use the `optimize` function with a custom objective function::

```julia
using DividedRectangles

# Define the objective function
f(x) = dot([1.0, 2.0, 3.0], x) # Example objective function with coefficients
f(x) = x[1]^2 + x[2]^2 + 3 * sin(5 * x[1]) + 2 * cos(3 * x[2]) # Multivariate example

# Set the search bounds
a = [0.0, 0.0, 0.0]
b = [1.0, 1.0, 1.0]
a = [-2.0, -2.0]
b = [2.0, 2.0]

# Call the optimization function
result = optimize(f, a, b)
Expand All @@ -78,43 +69,6 @@ println("Best design found: ", result)
- The best design 𝑥 found by DIRECT.
---

### Example: Multivariate Optimization

The following example shows how to optimize a multivariate function using the DIRECT algorithm:

```julia
using DividedRectangles

# Define the objective function
f(x) = x[1]^2 + x[2]^2 + 3 * sin(5 * x[1]) + 2 * cos(3 * x[2])

# Set the search bounds
a = [-2.0, -2.0]
b = [2.0, 2.0]

# Optimize
result = DividedRectangles.optimize(f, a, b)

println("Best design found: ", result)
```

### Parameters
- `f`: This is the objective function to minimize. Should be an operation that accepts a vector of Float64 values.
- `a`: Vector representing the lower bounds of the search space.
- `b`: Vector representing the upper bounds of the search space.
- `max_iterations`: Maximum number of iterations for the optimization (default: 100).
- `min_radius`: Minimum size of hyper-rectangles (`default: 1e-5`).

## Advanced Usage
### Fine-Tuning Optimization:
The `optimize` function offers several parameters for fine-tuning the optimization process:

- `max_iterations`: Sets the maximum number of iterations. Increasing this value can improve accuracy but requires more computational time.
- `min_radius`: Specifies the minimum size of hyper-rectangles to control the granularity of the search.

```julia
result = DividedRectangles.optimize(f, a, b, max_iterations=500, min_radius=1e-6)
```
## Credits

Contributors to this package include Anshrin Srivastava, Mykel Kochenderfer, Dylan Asmar, and Tim Wheeler.

0 comments on commit 5bb9e7c

Please sign in to comment.