Optimizer Cost Fuction

Help
rjrodrig
2008-09-16
2012-12-15
  • rjrodrig

    rjrodrig - 2008-09-16

    I am new to this QUCS.  Does anyone know where to find a tutorial on the optimizer?  How does the cost function work?  I want to define a filter and i want it to optimize it based on my inputs, but I don't understand how the parameters: less, maximize, minimize, greater work.. My intuition tells me to set it up one way, and the program the program complains the cost function cannot be negative.  Well attenuation is in negative dBs so I have to say -10 etc... it complains....  Anyone has done this?

    Any Ideas?

     
    • Jonas

      Jonas - 2008-09-27

      Hello

      You are probably using qucs in another language than english (like I my case), so the help is not fully translated. Find in your installation folder of qucs the folder "docs". It contains the help in several languages, but the english help is more complete. Find a file called "start_opt.html" : this is a small tutorial for optimization. I would recommand you to make somewhere a link to the "index.html" file from the english documentation, so you would have a better documentation.

      There is also some tutorials here :
      http://qucs.sourceforge.net/docs.html

       
    • rjrodrig

      rjrodrig - 2008-09-27

      I am using English as default.  I tried the example and I don't quite get the same answer.  Mainly I don't understand the minimize maximize and what it does to arrive to an answer.  I am trying to do the same thing as the example.  I have a filter and I want to optimize the return loss (S22).  The issue is that I tell the program my filter lobes are -20 dB, passband ripple 0.5 dB etc... the number are negative so

      Specs

      Center frequency 350MHz,
      Passband 30MHz
      Passband ripple 0.5dB
      Right/Left Lobe = less than 20 dB
      Output Return loss (S22) = better than 15 dB

      So I put the parameters and all is referenced from 0 dB so all the numbers are negative.

      So in my mind I want to minimize the ripple

      Ripple Greater than -0.6 dB since it is below zero
      S22 in band = Less than -15dB
      etc....
      sometimes I get errors like "Cost function cannot be negative"  I don't get it!  The quantities are negative as they are referenced to 0 dB.  Does that mean the optimization has to happen in non-dB quantities as the example?  I am doing dB and plugging in dBs reference to 0 dB.  So  I am confused as to how this optimizer works.

      If I could get it to work, that would be awesome.  Sometimes it does stuff, but when I build the filter in real life, it does not agree with the theory.  The design comes from a tool called Filter Shop.  It synthesizes the filter and provides the S21 transfer function, but I don't know the return losses.  So I take it to QUCS, include all the losses in the inductors and caps, and it gives me a similar S21 plot, but the S22 does not look good.  So my goal is to change the L's and C's to get a better performance.    This is where I get stuck with the optimizer.

      Any help would be greatly appreciated.

       
    • Jonas

      Jonas - 2008-09-29

      Hello

      I am using the latest cvs version of qucs with asco 0.4.6.
      I don't know what are S parameters, but it seems to me that the simulation is making a maximization of a function (in this case S11_In_Band=...) probably using the simplex algorithm. The function to be maximized (or minimized) is called the cost function.

      I tried the tutorial too. I also get this error "Cost function cannot be negative".
      In the tutorial the S11_In_Band is to be maximized, in the tutorial, its value is set to 0, I think that is the start value, while with the simplex algorithm, the function to be maximized is set to 0 in the beginning and could only get a higher value while executing the steps of the algorithm.
      So it is impossible that the cost function has a lower value than 0 unless if the problem has no solution (but I am not completely sure). This would be the reason of the error "Cost function cannot be negative".

      But I don't know why it is not working as it should according to the tutorial. I tried with asco 0.4.6, 0.4.5, 0.4.4, but I still have the same problem and, when working, the result of the variables is exactly the same. I tried also with asco 0.4.3, but it seems to be too old to be working with qucs.

      I noticed that if you make a type error, like forgetting the double p of "Ripple" in the optimization windows->goals, the simulation will be launched without errors, but with a different result. It would be nice if an error would be raised at that time. I looked several time to the data I entered, but I didn't find type errors.

      I noticed also that if I set "Pass_Band_Ripple" "greater than" -0.795 : it works but if I set it "greater than" -0.8 or lower : it doesn't. In the tutorial, this was set to "greater than" -1.
      With a Pass_Band_Ripple" "greater than" -0.795, I have almost the same results as the tutorial with less than 10% imprecision, but for the S11_In_Band, It is almost the same result, but negatif !!!! Since it is the cost function, why didn't complain asco about it was negatif ?!!? That must be a bug !

      Tomorrow, I will try qucs 0.0.10 since it was the version of qucs used for the tutorial. Today is too late :).

      Here is my schematic:

      <Qucs Schematic 0.0.15>
      <Properties>
        <View=0,87,1147,811,1,0,60>
        <Grid=10,10,1>
        <DataSet=test_opt.dat>
        <DataDisplay=test_opt.dpl>
        <OpenDisplay=1>
        <showFrame=0>
        <FrameText0=Titre>
        <FrameText1=Auteur :>
        <FrameText2=Date :>
        <FrameText3=Version :>
      </Properties>
      <Symbol>
      </Symbol>
      <Components>
        <Pac P1 1 70 380 18 -26 0 1 "1" 1 "50 Ohm" 1 "0 dBm" 0 "1 GHz" 0 "26.85" 0>
        <GND * 1 70 450 0 0 0 0>
        <GND * 1 640 390 0 0 0 0>
        <GND * 1 340 490 0 0 0 0>
        <Pac P2 1 910 380 18 -26 0 1 "2" 1 "50 Ohm" 1 "0 dBm" 0 "1 GHz" 0 "26.85" 0>
        <GND * 1 910 450 0 0 0 0>
        <C C2 1 310 180 -26 17 0 0 "C2" 1 "" 0 "neutral" 0>
        <C C1 1 250 420 17 -26 0 1 "C1" 1 "" 0 "neutral" 0>
        <L L1 1 440 420 10 -26 1 3 "L1" 1 "" 0>
        <L L2 1 470 180 -26 10 0 0 "L2" 1 "" 0>
        <C C3 1 550 320 17 -26 0 1 "C3" 1 "" 0 "neutral" 0>
        <L L3 1 740 320 10 -26 1 3 "L3" 1 "" 0>
        <Eqn Eqn1 1 380 570 -37 17 0 0 "Left_Side_Lobe=max(dB(S[2,1]),800e6:900e6)" 1 "Pass_Band_Ripple=min(dB(S[2,1]),960e6:1040e6)" 1 "Right_Side_Lobe=max(dB(S[2,1]),1100e6:1200e6)" 1 "S11_In_Band=max(dB(S[1,1]),960e6:1040e6)" 1 "yes" 0>
        <.SP SP1 1 70 560 0 69 0 0 "log" 1 "800 MHz" 1 "1200MHz" 1 "200" 1 "no" 0 "1" 0 "2" 0 "no" 0 "no" 0>
        <.Opt Opt1 1 840 570 0 42 0 0 "Sim=SP1" 0 "DE=3|50|2|20|0.85|1|3|1e-6|10|100" 0 "Var=C1|yes|5.734197E-11|50e-12|80e-12|LIN_DOUBLE" 0 "Var=L1|yes|4.481596E-10|350e-12|450e-12|LIN_DOUBLE" 0 "Var=L2|yes|7.663042E-08|60e-9|100e-9|LIN_DOUBLE" 0 "Var=C2|yes|3.347780E-13|300e-15|340e-15|LIN_DOUBLE" 0 "Var=C3|yes|5.770140E-11|50e-12|80e-12|LIN_DOUBLE" 0 "Var=L3|yes|4.438158E-10|350e-12|450e-12|LIN_DOUBLE" 0 "Goal=Left_Side_Lobe|LE|-20" 0 "Goal=Pass_Band_Ripple|GE|-0.795" 0 "Goal=Right_Side_Lobe|LE|-20" 0 "Goal=S11_In_Band|MAX|0" 0>
      </Components>
      <Wires>
        <70 180 250 180 "" 0 0 0 "">
        <70 180 70 350 "" 0 0 0 "">
        <70 410 70 450 "" 0 0 0 "">
        <340 180 440 180 "" 0 0 0 "">
        <500 180 550 180 "" 0 0 0 "">
        <550 350 640 350 "" 0 0 0 "">
        <640 350 740 350 "" 0 0 0 "">
        <640 350 640 390 "" 0 0 0 "">
        <550 180 550 270 "" 0 0 0 "">
        <550 270 550 290 "" 0 0 0 "">
        <550 270 740 270 "" 0 0 0 "">
        <740 270 740 290 "" 0 0 0 "">
        <250 180 280 180 "" 0 0 0 "">
        <250 450 340 450 "" 0 0 0 "">
        <340 450 440 450 "" 0 0 0 "">
        <340 450 340 490 "" 0 0 0 "">
        <250 180 250 370 "" 0 0 0 "">
        <250 370 250 390 "" 0 0 0 "">
        <250 370 440 370 "" 0 0 0 "">
        <440 370 440 390 "" 0 0 0 "">
        <550 180 910 180 "" 0 0 0 "">
        <910 180 910 350 "" 0 0 0 "">
        <910 410 910 450 "" 0 0 0 "">
      </Wires>
      <Diagrams>
      </Diagrams>
      <Paintings>
      </Paintings>

       
    • Jonas

      Jonas - 2008-09-29

      I solved the problem, by putting in the equation :
      S11_In_Band = abs(max(dB(S[1,1]),960e6:1040e6)) instead of : S11_In_Band = max(dB(S[1,1]),960e6:1040e6).

      But I still don't know why before when S11_In_Band was negatif, sometimes asco complains and sometimes it doesn't.

       
    • rjrodrig

      rjrodrig - 2008-09-29

      Hi Jonas,

      Thank you for your reply.  S parameters are Scattering parameters used in RF hardware engineering.  they are used to determine the GAIN, and input and output impedance of any electronic network.  Maximum power transfer occurs when the load and source have equal impedance.  So from math that means that a complex impedance a+jb from the source must equal at the load.  So you can use Smith Charts and other tools like Network analyzer to see this.  QUCS is nice because it gives you the S11 and S21 parameters (Return loss and gain) and tell you how good your design is.

      Now, going to your solution, that makes sense because you are taking the absolute value of a negative number, which is what I posted previously.  Return loss are negative numbers below zero, so it is often talked about having good return loss when you have -20dB of loss at the right frequency with the right impedance, and the right pass band.  However, the optimizer should not care if the numbers are negative or or not? 

      I guess when they run their example they use positive numbers.  I am assuming that the boxes take dB + or - magnitudes but from your example, it does not seem to be the case.documentation.  Nevertheless, thank you for your help.  I wish there were more optimization problems so one can understand it a bit better.  I appreciate the work the QUCS team put to this simulator.  After all it is free. 

      thank you.

      RR

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks