mc doc
This commit is contained in:
parent
d960ccd007
commit
2b64516ad1
6 changed files with 0 additions and 0 deletions
34
docs/examples.rst
Normal file
34
docs/examples.rst
Normal file
|
@ -0,0 +1,34 @@
|
|||
Examples
|
||||
========
|
||||
|
||||
Basic Optimization
|
||||
------------------
|
||||
|
||||
Here's a simple example using Optifik to solve a quadratic function.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from optifik import minimize
|
||||
|
||||
def quadratic(x):
|
||||
return (x - 3) ** 2
|
||||
|
||||
result = minimize(quadratic, x0=0)
|
||||
print(result)
|
||||
|
||||
Constrained Optimization
|
||||
------------------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from optifik import minimize
|
||||
|
||||
def objective(x):
|
||||
return x[0] ** 2 + x[1] ** 2
|
||||
|
||||
def constraint(x):
|
||||
return x[0] + x[1] - 1
|
||||
|
||||
result = minimize(objective, x0=[0, 0], constraints=[constraint])
|
||||
print(result)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue