A package implementing DFNDFL, an algorithm that solves mixed-integer nonsmooth constrained optimization problems whose constraint functions are avaliable only as the oytput of a black-box zeroth-order oracle.
Project description
DFNDFL Python Package
The DFNDFL Python package provides tools for solving Direct Function Optimization (DFO) problems. The package allows users to define custom optimization problems and solve them using the algorithms DFNDFL or DFL.
Installation
The package can be installed with pip:
python3 -m pip install dfndfl
Usage
Problem definition
To use the DFNDFL package, first define an optimization problem in a Python file. The problem file should define the following variables:
name
: string - name of the problemstartp
: numpy array - the starting point for the continuous problemlb
: numpy array - the lower bounds of the continuous problemub
: numpy array - the upper bounds of the continuous problemnint
: int - the number of discrete variables (>= 2)ncont
: int - the number of continuous variables (>= 2), (the variables are so intended: x[0] ... x[ncont-1] are the continuous variables and x[ncont] ... x[n-1] are the discrete variables)lbmix
: numpy array - the actual lower bounds of the mixed integer problemubmix
: numpy array - the actual upper bounds of the mixed integer problemx_initial
: numpy array - the actual initial point of the mixed integer problemxmix
: numpy array - a temporary array used for computationvfeval
: function handle - function to compute the objective function value (N.B. the point must be reconstructed through the use of reconstruct_xmix before calling feval)
Here's a sample problem definition:
import numpy as np
name = 'MISO prob. 10'
nint = 30
ncont = n-nint
lb =-15.0*np.ones(n)
ub = 30.0*np.ones(n)
lbmix =-15.0*np.ones(n)
ubmix = 30.0*np.ones(n)
startp = 7.0*np.ones(n)
x_initial =7.0*np.ones(n)
xmix = np.zeros(n)
def feval(x):
f = - 20*np.exp(-0.2*np.sqrt(np.sum(x**2)/15)) - np.exp(np.sum(np.cos(2*np.pi*x))/15)
return f
Running a problem
To run a problem from the command line, use:
python3 -m dfndfl.run --problem-path path/to/your/problem.py [options]
Command-Line Arguments
The run.py
script accepts several command-line arguments to control the optimization process:
usage: run --problem-path PROBLEM_PATH [-h] [--constrained] [--alg {DFN_DFL,DFL}] [--max_fun MAX_FUN]
[--outlev OUTLEV] [-M NM_MEMORY]
--problem-path PROBLEM_PATH
Path to the Python file containing the problem definition
optional arguments:
-h, --help show this help message and exit
--constrained Solve constrained problems
--alg {DFN_DFL,DFL} Name of algorithm to be used
--max_fun MAX_FUN Maximum number of function evaluations
--outlev OUTLEV Output level
-M NM_MEMORY, --NM_memory NM_MEMORY
History size for nonmonotone linesearch
Logging
The DFNDFL package uses Python's logging
module to log results and progress. The log level is set to INFO
by default. You can adjust the log level by modifying the logging.basicConfig(level=logging.INFO)
line in run.py
.
License
This project is licensed under the GNU General Public License - see the LICENSE for details.
Useful links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dfndfl-1.0.0.tar.gz
.
File metadata
- Download URL: dfndfl-1.0.0.tar.gz
- Upload date:
- Size: 59.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf71e6982f93775bda9e93a14cf72c3e3465ae70c5c19b82194efbbc62bca659 |
|
MD5 | 06eaceee5519d288dfb23f46c7aa04b3 |
|
BLAKE2b-256 | d34ce78cdb2f28675a8761dfd49e2f845936833d0688aa19c8442c14f34d8e7b |
File details
Details for the file dfndfl-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: dfndfl-1.0.0-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4153989b62498a749cdfc2e35e27f8e77b4a65e52e8a4518f8b9945c5dc42600 |
|
MD5 | 956f7d1eaf0e64b706356ba9702bf6a5 |
|
BLAKE2b-256 | d98dc79974cabcd8875da4d2df144982a4e530396c9fc5c69df94eac17b0674e |