# optimization of real values and binary, what is the difference

Many optimization packages provide several ways to find solutions, one of which is the choice between binary search and search for real values.

I have a real binary search task, but the search algorithm that I want to apply can only work with real values

Can I just convert the output from the search algorithm to binary form with the usual rounding, for example R code

out_real_val <- runif(20,1,5)
> out_real_val
[1] 4.258845 4.062256 4.318080 1.446091 1.696332 3.841191 2.379701 1.795424
[9] 1.815174 3.017192 2.872621 4.239992 1.847689 2.986606 1.420673 3.995540
[17] 4.822753 2.358454 4.808910 3.152754


convert to

to_bin_val <- round(out_real_val,0)
> to_bin_val
[1] 4 4 4 1 2 4 2 2 2 3 3 4 2 3 1 4 5 2 5 3


Can I apply rounding, or will the search no longer be as effective? or something else?

I want to know what is the difference between binary search and real value search, as well as whether it is possible to apply rounding as in my example

UPD======================

I am using the grammatical evolution package where each expression is a binary code

The package has a built-in genetic search algorithm, but nothing prevents you from using other algorithms ... I would like to try other optimization algorithms to find the best expression, such as multiobjective optimization from the GPareto package. But this package (like many others) only works with real values

I can't explain it clearly, but I have such a feeling that binary search is different from searching for real values ..

I may be confused but: For example, if we have two vectors of real values and they are very similar to each other, then the fitness function will most likely show a similar result. But if we have two very similar binary vectors, then these can be completely different expressions and the fitness function can be very different

• Can you give us some context? Aug 9, 2021 at 5:50
• yes of course i have updated the question
– mr.T
Aug 9, 2021 at 7:04