obj = @(x) (x(1)^3 - x(2))^2 - x(1);
nonlcon = @(x) deal(x(1)^2 + 3150 - x(2), []);
fprintf("Unscaled optimisation results:\n");
fval_unscaled = zeros(5,1);
options = optimoptions('ga','Display','none','ConstraintTolerance',1e-6,'PlotFcn', @gaplotbestf);
[x_unscaled(i,:), fval_unscaled(i)] = ga(obj, 2, [], [], [], [], lb, ub, nonlcon, options);
fprintf("Objective value: %0.3f, x = %0.3f, y = %0.3f\n",fval_unscaled(i), x_unscaled(i,1), x_unscaled(i,2));
obj = @(x) 0.01*(((15*x(1))^3 - (4000*x(2)))^2 - (15*x(1)));
nonlcon = @(x) deal(0.001*((15*x(1))^2 + 3150 - (4000*x(2))), []);
fprintf("Scaled optimisation results:\n");
fval_scaled = zeros(5,1);
options = optimoptions('ga','Display','none','ConstraintTolerance',1e-6,'PlotFcn', @gaplotbestf);
[x_scaled(i,:), fval_scaled(i)] = ga(obj, 2, [], [], [], [], lb, ub, nonlcon, options);
fval_scaled(i,1) = fval_scaled(i,1) * 100;
x_scaled(i,1) = x_scaled(i,1) * 15;
x_scaled(i,2) = x_scaled(i,2) * 4000;
fprintf("Objective value: %0.3f, x = %0.3f, y = %0.3f\n",fval_scaled(i), x_scaled(i,1), x_scaled(i,2));