Closed Fa20 closed 20 hours ago
Hi @Fa20, your code is missing definitions for setup_experiment()
and evaluate_parameters()
, so I had to guess a little. For me, it works. You may have gotten this error by running your code twice, in which case on
ax_client.complete_trial(trial_index=i, raw_data=result)
i
is a list index, say 0. But if there already were 20 trials on the experiment, you're trying to complete trial 0 when you should be trying to complete trial 20. Trial 0 is probably already completed, so this error being raised to save you from silent failures/bad results. You could either fix this by making sure the experiment is clean at the beginning, or by changing
ax_client.attach_trial(parameters=trial_params)
result = evaluate_parameters(trial_params)
ax_client.complete_trial(trial_index=i, raw_data=result)
to
params, trial_index = ax_client.attach_trial(parameters=trial_params)
result = evaluate_parameters(trial_params)
ax_client.complete_trial(trial_index= trial_index, raw_data=result)
like in the loop below. Probably you just want to make sure you start with a clean experiment though.
If this isn't it, please fix your minimal repro and I'll be happy to look again. Your minimal repro should include imports and all, with any private information substituted, so that I can copy and paste it into my own notebook and click run without any modification and see the error (or general problem) you're having.
@danielcohenlive thanks for your answer.No I do not want clean and start from the beginning the problem that I need to evaluate the objective functions by simulation which need to keep the Ax code running till to get the result from the simulation and I thought that I can avoid this by stop run the code till the simulation is finished and attach the parmas . Is there in Ax better way to solve this problem in case that I do not want to keep the code running till get the result from Simulation?
Is there in Ax better way to solve this problem in case that I do not want to keep the code running till get the result from Simulation?
@Fa20 could you clarify what you mean by not wanting to keep the code running... If you're talking about running a human in the loop experiment see https://ax.dev/tutorials/human_in_the_loop/human_in_the_loop.html. It's not written in AxClient though, so you'll have to cross reference with the service API tutorial.
@danielcohenlive I mean when we run the Loop start the Generation step then evaluate the objective with this values of parameters. In my case I do not have this value of objective functions and I should calculate it Numerical which need some time and the Ax Code should wait till to get this value and then go to the next step .is there any way to that after the first Generation step that we can step excuted the code till the calculation of objective finished and then run it again but this time the step of evaluate the objective can be excuted
@danielcohenlive I mean when we run the Loop start the Generation step then evaluate the objective with this values of parameters. In my case I do not have this value of objective functions and I should calculate it Numerical which need some time and the Ax Code should wait till to get this value and then go to the next step .is there any way to that after the first Generation step that we can step excuted the code till the calculation of objective finished and then run it again but this time the step of evaluate the objective can be excuted
Hi @Fa20, again drive-by commenting, but maybe you can:
for i in range(num_trials):
parameterization, trial_index = ax_client.get_next_trial()
# extract parameters
p1 = parameterization["Polymer1"]
p2 = parameterization["Polymer2"]
# Save suggestions in the dictionary
experiment_suggestions[f"Iteration_{i}"] = {
'Polymer1': p1,
'Polymer2': p2,
}
ax_client.save_to_json_file
; note this saves your ax_client instance, not the data)ax_client.complete_trial()
, with the correct trial indices.Probably you can also set up a scheduler, but I'm not sure how that works in Service.
@Abrikosoff step 4 Do I need to use for loop To evaluate the objectives and then complete the trial
@Abrikosoff step 4 Do I need to use for loop To evaluate the objectives and then complete the trial
You probably would want to, although I think you can also partially complete the set of suggested trials. In that case if the remainder is larger than your max_parallelism
number (I think!) you won't be able to generate new trials.
@Fa20 it looks like this issue can be closed. If you have further questions, please reopen it.
I have tried to attach trial to my experiment but when ax_client.generation_strategy.trials_as_df I can not see the attached experiment and when I run the code again I got