MATLAB Answers

Optimising using a combination of linear equality constraints and no constraints

2 views (last 30 days)
Adam Handley
Adam Handley on 27 Jul 2020
Commented: Adam Handley on 28 Jul 2020
I am currently trying to optimise at 18 variable input. 13 of my variables don't require any constraints on them except for ub and lb. 5 of the variables are summed to 1. I tried using simulannealbnd and normalising these weightings to each other. I have tried using patternsearch but patternsearch only seemed to consider the variables in the linear equality.
Does any one have any advise on what optimiser to use?
% set upper and lower bounds for time (s), PID and Error:
LB=[0.15,...%time delay
0,0,0,0,0]; %weights to sum to 1
UB=[0.15,...%time delay
1,1,1,1,1];%weights to sum to 1
INPUT=(LB+UB)/2; %set initial guess in the middle
ObjectiveFunction=@(x) NN_v1_2_Parfor(INPUT,setup);
[x,fval,exitFlag,output] = patternsearch(ObjectiveFunction,INPUT,[],[],Aeq,1,LB,UB);


Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 27 Jul 2020
I don't know whether your objective function is smooth or not. If it is smooth (differentiable), I would suggest that you use fmincon as your solver. If it is not smooth, then use patternsearch with the following option change:
options = optimoptions('patternsearch','PollMethod','GSSPositiveBasis2N');
Be sure to pass options in your solver call.
I also suggest that you remove variable 1 from the problem entirely, so your problem is 17 variables. And I suggest that you rescale your variables so that all are of the same order. Your objective function internally should divide the first five variables by 1000, and the upper bound for the first five variables should be 1. Similarly, the new variables 8, 9, and 10 should internally be multiplied by 500, 1500, and 500 respectively, and the corresponding upper bounds should all be 1.
Alan Weiss
MATLAB mathematical toolbox documentation


Show 4 older comments
Adam Handley
Adam Handley on 28 Jul 2020
The objective function won't be deterministic as the simulation as random noise added at various stages throughout the simulation. The basis of the simulation is that the same simulation won't be achieved each time. The parameters found should be able to hold up in a stochastic environment. I don't know how this fairs in relation to the optimisers.
Alan Weiss
Alan Weiss on 28 Jul 2020
Your problem needs to be better defined. Are you trying to minimize the mean of something? Then you need to take enough samples to have a good estimate of the mean. This might imply that your simulation should be run many, many times for each parameter, and the whole computation will then be slow.
I suspect that you need to think hard about what exactly you are attempting to do. What is the real objective function? The theoretical, deterministic thing that you are trying to optimize? Is there any way to calculate it, or can you only obtain samples from a distribution?
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Adam Handley
Adam Handley on 28 Jul 2020
I am trying to minimise the difference between an inverted pendulum model and experimental collected data. The experimental data no one experiment is the same and to accurately have the simulation match the experiment the simulation cannot run exactly the same each time. Therefore I have adopted the approach of optimising based on the t-statistic from a set number of optimisations in order to determine if the simulation can replicate the sample of experimentally measured data. As I only have 10 sets of experimental data I have only been running 10 simulations.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!