How to solve an optimization problem with an objective function which is not directly a function of decision variables?

8 visualizaciones (últimos 30 días)
My objective function and constraints include some expressions each of which are defined separately. Therefore the OF and constraints does not directly include variables. I know that the optimization functions in Matlab require the variables to present in the constraints or OFs to be able to solve the problem. I cannot bring variables to my functions because I do max operation and some different for loops for their calculations separately.
  4 comentarios
Bahar Bahari
Bahar Bahari el 15 de Dic. de 2019
Editada: Walter Roberson el 7 de Oct. de 2020
Hello
I have the same question in using GA but I found the answer a bit complicated. Could you say the soloution for a simple question as follows:
a=10;
b=5;
x=2a+b
y=b/3
z=x+y
I want to minimize "z" while "a" & "b" are the variables.
Thank you very much.

Iniciar sesión para comentar.

Respuesta aceptada

Alan Weiss
Alan Weiss el 18 de Mzo. de 2014
I am not sure that I understand you. If you have some parameters that are not decision variables, but instead are extra parameters or data, see how to pass extra parameters.
If you have some parameters that depend on intermediate calculations in your objective or nonlinear constraint functions, then just wratp them into your function files.
If I misunderstand you completely, please try again, and perhaps include a bit of pseudocode so that we can have a better chance of understanding your situation.
Alan Weiss
MATLAB mathematical toolbox documentation
  3 comentarios
Alan Weiss
Alan Weiss el 19 de Mzo. de 2014
Thanks for the explanation. Here is how I would approach this problem.
  1. Get the Excel data into your workspace first with the xlsread statement.
  2. Create the parameters I, J, K, and whatever else you need that doesn't depend on anything but the data.
  3. Write a function file OF = myfunction(x,I,J,K,...), where x represents ALL your decision variables, and I,J,K,... are ALL your parameters that you need. myfunction should return the value of the objective function when x,I,J,K,.. are specified.
  4. Call the solver like this:
[solution,value] = patternsearch(@(x)myfunction(x,I,J,K,...),x0)
or
[solution,value] = ga(@(x)myfunction(x,I,J,K,...),numVariablesInx)
Alan Weiss
MATLAB mathematical toolbox documentation

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by