From 9c90dabf7aaabbfe9380be18cbbe933fe4b01b6d Mon Sep 17 00:00:00 2001 From: Wai-Shing Luk Date: Fri, 11 Oct 2024 11:06:51 +0800 Subject: [PATCH] minor change --- notes.md | 12 ++++++++++++ src/ellalgo/cutting_plane.py | 25 +++++++++++++++++++++++++ src/ellalgo/oracles/lmi_oracle.py | 4 ++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/notes.md b/notes.md index ae513b7..1a1312c 100644 --- a/notes.md +++ b/notes.md @@ -1,5 +1,17 @@ ## Cutting Plane Feasibility Algorithm +```python +def cutting_plane_feas(omega, space, options=Options()): + for niter in range(options.max_iters): + cut = omega.assess_feas(space.xc()) # query the oracle at space.xc() + if cut is None: # feasible solution obtained + return space.xc(), niter + status = space.update_bias_cut(cut) # update space + if status != CutStatus.Success or space.tsq() < options.tolerance: + return None, niter + return None, options.max_iters +``` + This code defines a function called cutting_plane_feas which implements a cutting plane algorithm for finding a feasible point in a convex set. The purpose of this algorithm is to solve a feasibility problem, which means finding a point that satisfies certain constraints. The function takes three inputs: diff --git a/src/ellalgo/cutting_plane.py b/src/ellalgo/cutting_plane.py index dc62d9a..77c372a 100644 --- a/src/ellalgo/cutting_plane.py +++ b/src/ellalgo/cutting_plane.py @@ -1,3 +1,28 @@ +""" +Cutting Plane Algorithm Implementation + +This code implements various cutting plane algorithms, which are optimization techniques used to solve convex optimization problems. The main purpose of these algorithms is to find optimal or feasible solutions within a given search space. + +The code defines several functions that take different inputs: + +1. cutting_plane_feas: Takes an oracle (a function that assesses feasibility), a search space, and options. +2. cutting_plane_optim: Takes an optimization oracle, a search space, an initial best value (gamma), and options. +3. cutting_plane_optim_q: Similar to cutting_plane_optim, but for quantized discrete optimization problems. +4. bsearch: Performs a binary search using an oracle and an interval. + +These functions generally output a solution (if found), the best value achieved, and the number of iterations performed. + +The algorithms work by iteratively refining the search space. They start with an initial point and ask the oracle to assess it. The oracle either confirms the point is feasible/optimal or provides a "cut" - information about how to improve the solution. The search space is then updated based on this cut, and the process repeats until a solution is found or the maximum number of iterations is reached. + +An important concept in these algorithms is the "cut". A cut is like a hint that tells the algorithm which parts of the search space to exclude, helping it focus on more promising areas. The search space is continuously shrunk based on these cuts until a solution is found or the space becomes too small. + +The code also includes a BSearchAdaptor class, which adapts a feasibility oracle to work with the binary search algorithm. This allows the binary search to be used in solving certain types of optimization problems. + +Throughout the code, there's a focus on handling different types of problems (feasibility, optimization, discrete optimization) and different types of search spaces. The algorithms are designed to be flexible and work with various problem types. + +In summary, this code provides a toolkit for solving different types of optimization problems using cutting plane methods. It's designed to be adaptable to various problem types and to efficiently search for solutions by iteratively refining the search space based on feedback from problem-specific oracles. +""" + import copy from typing import Any, MutableSequence, Optional, Tuple, Union diff --git a/src/ellalgo/oracles/lmi_oracle.py b/src/ellalgo/oracles/lmi_oracle.py index 9f3f2be..e1b0a05 100644 --- a/src/ellalgo/oracles/lmi_oracle.py +++ b/src/ellalgo/oracles/lmi_oracle.py @@ -31,8 +31,8 @@ class LMIOracle(OracleFeas): This oracle solves the following feasibility problem: - find x - s.t. (B − F * x) ⪰ 0 + | find x + | s.t. (B − F * x) ⪰ 0 """