Re: Non zero tracking error

10 visualizzazioni
Passa al primo messaggio da leggere

Mahraz Amini

da leggere,
9 ago 2017, 18:25:3609/08/17
a sup...@ampl.com, am...@googlegroups.com
Dear AMPL group,

thanks for your response.

I did what you told. so now I have one problem with 2 objectives.

minimize  active_power1 : sum{p in Time, k in BUS} (bus_p_inj[k,p]) ;

minimize  active_power2 : sum{p in Time, k in BUS}   (bus_p_inj[k,p]-bus_p_inj_set[k,p])^2 ;

I am trying to solve the problem as follow:

ampl.eval ('objective active_power1 ;')
ampl.solve();


Pinj   = ampl.getVariable('bus_p_inj').getValues.getColumnAsDoubles('val');
ampl.getParameter('bus_p_inj_set').setValues(Pinj);

ampl.eval ('objective active_power2 ;')
ampl.solve();



it means that var bus_p_inj[k,p] were found by solving active_power and set as reference for active_power2. my question is objective function of the second problem ( or second time that we solve the problem ) should not be exactly zero! But it is not Zero! As bus_p_inj[k,p] is a feasible solution for question 1, it must be a feasible solution for question 2 with exact same constraints and parameters as well. Can you please help me understand why it is not zero.

Thanks,

Mahraz


On Aug 9, 2017, at 4:15 PM, AMPL Support <sup...@ampl.com> wrote:

Dear Mahraz,

You can certainly write

  param bus_ref {i in BUS, p in Time : bus_type[i] == 1}

The condition that follows : can be any valid AMPL relational expression, as
long as it only uses sets and parameters that were previously defined.

Rather than define two models that are the same except for the objective
function, we recommend that you define one model that has two objective
functions:

  minimize active_power :
     sum{p in Time, k in BUS : bus_type[k] == 2 || bus_type[k] == 3}
        c[k]*(bus_p_inj[k,p])^2 ;

  minimize active_power_interp :
     sum{p in Time, k in BUS : bus_type[k] == 2 || bus_type[k] == 3}
        (bus_p_inj[k,p]-bus_p_inj_set[k,p])^2 ;

Then you can solve with both objective functions in one AMPL session:

  ampl.eval('objective active_power ;');
  ampl.solve();
  ...
  ampl.eval('objective active_power_interp ;');
  ampl.solve();

Where ... is shown, you can put any statements that you want for examining
the results.  The variable values from the first solve will automatically be
sent back to the solver as a suggested starting point for the second solve.
If you do not get results from the second solve like you are expecting,
however, then as the creator of the model you will need to figure out the
reason.

If you have further questions, consider submitting them to our online user
forum by sending an email to am...@googlegroups.com or entering your question
at http://groups.google.com/group/ampl.  That will often get you a faster
response and also will make the answer available to other users.

AMPL Support Services
sup...@ampl.com


-----Original Message-----
From: Mahraz Amini [mailto:mam...@uvm.edu]
Sent: Tuesday, August 8, 2017 6:25 PM
To: sup...@ampl.com
Cc: Mads Almassalkhi; Melinh Nguyen
Subject: Non zero tracking error

Dear AMPL group,

I am writing on behalf of University of Vermont power system group and I am
working under supervision of Dr.Almassalkhi.  Melinh told us that we , as
paid costumers, can directly ask our questions from you. I have a question
that you might be able to answer.

I am trying to solve an optimal power flow problem and find set points of
different generator over a horizon of T which I define as problem 1. The out
put of problem 1 ( set points of generator ) are given as input ( reference
signal) to problem 2 which is exactly same as problem 1 except objective
function. objective function of problem 2 is finding set points of
generators while minimizing deviation from reference signal provided by
solving problem 1. As all the constrains are exactly the same in problem 1
and 2, it is expected that founded set points of problem 1, also be feasible
solution for problem 2 and objective function of problem 2 be 0. however, it
is not. Can you take a look at the code please.

main file is test.m which loads case96.mat, then call MPC_LLC to solve
problem 1 and find the reference set points. founded set points are given as
input to MPC_LLCinterp. MPCD.dat is used for both problems.

by the way I am wondering if there is any way to define parameters in ampl
in this way :

param bus_ref { i in BUS, p in Time : bus_type[i] == 1} , while BUS and Time
are sets and bus_type is parameter over BUS.

Thanks,

Mahraz Amini


Robert Fourer

da leggere,
10 ago 2017, 11:01:1010/08/17
a am...@googlegroups.com
Suppose that you comment out the API assignment,

ampl.getParameter('bus_p_inj_set').setValues(Pinj);

and instead use at the same place an AMPL assignment:

ampl.eval ('let {p in Time, k in BUS} bus_p_inj_set[k,p] := bus_p_inj[k,p] ;')

Then does the second solve give you an objective value of zero? Knowing the answer will narrow down the search for the cause of the problem.

Also check that the solve with the first objective function gives an "optimal solution" message. If the solver terminates with some other message then there may be an infeasible solution or no solution returned.

Bob Fourer
am...@googlegroups.com

=======
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi