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

조회 수: 8 (최근 30일)
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
Bahar Bahari
Bahar Bahari 2019년 12월 15일
편집: Walter Roberson 2020년 10월 7일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Weiss
Alan Weiss 2014년 3월 18일
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
Alan Weiss
Alan Weiss 2014년 3월 19일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by