0

I am trying to solve a minimization problem using DEoptim in R. Previously, I used Excel's Solver tool, particularly the Evolutionary Solver technique. But the results from DEoptim don't match and are found often provide answers close to the given upper bounds of the parameters.

Problem Statement I define the problem by minimizing the squared difference as represented in function $f(q_1,q_2,\alpha_1,\alpha_2)$

The objective function: $$f(q_1,q_2,\alpha_1,\alpha_2)= \frac{1}{5}\sum\limits_{i = 1}^{5} (b_{i} - b_{mod_{i}})^2$$

With bounds:

lower = c(1000, 1000, 0.8, 1.4)
upper = c(1e10, 1e35, 1.5, 15.0)

where,

$$b_{mod,i} = q_{1} \lambda_i^{-\alpha_1} + q_{2} \lambda_i^{-\alpha_2}$$

and $\lambda_i = c(375, 470, 528, 625, 880)$ are the wavelengths of 5 channels and $b_i = c(228,124,98,67,44)$ represents the light absorption measurement corresponding to each wavelength.

Here $b_i$ is a measured value from a device and $b_{mod,i}$ is the modelled value achieved by the optimization process.

Queries

I am trying to use this technique in R to solve a physical problem.

  • Is DEoptim a good choice for the defined problem?
  • Any suggestions on solving this problem using R?
  • Are there any other optimization techniques to solve the present problem?

Approach 1: Excel Solver

In the Excel solver, I used the non-linear solver function with the inbuilt "Evolutionary" algorithm. The optimized values $q_1,\alpha_1,q_2,\alpha_2$ seems reasonable.

Approach 2: in R using DEoptim

I found that the Evolutionary algorithm in Excel is based on the Differential Evolutionary algorithm and in R there is a package called DEoptim (Link). Also, I need to run the optimization process for a large data set where each timestamp of data represents $b$. However, DEoptim results were found to be very close to the upper bound and often are very sensitive to the bounds provided.

## Values:
b = c(858.3302, 523.2456, 429.2651, 310.0678, 222.0470)

## Define Objective Function
obj_fun = function(x){
            return(0.2*((b[1] - (x[1]*(375^(-x[2])) + x[3]*(375^(-x[4]))))^2 +
                  (b[2] - (x[1]*(470^(-x[2])) + x[3]*(470^(-x[4]))))^2 +
                  (b[3] - (x[1]*(528^(-x[2])) + x[3]*(528^(-x[4]))))^2 +
                  (b[4] - (x[1]*(625^(-x[2])) + x[3]*(625^(-x[4]))))^2 +
                  (b[5] - (x[1]*(880^(-x[2])) + x[3]*(880^(-x[4]))))^2))
  }

## Define Bounds
lower = c(1000, 1.5, 1000, 0.8)
upper = c(1e35, 15.0, 1e10, 1.4)

## Control Params
control.param = DEoptim.control(list(trace=0, parallelType = "parallel"))

## Run DEoptim
result = DEoptim(obj_fun, lower, upper, control.param)

## See Result

result$optim$bestmem

        par1         par2         par3         par4 
4.677653e+34 1.133396e+01 2.119513e+09 1.382064e+00 


Excel Solver Result: par1 par2 par3 par4 1.782904e+27 9.5913123 144797.964 0.9558152715

yuliaUU
  • 1,581
  • 2
  • 12
  • 33
  • I don't have time on hand to go through your formula, so I'm afraid this is not a very tailored comment, but try setting a higher `itermax` in your DEoptim controls. Also, make sure your formula is set up such that a lower return is a 'success' - DEoptim minimises rather than maximises. – Paul Stafford Allen Apr 17 '23 at 06:51

0 Answers0