ellpy package

Subpackages

Submodules

ellpy.cutting_plane module

class ellpy.cutting_plane.CInfo(feasible: bool, num_iters: int, status: CUTStatus)[source]

Bases: object

class ellpy.cutting_plane.CUTStatus(value)[source]

Bases: Enum

An enumeration.

noeffect = 3
nosoln = 1
smallenough = 2
success = 0
class ellpy.cutting_plane.Options[source]

Bases: object

max_it: int = 2000
tol: float = 1e-08
ellpy.cutting_plane.bsearch(Omega: ~typing.Callable[[~typing.Any], bool], Interval: ~typing.Tuple, options=<ellpy.cutting_plane.Options object>) Tuple[Any, CInfo][source]

[summary]

Parameters
  • Omega ([type]) – [description]

  • I ([type]) – interval (initial search space)

Keyword Arguments

options ([type]) – [description] (default: {Options()})

Returns

[description]

Return type

[type]

class ellpy.cutting_plane.bsearch_adaptor(P, S, options=<ellpy.cutting_plane.Options object>)[source]

Bases: object

property x_best

[summary]

Returns

[description]

Return type

[type]

ellpy.cutting_plane.cutting_plane_dc(Omega: ~typing.Callable[[~typing.Any, ~typing.Any], ~typing.Any], S, t, options=<ellpy.cutting_plane.Options object>) Tuple[Any, Any, CInfo][source]

Cutting-plane method for solving convex optimization problem

Parameters
  • Omega ([type]) – perform assessment on x0

  • S ([type]) – Search Space containing x*

  • t (float) – initial best-so-far value

Keyword Arguments

options ([type]) – [description] (default: {Options()})

Returns

solution vector t: final best-so-far value ret {CInfo}

Return type

x_best (Any)

ellpy.cutting_plane.cutting_plane_feas(Omega: ~typing.Callable[[~typing.Any], ~typing.Any], S, options=<ellpy.cutting_plane.Options object>) CInfo[source]

Find a point in a convex set (defined through a cutting-plane oracle).

Description:

A function f(x) is convex if there always exist a g(x) such that f(z) >= f(x) + g(x)’ * (z - x), forall z, x in dom f. Note that dom f does not need to be a convex set in our definition. The affine function g’ (x - xc) + beta is called a cutting-plane, or a ``cut’’ for short. This algorithm solves the following feasibility problem:

find x s.t. f(x) <= 0,

A separation oracle asserts that an evalution point x0 is feasible, or provide a cut that separates the feasible region and x0.

Parameters
  • Omega ([type]) – perform assessment on x0

  • S ([type]) – Initial search space known to contain x*

Keyword Arguments

options ([type]) – [description] (default: {Options()})

Returns

solution vector niter: number of iterations performed

Return type

x

ellpy.cutting_plane.cutting_plane_q(Omega, S, t, options=<ellpy.cutting_plane.Options object>)[source]

Cutting-plane method for solving convex discrete optimization problem

Parameters
  • Omega ([type]) – perform assessment on x0

  • S ([type]) – Search Space containing x*

  • t (float) – initial best-so-far value

Keyword Arguments

options ([type]) – [description] (default: {Options()})

Returns

solution vector t (float): best-so-far optimal value niter ([type]): number of iterations performed

Return type

x_best (float)

ellpy.ell module

ellpy.problem module

class ellpy.problem.Problem(S, oracle, options=<ellpy.cutting_plane.Options object>)[source]

Bases: object

property optim_value

The optimal value from the last time the problem was solved.

Return type

float or None

property optim_var

The optimal value from the last time the problem was solved.

Return type

x_best or None

solve(*args, **kwargs)[source]

Solves the problem using the specified method.

Parameters
  • method (function) – The solve method to use.

  • solver (str, optional) – The solver to use.

  • verbose (bool, optional) – Overrides the default of hiding solver output.

  • solver_specific_opts (dict, optional) – A dict of options that will be passed to the specific solver. In general, these options will override any default settings imposed by cvxpy.

Returns

The optimal value for the problem, or a string indicating why the problem could not be solved.

Return type

float

property solver_stats

Returns an object containing additional information returned by the solver.

property status

The status from the last time the problem was solved.

Return type

str

class ellpy.problem.SolverStats(solver_name)[source]

Bases: object

Reports some of the miscellaneous information that is returned by the solver after solving but that is not captured directly by the Problem instance.

num_iters

The number of iterations the solver had to go through to find a solution.

Type

int

ellpy.skeleton module

This is a skeleton file that can serve as a starting point for a Python console script. To run this script uncomment the following lines in the [options.entry_points] section in setup.cfg:

console_scripts =
     fibonacci = ellpy.skeleton:run

Then run pip install . (or pip install -e . for editable mode) which will install the command fibonacci inside your current environment.

Besides console scripts, the header (i.e. until _logger…) of this file can also be used as template for Python modules.

Note

This skeleton file can be safely removed if not needed!

References

ellpy.skeleton.fib(n)[source]

Fibonacci example function

Parameters

n (int) – integer

Returns

n-th Fibonacci number

Return type

int

ellpy.skeleton.main(args)[source]

Wrapper allowing fib() to be called with string arguments in a CLI fashion

Instead of returning the value from fib(), it prints the result to the stdout in a nicely formatted message.

Parameters

args (List[str]) – command line parameters as list of strings (for example ["--verbose", "42"]).

ellpy.skeleton.parse_args(args)[source]

Parse command line parameters

Parameters

args (List[str]) – command line parameters as list of strings (for example ["--help"]).

Returns

command line parameters namespace

Return type

argparse.Namespace

ellpy.skeleton.run()[source]

Calls main() passing the CLI arguments extracted from sys.argv

This function can be used as entry point to create console scripts with setuptools.

ellpy.skeleton.setup_logging(loglevel)[source]

Setup basic logging

Parameters

loglevel (int) – minimum loglevel for emitting messages

Module contents