Comments (6)
Thank you for your check. You're right. Sorry for confusing you.
from optuna.
no problem. Is there any quick hacks I can do to get around this? I'm assuming this is showing up because constant_liar's implementation doesn't add any constraints during the period after ask() and before tell(). Does the fact that we don't have constraint values and it being "treated as a lower priority" actually cause a quantifiable difference in the optimization quality? If not, I'm happy to suppress this warning for now on my side.
from optuna.
Thank you for your bug report. I investigated the cause, and it will be fixed by #5298. In my understanding, it does not affect the optimization quality if you do not set infinity for constraint values.
from optuna.
Strangely, Trials 0-9 do not have any warnings
The first 10 trials use random sampler instead of TPESampler with a default argument . At least this behaviour is expected.
from optuna.
Thank you for reporting it. As a workaround, could you use trial.set_system_attr
rather than set_user_attr
?
import optuna
def objective(trial):
# Binh and Korn function with constraints.
x = trial.suggest_float("x", -15, 30)
y = trial.suggest_float("y", -15, 30)
# Constraints which are considered feasible if less than or equal to zero.
# The feasible region is basically the intersection of a circle centered at (x=5, y=0)
# and the complement to a circle centered at (x=8, y=-3).
c0 = (x - 5) ** 2 + y ** 2 - 25
c1 = -((x - 8) ** 2) - (y + 3) ** 2 + 7.7
# Store the constraints as user attributes so that they can be restored after optimization.
# trial.set_user_attr("constraint", (c0, c1))
trial.set_system_attr("constraint", (c0, c1))
v0 = 4 * x ** 2 + 4 * y ** 2
v1 = (x - 5) ** 2 + (y - 5) ** 2
return v0, v1
def constraints(trial):
# return trial.user_attrs["constraint"]
return trial.system_attrs["constraint"]
sampler = optuna.samplers.TPESampler(constraints_func=constraints, constant_liar=True)
study = optuna.create_study(
directions=["minimize", "minimize"],
sampler=sampler,
)
study.optimize(objective, n_trials=32, timeout=600)
Anyways, I think this should be fixed.
from optuna.
Hi @nzw0301 thanks for getting back to me so quickly. I think using system attrs doesn't work either:
import optuna
def objective(trial):
# Binh and Korn function with constraints.
x = trial.suggest_float("x", -15, 30)
y = trial.suggest_float("y", -15, 30)
# Constraints which are considered feasible if less than or equal to zero.
# The feasible region is basically the intersection of a circle centered at (x=5, y=0)
# and the complement to a circle centered at (x=8, y=-3).
c0 = (x - 5) ** 2 + y**2 - 25
c1 = -((x - 8) ** 2) - (y + 3) ** 2 + 7.7
# Store the constraints as user attributes so that they can be restored after optimization.
trial.set_system_attr("constraint", (c0, c1))
v0 = 4 * x**2 + 4 * y**2
v1 = (x - 5) ** 2 + (y - 5) ** 2
return v0, v1
def constraints(trial):
return trial.system_attrs["constraint"]
sampler = optuna.samplers.TPESampler(constraints_func=constraints, constant_liar=True)
study = optuna.create_study(
directions=["minimize", "minimize"],
sampler=sampler,
)
# distributed optimization
batch_size = 10
rounds = 20
for round_idx in range(rounds):
objs = []
trials = []
for batch_idx in range(batch_size):
trials.append((trial := study.ask()))
objs.append(objective(trial))
for obj, trial in zip(objs, trials):
study.tell(trial, obj)
Runs into the same problem. I don't think you can reproduce it if you use study.optimize
instead of this batch optimization approach
from optuna.
Related Issues (20)
- Custom Executor Support HOT 1
- The study.best_params belong to several functions. Is it possible to group params to indicate which function they belong to? HOT 2
- trial.suggest_float doesn't work properly. HOT 1
- while opptimizing hyperparameter with optuna I get stuck in first trial and the trial 0 is not terminated
- Optuna restrict to only to the first trial and display it as the best one HOT 1
- Cannot build the document on Mac HOT 1
- With very short heartbeat, not only trials may fail but also the whole process crushes
- TypeError if both storage and WilcoxonPruner are given to create_study HOT 4
- Why is optuna stressing my CPU instead of GPU when device is set to "cuda"?
- ModuleNotFoundError: No module named 'MySQLdb'
- Speed up `TPESampler` using approximation in standard normal related computation
- Unable to use Redis: AttributeError: 'JournalRedisStorage' object has no attribute 'create_new_study' HOT 2
- Conda package not updated HOT 3
- Specify the removing version on `convert_positional_args`
- GridSampler: Duplicates HOT 5
- Wrong testing in tests with minimum versions
- Any bugs when using NumPy v2.0.0 HOT 2
- Expand the type of `callbacks` in `optimize` to `Iterable` HOT 2
- Fix http links underscore HOT 2
- Why does ` CmaEsSampler` expect at least 2D continuous space?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from optuna.