Skip to content

ZIB-IOL/frankwolfe-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

frankwolfe-py

This package is a python wrapper for FrankWolfe.jl.

Installation

First, download the package frankwolfe-py.

Move to the root of the package and execute on a terminal the following command:

pip install .

Now you can use the FrankWolfe.jl functions with

from frankwolfepy import frankwolfe

and the wrapper of the objective function with

from frankwolfepy import wrapper

Usage

Because of compatibility issues between Python and Julia number types, each objective function must be wrapped if the algorithm is used with verbose=true.

In each file, import wrapper and wrap the objective function using:

f = wrapper.wrap_objective_function(f).

A simple example :

from frankwolfepy import frankwolfe
from frankwolfepy import wrapper
import numpy as np

def f(x): #objective function
    return np.linalg.norm(x)**2

f = wrapper.wrap_objective_function(f) #wrap the objective function

def grad(storage,x): #gradient computation
    for i in range(len(x)):
        storage[i] = x[i]

# Create the Linear Minimization Oracle
lmo_prob = frankwolfe.ProbabilitySimplexOracle(1)

# Compute first point
x0 = frankwolfe.compute_extreme_point(lmo_prob,np.zeros(5))

#Solve the optimisation problem using vanilla Frank-Wolfe algorithm
frankwolfe.frank_wolfe(
    f,
    grad,
    lmo_prob,
    x0,
    max_iteration=1000,
    line_search=frankwolfe.Agnostic(),
    verbose=True,
)

For documentation on FrankWolfe.jl: https://zib-iol.github.io/FrankWolfe.jl/dev/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages