Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use additional variables in the blackbox function? #181

Open
IlyaYakovenko opened this issue Sep 26, 2024 · 3 comments
Open

How to use additional variables in the blackbox function? #181

IlyaYakovenko opened this issue Sep 26, 2024 · 3 comments

Comments

@IlyaYakovenko
Copy link

How can I pass any additional variables to the blackbox function other than those that will change?
For example, I need to optimize the function f(x) = abs(original_length - current_length)
The variable current_length will be calculated from the vector x, which will be extracted from argv[1].
But original_length is a vector with fixed lengths, that do not depend on the input parameters. How can I give this vector to function?
I studied the user manual and all the examples, but only mathematical functions are used there without any additional variables.
About the batch method it is written that the function should accept only the name of the vector of variables, and the library method in the eval_x function also accepts only the vector x, hMax and countEval.

@ctribes
Copy link
Contributor

ctribes commented Sep 27, 2024

You have the parameter FIXED_VARIABLE to pass some fixed values to the blackbox function. This is managed by Nomad when calling the blackbox function. The values of the true variables and the fixed variables are passed together to the blackbox function in an input file (batch mode) or in the vector x (library mode with eval_x).
https://nomad-4-user-guide.readthedocs.io/en/latest/AdvancedFunctionalities.html#fixed-variable

It is also possible to pass some fixed information to the blackbox function executable in batch mode.
If your blackbox executable accepts some extra arguments and an argument for an input file name you can define the BB_EXE as in the example below

BB_EXE "myBB.exe Val1 Val2"

In this example, myBB.exe must be able to accept arguments Val1, Val2 and the input file name (managed by Nomad) for the variables.

@IlyaYakovenko
Copy link
Author

Thank you very much for your response!
So the problem dimension will be the number of dependent variables + the number of fixed variables?
Will this somehow affect the performance or the quality of optimization?

@ctribes
Copy link
Contributor

ctribes commented Sep 27, 2024

Yes. Some of the n "variables" are fixed and others varies.

It should not affect the quality of the optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants