Skip to content

Commit

Permalink
Update usage.md - Made Tim's requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aero-Spec authored Sep 22, 2024
1 parent 7696b8a commit ecccbc4
Showing 1 changed file with 4 additions and 45 deletions.
49 changes: 4 additions & 45 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ 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 @@ -42,43 +41,3 @@ println("Best design found: ", result)
**Returns:**
- 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)
```

0 comments on commit ecccbc4

Please sign in to comment.