Setting decision variables as an array
A Free and Open Source Java Framework for Multiobjective Optimization
Brought to you by:
dhadka
Hi
I want to ask if it is possible to set my decision variables as an array, for example if I have 12 decision variables that are represented and stored in an array of [3][4], and I have tryied set the variables as follows
for (int i = 0;i < 3; i++) { for (int j = 0; j < 4; j++) { solution.setVariable([i][j], EncodingUtils.newReal(-10.0, 10.0)); } }
and I am getting the following error message
Syntax error on token "(", Expression expected after this token
associated with
solution.setVariable([i][j], EncodingUtils.newReal(-10.0, 10.0));
Please any one can help in this issue
Kind regards
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Another question related to the previous Ticket is that >>>>
Is it compulsory to use the decision variables directly within the objective
function? or it is allowed to use them elsewhere to calculate other parameters that will be used with the objective function???
Thank you
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Regarding the first question, you'll need to scalarize the 3x4 matrix into an array:
The objective functions are calculated within a problem's
public void evaluate(Solution solution) { ... }
method. All calculations for computing the objective functions from the decision variables must be included within this method.Hope this helps answer your questions!
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi
Thank you for your respond
What I mean is that, I want to set and assign the decision variables to to hold the values of variables that I have already initialized and saved in an array [3][4].
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi
in addition to the previous question
Can I set the decision variables to hold values of some other variables used elsewhere within the program as follows:
solution.setVariable(0, EncodingUtils.newReala));
solution.setVariable(1, EncodingUtils.newRealb));
solution.setVariable(2, EncodingUtils.newReal(c));
where (a,b,c) are some variables that their values are changing in each iteration.
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
I'm not 100% sure I understand the question, so please ask for clarification if I'm not answering your question. I may also help if you can attach some example code of your problem.
The decision variables can only be defined using a lower and upper value:
This variable will be assigned values within these bounds by the algorithm. It sounds like you want to have some decision variables set to a specific value that you are calculating elsewhere in the program. If that's the case, then you likely do not want to save them as decision variables. Instead, just access the variables directly.
You can then change the value of
a
anywhere in your program. If, for example, you want to update the value every 100 evaluations:View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Thanks a lot for your valued feedback, the code now performing much better and needs some more modification to be more reliable.
Best regards