Skip to content

Commit d1a2b64

Browse files
author
Krishnateja
committed
The lazierthanlazygreedy optimizer has been updated to accept two types 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.
1 parent 6377a35 commit d1a2b64

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

cpp/optimizers/LazierThanLazyGreedyOptimizer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ std::vector<std::pair<ll, double>> LazierThanLazyGreedyOptimizer::maximize(
195195
float rem_budget = budget;
196196
std::unordered_set<ll> remainingSet = f_obj.getEffectiveGroundSet();
197197
ll n = remainingSet.size();
198-
ll randomSetSize = ((double)n / budget) * log(1 / epsilon);
198+
ll randomSetSize = static_cast<ll>(epsilon);
199+
if (epsilon < 1) {
200+
randomSetSize = static_cast<ll>(((double)n / budget) * log(1 / epsilon));
201+
}
199202

200203
if (verbose) {
201204
std::cout << "Epsilon = " << epsilon << "\n";

cpp/optimizers/StochasticGreedyOptimizer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ std::vector<std::pair<ll, double>> StochasticGreedyOptimizer::maximize(SetFuncti
3131
float rem_budget = budget;
3232
std::unordered_set<ll> remainingSet = f_obj.getEffectiveGroundSet();
3333
ll n = remainingSet.size();
34-
ll randomSetSize = ((double)n/budget)* log(1/epsilon);
34+
ll randomSetSize = epsilon;
35+
if (epsilon < 1) {
36+
randomSetSize = static_cast<ll>(((double)n / budget) * log(1 / epsilon));
37+
}
3538

3639
if (verbose) {
3740
std::cout << "Epsilon = " << epsilon << "\n";

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#this file is needed for doc building by readthedocs.org
22
sphinxcontrib-bibtex
33
pybind11>=2.6.0
4-
numpy==1.22.0
4+
numpy
55
scipy
66
scikit-learn

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
# "tqdm >= 4.24.0",
9494
# "nose"
9595
# ],
96-
install_requires=["numpy==1.22.0", "scipy", "scikit-learn", "numba"],
96+
install_requires=["numpy>=1.22.0", "scipy", "scikit-learn", "numba"],
9797
#setup_requires=['pybind11','pytest-runner'],
9898
tests_require=['pytest'],
9999
#extras_require={"test": "pytest"},

0 commit comments

Comments
 (0)