Skip to content

Commit

Permalink
The lazierthanlazygreedy optimizer has been updated to accept two typ…
Browse files Browse the repository at this point in the history
…es of input for the random subset size:

An epsilon value between 0 and 1
A positive integer

The random subset size is determined as follows:

If epsilon is less than 1:
Random subset size = ((n / budget) * log(1 / epsilon))
Where:

n is the total number of elements
budget is the computational budget
log is the natural logarithm

If epsilon is 1 or greater:
The provided value is directly used as the random subset size

This update allows for more flexible control over the optimizer's behavior, allowing users to specify either a proportion (epsilon) or an exact size for the random subset.
  • Loading branch information
Krishnateja committed Sep 12, 2024
1 parent 6377a35 commit d1a2b64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cpp/optimizers/LazierThanLazyGreedyOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ std::vector<std::pair<ll, double>> LazierThanLazyGreedyOptimizer::maximize(
float rem_budget = budget;
std::unordered_set<ll> remainingSet = f_obj.getEffectiveGroundSet();
ll n = remainingSet.size();
ll randomSetSize = ((double)n / budget) * log(1 / epsilon);
ll randomSetSize = static_cast<ll>(epsilon);
if (epsilon < 1) {
randomSetSize = static_cast<ll>(((double)n / budget) * log(1 / epsilon));
}

if (verbose) {
std::cout << "Epsilon = " << epsilon << "\n";
Expand Down
5 changes: 4 additions & 1 deletion cpp/optimizers/StochasticGreedyOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ std::vector<std::pair<ll, double>> StochasticGreedyOptimizer::maximize(SetFuncti
float rem_budget = budget;
std::unordered_set<ll> remainingSet = f_obj.getEffectiveGroundSet();
ll n = remainingSet.size();
ll randomSetSize = ((double)n/budget)* log(1/epsilon);
ll randomSetSize = epsilon;
if (epsilon < 1) {
randomSetSize = static_cast<ll>(((double)n / budget) * log(1 / epsilon));
}

if (verbose) {
std::cout << "Epsilon = " << epsilon << "\n";
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#this file is needed for doc building by readthedocs.org
sphinxcontrib-bibtex
pybind11>=2.6.0
numpy==1.22.0
numpy
scipy
scikit-learn
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
# "tqdm >= 4.24.0",
# "nose"
# ],
install_requires=["numpy==1.22.0", "scipy", "scikit-learn", "numba"],
install_requires=["numpy>=1.22.0", "scipy", "scikit-learn", "numba"],
#setup_requires=['pybind11','pytest-runner'],
tests_require=['pytest'],
#extras_require={"test": "pytest"},
Expand Down

0 comments on commit d1a2b64

Please sign in to comment.