0

I want to optimize an objective function with dependent decision variables as below.

Sum [I * (x(i) - x(i-1) + lo(i) - g(i)) * p(i)] 

Please note that the decision variable is only x(i) and x(i-1) is a value came from previous step of optimization. I have no idea how to write this objective function. Should I use function handler? Thanks

nana
  • 1
  • 1
  • Your question does not make any sense. What do you mean, "previous step of optimization?" – Matthew Gunn Apr 05 '16 at 11:41
  • I mean by "previous step of optimization" is x(i-1). Can I use diff(x) for that? – nana Apr 05 '16 at 15:00
  • By "previous step of optimization" do you mean you're trying to optimization some function using an iterative method? (i.e. compute some x_1 in step 1, then computes some x_2 in step 2 etc...) If so, your question is completely screwy because the objective function of a well defined optimization problem will in NO WAY refer to the method used to solve it. If I'm trying to `minimize f(x)`, I could solve it by hand, I could solve it using numerical methods on a computer etc...; `f` shouldn't refer to what method I'm using to try to solve it. So I'm confused what you're trying to do or ask. – Matthew Gunn Apr 05 '16 at 19:55
  • Ok, let me paraphrase the question. Can I write that objective function using vectorization method for the optimization? – nana Apr 06 '16 at 08:30

1 Answers1

0

Perhaps this is what you're asking?

Imagine you have a 3 by 1 vector x.

       [x_1
  x =   x_2
        x_3]

and you want to compute:

      [x_1         [0
  y=   x_2    -     x_1
       x_3          x_2]

You could do this in Matlab with the code:

y = x - [0;x(1:end-1)];

this works since x(1:end-1) will refer to [x_1; x_2]. You can use this snippet to write your overall objective function.

Matthew Gunn
  • 4,451
  • 1
  • 12
  • 30