optim_size_control_direct.m

616 views
Skip to first unread message

Huckleberry Febbo

unread,
Jan 14, 2014, 5:50:12 PM1/14/14
to adv-veh...@googlegroups.com
Hello again,

I tried using the DIRECT optimization program given with ADVISOR to optimize both the components and the control parameters. I am having some trouble, I changed the default FUEL CELL vehicle to:

input.init.saved_veh_file='PARALLEL_defaults_in';   %The only line of code I changed in the program

and when I run it I get this:

>> optim_size_control_direct
Data loaded: FC_SI41_emis.M - Geo 1.0L (41kW) SI Engine - transient data
Data loaded: MC_AC75 - Westinghouse 75-kW (continuous) AC induction motor/inverter
Data loaded: ESS_PB25 - Hawker Genesis 12V26Ah10EP VRLA battery, tested by VA Tech
Data loaded: WH_SMCAR - Wheel/axle assembly for small car
Data loaded: VEH_SMCAR - Hypothetical small car
Data loaded: ACC_HYBRID - 700-W constant electric load
Data loaded: EX_SI - Standard catalyst for ~stoichiometric SI engine
Data loaded: TX_5SPD - manual 5-speed transmission
Data loaded: TC_DUMMY - lossless belt drive
Data loaded: PTC_PAR - multi-spd parallel electric-assist hybrid w/ electric launch
Data loaded: INIT_CONDS - Standard initial conditions
Error in adv_no_gui case {modify}:
Cell contents reference from a non-cell array object.
[adv_no_gui] going to keyboard -- type return to continue code or dbquit to exit


I am not sure what is happening here, but I know that it is failing at 

% start the optimization
direct_opt_results = gclSolve(p_f, p_c, x_L, x_U, A, b_L, b_U, c_L, c_U, I, GLOBAL, PriLev, plot_info, dv_names, resp_names, con_names);

Also, I am wondering which drive cycle this optimization is being done for? I assume that it is the default CYC_UDDS, but I am not entirely sure.

Thanks

Michael O'Keefe

unread,
Jan 15, 2014, 12:17:31 AM1/15/14
to adv-veh...@googlegroups.com
If you change the vehicle that you are going to optimize, you have to be sure that the powertrain model contains the design variables (dv_names) you want to optimize. When you changed to PARALLEL_defaults_in, the default control strategy for that model changed. For me, I get a different error: undefined function or variable 'cs_min_pwr'. Not sure why you get the Cell contents error. What version of matlab are you running? I'm on R2013b.

A way to get started is to load the model you want to optimize in the UI and use the UI to peruse the variables and decide which ones you want to be design variables. Then you can plug those in using the example scripts as a guide.

As for adv_no_gui, the documentation is slim but there's a little bit here:


To see exactly what it's doing, the best way is to open the adv_no_gui.m file. Yes, 'CYC_UDDS' is the default (see adv_no_gui.m line 336).

You can get information on all of the arguments to gclSolve by checking the m-file in the optimization folder -- it's fairly well documented.

Hope that helps,

Michael

Huckleberry Febbo

unread,
Jan 15, 2014, 6:43:18 PM1/15/14
to adv-veh...@googlegroups.com
Dear Michael,

Thank you again for your support, I greatly appreciate it and needed it.

As for my problem, I got a bit further and got stuck again.

>> optim_size_control_direct_small_parallel
Data loaded: FC_SI41_emis.M - Geo 1.0L (41kW) SI Engine - transient data
Data loaded: MC_AC75 - Westinghouse 75-kW (continuous) AC induction motor/inverter
Data loaded: ESS_PB25 - Hawker Genesis 12V26Ah10EP VRLA battery, tested by VA Tech
Data loaded: WH_SMCAR - Wheel/axle assembly for small car
Data loaded: VEH_SMCAR - Hypothetical small car
Data loaded: ACC_HYBRID - 700-W constant electric load
Data loaded: EX_SI - Standard catalyst for ~stoichiometric SI engine
Data loaded: TX_5SPD - manual 5-speed transmission
Data loaded: TC_DUMMY - lossless belt drive
Data loaded: PTC_PAR - multi-spd parallel electric-assist hybrid w/ electric launch
Data loaded: INIT_CONDS - Standard initial conditions
Cell contents reference from a non-cell array object.

Error in obj_fun (line 3)
time=varargin{1}{1};

Error in gclSolve (line 298)
   f     = feval(p_f,x, varargin{:});   % Function value at
   x

Error in optim_size_control_direct_small_parallel (line 65)
direct_opt_results = gclSolve(p_f, p_c, x_L, x_U, A, b_L,
b_U, c_L, c_U, I, GLOBAL, PriLev, plot_info, dv_names,
resp_names, con_names);

I believe the error is in the function:

function [con, con_e]=con_fun(x,varargin)

con=evalin('base','con');    %Line 3

 I looked on the workspace and I did not find any variables named 'base' or 'con'. I do not know what these are supposed to stand for. I looked into the gclSolve.m program as you suggested and

% p_f      Name of m-file computing the function value.
% p_c      Name of m-file computing the nonlinear constraints.

with  (p_f='obj_fun';) and p_c='con_fun'; - (I am not sure what would need to change in these functions if I change the vehicle, and I have attached both for reference)

It looks like the con variable is storing the response acceleration times and the grade response.  I guess maybe there is a problem with the initialization? 

Thank you in advance Michael,

Huck
con_fun.txt
obj_fun.txt

Huckleberry Febbo

unread,
Jan 15, 2014, 6:46:02 PM1/15/14
to adv-veh...@googlegroups.com
By the way I am running on R2013a

Michael P O'Keefe

unread,
Jan 16, 2014, 10:04:16 PM1/16/14
to adv-veh...@googlegroups.com
I don't have matlab available at the moment but here are a few thoughts/comments:

con = constraints -- a numeric value indicating how much constraints are being violated.

Perhaps things are no longer coordinated correctly between your design variables and their ranges. The variable giving the design variable names ("dv_names") has to be coordinated with the ranges over which that design variable can be used. Gcl solve has a lot of inputs and it can be a bit overwhelming to get it all straight.

Have you looked at the simpler optimization problems in the same folder (3 humb camel back and such)? They might give you a gentler introduction to running gcl solve where it's more apparent what the parameters are. I doubt the problem is in gclSolve though it seems like a miscoordination between your problem specification and the objective function and constraint function.

~Michael

Huckleberry Febbo

unread,
Jan 31, 2014, 5:15:47 PM1/31/14
to adv-veh...@googlegroups.com
Dear Michael,

Thanks again for your help. I have thoroughly read through all of your comments and suggestions.

Unfortunately, I am still experiencing difficulty running some of these optimizations. I worked through some of the simpler problems and that definitely helped me understand how to use the programs, but I still cannot get the thing to work for some reason. 

I have done a number of things to try and get it to work. Below I will describe two attempts that I made which produce the same error message:

Test 1. Run the size_plus_control using the DIRECT algorithm - to optimize the default parallel vehicle
I used the control variables and their ranges (that can be found easily in  the autosize window, shown below) in the code as:

WHAT I CHANGED FROM optim_size_control_direct  (IN RED)

input.init.saved_veh_file='PARALLEL_defaults_in';

[a,b]=adv_no_gui('initialize',input);

end

dv_names={'fc_pwr_scale','mc_trq_scale','ess_module_num','ess_cap_scale','cs_charge_trq','cs_min_trq_frac','cs_off_trq_frac','cs_electric_launch_spd_lo','cs_electric_launch_spd_hi','cs_charge_deplete_bool'};

resp_names={'combined_mpgge'};

con_names={'delta_soc','delta_trace','vinf.accel_test.results.time(1)','vinf.accel_test.results.time(2)','vinf.accel_test.results.time(3)','vinf.grade_test.results.grade'};

% define the problem

cont_bool=0;

p_f='obj_fun_size_control';

p_c='con_fun_size_control';

x_L=[1.0,0.8,11,0.333,1, 0.05, 0.05, 0, 10, 0]';

x_U=[3.0,2.5,35,2.0,80.9, 1, 1, 15, 30, 1]';

A=[];
b_L=[];
b_U=[];
c_L=[0; 0; 0; 0; 0; 6.5];
c_U=[0.005; 2; 11.2; 4.4; 20; 100];
I=[];
PriLev=2;
MaxEval=10;
MaxIter=2;

OUTPUT
Warning: Zero delay at time '0' to input port two
of 'BD_PAR/par <vc> config/<vc> par/engine on
(parallel hybrid)/Subsystem/Variable Transport
Delay' may result in incorrect simulation results.
To ensure proper results, check the 'Handle zero
delay' in the parameter dialog. By doing so, it
will turn the variable time delay block to a direct
feedthrough block. 
  In gui_run_simulation at 80
  In grade_test_advanced>get_resp at 466
  In grade_test_advanced at 366
  In adv_no_gui at 313
  In con_fun_size_control at 22
  In gclSolve at 937
  In optim_size_control_direct_parallel at 59 
Error in adv_no_gui case {save_vehicle}:
Error using strmatch (line 29)
Not enough input arguments.
[adv_no_gui] going to keyboard -- type return to continue code or dbquit to exit
K>> 

So, it completes the optimization, but for some reason it is unable to save the vehicle?


TEST 2. Run the opt_sizing_direct  - to optimize the default parallel vehicle

I simply change the vehicle to a Parallel and the max number of iterations and evaluations. When I do this, I also get the same output/error as in TEST 1.

What do you think may be the cause for this?

Thanks,
Huck

 

Michael P O'Keefe

unread,
Feb 4, 2014, 12:38:50 AM2/4/14
to adv-veh...@googlegroups.com
Sorry so long to reply. Unfortunately, I don't have time to look into this now but I'll see if I can grab a scratch of time and develop a working model to demonstrate gcl_solve (DIRECT) on the parallel.

~Michael

Huckleberry Febbo

unread,
Feb 4, 2014, 1:23:46 AM2/4/14
to adv-veh...@googlegroups.com
Thank you.


--
You received this message because you are subscribed to a topic in the Google Groups "ADVISOR and adv-vehicle-sim Software Discussion Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adv-vehicle-sim/QLgx41a_Rdw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adv-vehicle-s...@googlegroups.com.
To post to this group, send email to adv-veh...@googlegroups.com.
Visit this group at http://groups.google.com/group/adv-vehicle-sim.
To view this discussion on the web visit https://groups.google.com/d/msgid/adv-vehicle-sim/509f51e0-3e3d-4778-9836-c6501f7fbe5c%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
All the best,

Huckleberry Febbo

Michael P O'Keefe

unread,
Feb 7, 2014, 11:59:38 AM2/7/14
to adv-veh...@googlegroups.com
There is an error in gui_save_vehicle.m which only appears when used with DIRECT optimization. I fixed it in the Subversion repository and also added the example of the parallel hybrid vehicle. I want to do more testing of the files before I make an "official" ADVISOR release but what I would recommend is that you checkout the subversion repository for ADVISOR and run from that.

If you're not already familiar with Subversion, the easiest way to get a snapshot of the latest is to go here:


And click the "Download Snapshot" icon.

This should fix the "save" for DIRECT optimization runs.

Best,

Michael

Huckleberry Febbo

unread,
Feb 11, 2014, 3:51:33 PM2/11/14
to adv-veh...@googlegroups.com
Hello Michael,

I just got a chance to run the ADVISOR code that you made available on the subversion and then I ran the code that you made for the parallel vehicle, but unfortunately I got the same error that I described in my previous comment with the issue that it had saving the vehicle. 
Again, it is not imperative that this gets fixed I can easily input the parameters for the vehicle after the optimization manually.

On a side note ( and maybe this actually has something to do with this ), if I run the same optimization code on my desktop (windows 7) that I run on my laptop (windows 8), both with Matlab 2013a, the desktop has issues and the simulation does not run, but the laptop has no issues.


Michael O'Keefe

unread,
Feb 11, 2014, 4:02:17 PM2/11/14
to adv-veh...@googlegroups.com
I tested that script on Mac OS 10.8.5. I've got Win7 here and can double check if there are any Win7 particular issues.

Could you first confirm the following:
  • Are you running with a clean checkout of Advisor?
  • Also, have you reset your matlab path to the default and (re-)started the ADVISOR GUI at least once to add standard paths back (so that you're sure you're not accidentally pulling in older files still on your path)?
~Michael

Huckleberry Febbo

unread,
Feb 11, 2014, 6:14:30 PM2/11/14
to adv-veh...@googlegroups.com
Hello again,

Are you running with a clean checkout of Advisor? - Yes, I did a fresh download of your new code from the subversion. Also, I ask another question below and I tried running it on both the latest version of ADVISOR (on the subversion) and a copy from The Big Ladder site.
 
Also, have you reset your matlab path to the default - I am not sure what you mean by this, I change the matlab folder to the one with the new copy of advisor, if that is what you are talking about.
 
 (re-)started the ADVISOR GUI at least once to add standard paths back (so that you're sure you're not accidentally pulling in older files still on your path)? - - Yes, I did this.

I have been looking further into this issue and I have run into some more errors. 

When I run the optimization code on my laptop (only Windows 8 machine) that is the only time that it executes (albeit still with the save issue), but I have tried to run the code on 4 other machines (three of which have the same version of Matlab (2013 a) and I get this error:
 
Delta SOC Tolerance of 0.005 met.
Number of runs: 2, ESS/Fuel Energy ratio: 0.45505 %, DeltaSOC: -0.0043353, Initial_SOC: 0.62636

a =

     0


b = 

    cycle: [1x1 struct]

Error in adv_no_gui case {modify}:
Cell contents reference from a non-cell array object.
[adv_no_gui] going to keyboard -- type return to continue code or dbquit to exit
K>> 

I am about to try and run it on Linux Red Hat and see if I can get it to work that way.
 
Thank you for your help.
Huck

Michael O'Keefe

unread,
Feb 11, 2014, 6:55:10 PM2/11/14
to adv-veh...@googlegroups.com
Shucks, we don't seem to be having much luck getting you going with this. Sorry this is so complicated. I just ran the latest checkout on Windows 7 and it runs and saves the vehicle correctly so let me go through exactly the steps I took to do this:

1. Download the latest advisor from subversion from here: http://sourceforge.net/p/adv-vehicle-sim/code/HEAD/tree/ (click "Download Snapshot" -- this is r126)
2. I unzipped this and placed it on my C drive
3. Start Matlab 2013a
4. From the Matlab home tab, click on "set path" in the ribbon on top of the screen in the Environment block (the environment block is second to the right for me). You can more about the matlab path here: http://www.mathworks.com/help/matlab/ref/path.html You can also query for help on the path from within Matlab
If you have other versions of ADVISOR on your machine and your path is still pointing to them, you might not be running the files you think you are.
5. From the "Set Path" dialogue window, click "Default", "Yes" to replace what you currently have, "Save", then "Close"
6. From the matlab command prompt, cd (change directory) to the advisor root directory (for me, that is "cd C:\adv-vehicle-sim-code-126\adv-vehicle-sim-code-126\application\branches\advisor")
7. type advisor and save the paths for this version of advisor you just downloaded
8. click exit at the welcome screen
9. type 'optim_size_control_direct_par'

You'll see all of the warnings coming by due to changes in the simulink language between when the block diagrams were written and today but for me it does finish and save successfully in about 10 minutes.

With regards to running on Linux, I doubt that will be more "runnable" than Windows (it was originally developed on Windows) but it would be interesting to know how it does.

By the way, the "K>>" prompt is designed to dump you INSIDE of the context of the file where the error happened to help you to find/debug the error. adv_no_gui is an advanced ADVISOR tool so there is much less of a good beginner experience -- honestly, it was hacked together for folks to be able to automate advisor runs and does assumes some advanced knowledge of matlab. For example, in this case, your error happened within the 'modify' case in adv_no_gui. From the K>> prompt, you can query variables and find out how far the code executed and try to figure out what went wrong.

Don't feel obligated to dig around in the code but, if you're so inclined, you might be surprised at your ability to deduce what's going on so I don't become the bottleneck.

Anyhow, if this is still an area you're going to need to get working, see if the above steps help you to get a successful run and we can then pick up any further questions you have from there.

Thanks and best of luck,

Michael O'Keefe

Huckleberry Febbo

unread,
Feb 11, 2014, 7:17:07 PM2/11/14
to adv-veh...@googlegroups.com

Thanks you very much for the detailed response. I will definitely go through this and see if it works. I just wanted to mention that I got it working on Linux redhat.

Thanks again,
Huck

> --
> You received this message because you are subscribed to a topic in the Google Groups "ADVISOR and adv-vehicle-sim Software Discussion Forum" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/adv-vehicle-sim/QLgx41a_Rdw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to adv-vehicle-s...@googlegroups.com.
> To post to this group, send email to adv-veh...@googlegroups.com.
> Visit this group at http://groups.google.com/group/adv-vehicle-sim.

> To view this discussion on the web visit https://groups.google.com/d/msgid/adv-vehicle-sim/df3d0ce8-443f-45e5-9669-4427de816ef7%40googlegroups.com.

Huckleberry Febbo

unread,
Feb 12, 2014, 12:13:59 AM2/12/14
to adv-veh...@googlegroups.com

Michael,

It worked!! I imagine that it was probably an issue with the set paths step that I did not execute and I apologize that you had to break that down for me. 

Thank you very much,

Huck

Michael P O'Keefe

unread,
Feb 12, 2014, 12:31:50 AM2/12/14
to adv-veh...@googlegroups.com
No problem at all. Happy to hear it's working for you now. I've been bitten many a time by the Matlab path issue.

Cheers,

Michael

Huckleberry Febbo

unread,
Feb 18, 2014, 4:34:57 PM2/18/14
to adv-veh...@googlegroups.com
Michael,

With regard to the default optimization implementation of the DIRECT algorithm that ADVISOR uses:

1) Is it running the vehicle through a drive cycle?  

2) Is it just running the vehicle through the acceleration tests and grade test?

3) If 1) is false and 2) is true, how can it determine a combine mpgge? I thought that this metric was only determined based off drive cycles.

It seems like 1) is false and 2) is true, because after I ran optimizations for the same vehicle but different drive cycles, I ended up with the same exact result for both optimizations. So, it seems that the optimization is independent of the drive cycle. If this is the case, how would you suggest that I optimize a vehicle for a given drive cycle?

I considered looking at the different performance parameters that the vehicle needs to follow each cycle and using that as the constraint in the optimization function, but the performance parameters for the HWFET and FTP seem to be very close.

Michael P O'Keefe

unread,
Feb 18, 2014, 4:53:30 PM2/18/14
to adv-veh...@googlegroups.com
Inline below:


On Tuesday, February 18, 2014 2:34:57 PM UTC-7, Huckleberry Febbo wrote:
Michael,

With regard to the default optimization implementation of the DIRECT algorithm that ADVISOR uses:

1) Is it running the vehicle through a drive cycle?  

No, false. You can tell by checking out the objective function. The city/highway test procedure is being run. A test procedure is 2 or more cycles with their outcomes weighted together.
 
2) Is it just running the vehicle through the acceleration tests and grade test?

Yes, true. You can tell by inspecting the constraint functions:

Looks like acceleration test and grade test.
 
3) If 1) is false and 2) is true, how can it determine a combine mpgge? I thought that this metric was only determined based off drive cycles.

See comments above. Also, see line 21 here:

Once you get the results of the optimization, you can rerun the vehicle with the given optimized characteristics on any cycle. Also, the "response variable" is the miles per gallon gasoline equivalent (see line 19 here: https://sourceforge.net/p/adv-vehicle-sim/code/HEAD/tree/application/branches/advisor/optimization/examples/sizing_plus_control/direct/optim_size_control_direct_par.m)
 
It seems like 1) is false and 2) is true, because after I ran optimizations for the same vehicle but different drive cycles, I ended up with the same exact result for both optimizations. So, it seems that the optimization is independent of the drive cycle. If this is the case, how would you suggest that I optimize a vehicle for a given drive cycle?

Make sure that the response value is tied to what you want to maximize or minimize -- in this case, the new driving profiles you want to run. If their values don't get into the response variable or constraint variables, they won't have an effect on the optimization results.

Huckleberry Febbo

unread,
Feb 18, 2014, 5:36:46 PM2/18/14
to adv-veh...@googlegroups.com
Michael,

Thank you very very much! I greatly appreciate the incredibly helpful and timely response!

All the best,

Huck 

Aishwarya Pandey

unread,
Feb 22, 2014, 5:32:52 AM2/22/14
to adv-veh...@googlegroups.com
hi
I am also working on ADVISOR. I have learnt it so questions asked by you poked me to write here. I think u are through with it. If any problem you can ask.
1) one can use drive cycle or test procedure to check how the vehicle will respond on these. with this one can check fuel consumption. it should be in objective function file.
2) i think  grade_test or acceleration_test, impose  some constraint  while optimizing. it should be in constraint file.

Huckleberry Febbo

unread,
Feb 22, 2014, 10:57:10 PM2/22/14
to adv-veh...@googlegroups.com
Thank you Aishwarya.

Huckleberry Febbo

unread,
Feb 22, 2014, 11:36:05 PM2/22/14
to adv-veh...@googlegroups.com
Michael or Aishwrya,

I thought that I had the DIRECT optimization down, but unfortunately I am still having some issues. For the past two and a half days I have been trying very hard to figure out how to optimize a series vehicle the same way that I optimized the parallel vehicle, but I get strange errors:

1) The code executes and runs through, but finds no feasible points and many other variables are NaN:


2) When the graph pops up, there is no mpgge or anything else plotted (even after all iterations are complete)

3) It is satisfying the constraints during each run

I have read through the constraints and the objective functions many times, but I cannot seem to find any issues. I have also read through glcSolve and I cannot figure out why all of those variables are not defined. It is still changing the design variables each time it evaluates the function. For instance, here is fc_pwr_scale:

In the case that you get some time to look into my issue a bit further, I have attached my constraints, my objective, and my code that orchestrates everything. 


Thank you very much in advance and I will of course understand if you do not have time to look into this strange issue that I am getting.

All the best,

Huck


con_STEP.m
obj_STEP.m
small_series_STEP_t2.m

Huckleberry Febbo

unread,
Feb 22, 2014, 11:44:20 PM2/22/14
to adv-veh...@googlegroups.com
In addition to this,

I have tried the optimization with the following powertrain configurations and gotten the same error:

1) All Electric
2) Combustion Engine only


--
You received this message because you are subscribed to a topic in the Google Groups "ADVISOR and adv-vehicle-sim Software Discussion Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adv-vehicle-sim/QLgx41a_Rdw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adv-vehicle-s...@googlegroups.com.
To post to this group, send email to adv-veh...@googlegroups.com.
Visit this group at http://groups.google.com/group/adv-vehicle-sim.

For more options, visit https://groups.google.com/groups/opt_out.

Michael P O'Keefe

unread,
Feb 23, 2014, 8:40:15 AM2/23/14
to adv-veh...@googlegroups.com
Huck,

I haven't had a chance to look at your files but have you made sure that the con_STEP.m and obj_STEP.m functions work? One easy way to do this is to use matlab's "keyboard" command. It looks like either fmin is not being assigned or it is being assigned a NaN at some point which will wipe out the simulation.

Just a thought,

Michael

Huckleberry Febbo

unread,
Feb 23, 2014, 9:20:23 PM2/23/14
to adv-veh...@googlegroups.com
Michael,

As always, I greatly appreciate you helpful and quick comments. Unfortunately, I have not had a chance to try the things that you mentioned to fix my issue; I got a little behind with some other things that I put off, and I have to focus on them now. But, I will definitely be trying your suggestions and thinking about what you said.

All the best,
Huck

Aishwarya Pandey

unread,
Feb 24, 2014, 1:59:41 AM2/24/14
to adv-veh...@googlegroups.com
HI
1ST TIME WHEN I TRIED YOUR PROGRAM, IT GAVE ME THE GRAPH. BUT AFTER THAT IT IS NOT AT ALL SHOWING THE GRAPH. dO YOU WANT TO MODIFY THE MASS OF THE VEHICLE HERE? I TRIED SO MANY TIMES BUT COULDN'T GET THE SATISFACTORY RESULT ALTHOUGH THE PROGRAM IS RUNNING ERROR FREE.
 FOR ME ITS IS NOT WORKING. CLARIFY WHAT EXACTLY YOU WANT TO DO?  


On Wednesday, January 15, 2014 4:20:12 AM UTC+5:30, Huckleberry Febbo wrote:
1.fig
1.mat

Huckleberry Febbo

unread,
Feb 24, 2014, 2:05:20 AM2/24/14
to adv-veh...@googlegroups.com

Hello,
Thanks you for your efforts, I appreciate the help! Unfortunately, I am not really sure why it is not working. I tried to explain what I understand about my issue in my post. There is probably an error somewhere in either my constraints or my objective function that I cannot find.
Thanks again,
Huck

--
You received this message because you are subscribed to a topic in the Google Groups "ADVISOR and adv-vehicle-sim Software Discussion Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adv-vehicle-sim/QLgx41a_Rdw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adv-vehicle-s...@googlegroups.com.
To post to this group, send email to adv-veh...@googlegroups.com.
Visit this group at http://groups.google.com/group/adv-vehicle-sim.

Huckleberry Febbo

unread,
Feb 25, 2014, 7:15:03 PM2/25/14
to adv-veh...@googlegroups.com
Aishwarya,

Thank you again. I actually just got a chance to sit down and look at this problem again and I was surprised to see that the program worked for you! This is strange to me, but I think that it is good news. I will let you know if I figure this issue out!

All the best,
Huck 

Huckleberry Febbo

unread,
Feb 25, 2014, 10:54:48 PM2/25/14
to adv-veh...@googlegroups.com
That was a doozy!

It turns out that the series vehicle could not make the grade constraint for 1200 s. 


Which, I believe makes sense.. ( and please correct me if I am at all wrong Michael)  

The power from form the ICE has to turn a generator to make power for the motor that ultimately helps move the vehicle (along with the power from the battery). As you drive up the hill, if the engine does not have enough power (after the generator) to maintain the grade at a specific speed then the vehicle will slow down. The SOC may prolong this event, but ultimately it will happen.

With the parallel vehicle with the same size engine and battery ( the defaults) this was not a problem, because there are not additional energy losses through the generator.

Very interesting, I thought it was a code issue, but it turns out it is just physics!

All the best,
Huck


Huckleberry Febbo

unread,
Feb 25, 2014, 11:48:23 PM2/25/14
to adv-veh...@googlegroups.com
A few more comments/questions:

1) If the initial design point in not feasible, then the simulation does not work. 

It starts to check to see if the initial design point is feasible around line 336 inn glcsolve.m, then later in the code it appears that if there is no feasible points it can still proceed. I am sure why it would fail to find one though.

2) When I optimized the parallel vehicle ( an optimization that I believe worked), the optimization stopped after 37 iterations despite the fact that i set it to 50. I imagine that it converged, but I just wanted to make sure that the DIRECT algorithm does not need to execute all of its iterations in order to be complete.

Thanks,
Huck

Michael P O'Keefe

unread,
Feb 26, 2014, 12:27:15 AM2/26/14
to adv-veh...@googlegroups.com
Awesome! Good piece of engineer, Huck! Sounds right.

Michael P O'Keefe

unread,
Feb 26, 2014, 12:31:58 AM2/26/14
to adv-veh...@googlegroups.com
For 1
Hmm, I can't speak to the actual implementation of gcl solve but I was under the impression that it keeps hopping around the design space until it hits a feasible region. The only real way to get to the bottom of this is to rig a very simple problem with infeasible regions and make sure it seeks out the feasible region. There may be a setting for how long it searches.

2: There should be some settings for convergence criteria and the like. GCL Solve is a bit complex for its own good but we were fairly impressed with its robustness (10 years ago, at least).

Huckleberry Febbo

unread,
Feb 26, 2014, 1:22:14 AM2/26/14
to adv-veh...@googlegroups.com
Michael,

Thank for the support, I appreciate it! I sure was happy when I figured this one out!

For the next issue, that is a great idea! I will give it a shot.

Thanks,
Huck

Huckleberry Febbo

unread,
Feb 27, 2014, 12:28:05 AM2/27/14
to adv-veh...@googlegroups.com
Michael,

So I tried a few different things:

1) I Went back to the Parallel Vehicle that seemed to be working fine and:

 a) I got ride of all the design variables except fc_pwr_scale

b) I ran a basic simulations that determined the minimum value of fc_pwr_scale (0.17) that could meet a 55 mph for 100 s at 5% - See Figure below
- I also attached the code for this if anyone is interested

b) I relaxed the acceleration times so they were well above:

<<< ACCELLERATION TEST RESULTS >>>

                 0-60 mph:  11.5 sec

                 40-60 mph:  6.28 sec

                 0-85 mph:  28.5 sec

Which are the acceleration times using mc_pwr_scale_MIN. I also set the delta_soc and delta_trace constraints to high values. This ensures that the grade is the thing that will cause it to fail (if anything).

c) I set the upper and lower bounds for the design variables to 0.2 and 0.1 (as shown in the graph. GLC solve should then select the center point and evaluate it to see if it is feasible ( that is 0.15). That is not a feasible point, but from 0.17 to 0.2 are and despite this it crashes. It actually passes back an error after the grade test ( and []) and then, even thought the constraints function appears to be able to handle that error, it stops the simulation. 

- So this is a different error than I was getting before.

2) The second thing that I tried ( much less complicated ), was to simply take my original simulation with the parallel vehicle, that seems to work perfectly fine:

a) Get ride of all of the design variables except fc_pwr_scale

b) Let it range from 1 to 3

c) Look at one of the acceleration times that come out of the default configuration

d) Change my constraint so that the acceleration time in my constraints is less than that

- When I ran the simulation I got the same error that I had been getting with the series vehicle.

What I am thinking:

1) I could scale up the vehicle before the optimization so that it meets the initial performance requirements. I dislike this idea, way too much scaling and I feel that I would be assuming too much. By the way, I feel like it is a pretty bad assumption that we can scale the efficiency maps by a factor of 3. I do feel like they scale linearly this far, but I would like to hear your input on this one Michael. I usually scale mine for 0.75 to 1.25, but I have had trouble finding any papers on any validation for these ranges.

2) I could try another optimization technique. Any suggestions? I was thinking Genetic Algorithm perhaps.

3) I could relax my constraints, mostly the acceleration times, they are not too far off, but I feel like this is the wrong way to go as well. The optimizer should not dictate performance.

4) I would like to use GLC solve, I feel like I was very close to getting some preliminary results, but I don't want to spend much more time fiddling with it.

Michael please feel free to comment if you would like, I do not expect you to go through this entire thing. Although I do tremendously appreciate and look forward to your feedback, I mostly put all of this information up here because I saw that this particular post is getting a lot of interest in the ADVISOR community and I am happy to contribute anything that might help someone else. 

Thanks,

Huck

SCRATY.m
SCRATY2.m

Huckleberry Febbo

unread,
Feb 27, 2014, 12:36:45 AM2/27/14
to adv-veh...@googlegroups.com
Opps, I mean't:

I do not feel like they scale linearly this far.

Sometimes typing in this google group thing is a bit difficult; you cannot easily see your entire post (as far as I am aware)

Michael P O'Keefe

unread,
Feb 27, 2014, 10:24:12 AM2/27/14
to adv-veh...@googlegroups.com
Nice sleuthing work and good to know about gclsolve although I'm still surprised to hear that it crashes on infeasible points.

Since you're in matlab, I guess you have quite a few choices on what algorithm to choose although you probably want to do one that's not gradient based (genetic algorithm, simulated annealing, another search algorithm) due to the fact that the response surface is so ragged and spikey.

Best of luck. Others please feel free to jump in.

~Michael 

Huckleberry Febbo

unread,
Mar 19, 2014, 7:11:12 PM3/19/14
to adv-veh...@googlegroups.com
Hello All,

Just an update on using the DIRECT algorithm. I decided to continue using this optimization technique and it has given me some useful results.

A couple of suggestions:
1) Make sure that your initial point is a feasible solution. I do this using ADVISOR's Autosize function to scale the component sizes before optimization in the GUI:

2) glcSolve (DIRECT) starts in the middle of the design space, so make sure the middle of the design space is a feasible solution.  For instance, if I scaled the torque of the engine before the optimization to make sure that the vehicle meets my constraints, I can ensure that I am in the middle of the design space by defining the range for my torque as:
% Identify the Design Variables and their ranges    
dv_names={ 'fc_trq_scale'};
x_L=[    0.5*fc_trq_scale  ]';
x_U=[    1.5*fc_trq_scale  ]';

Hope this helps someone,
Huck

Amanda Cristina Santana

unread,
Nov 1, 2015, 8:12:51 AM11/1/15
to ADVISOR and adv-vehicle-sim Software Discussion Forum
How did you solve the problem with variable "con"? I am with the same problem here when I run the Optimization Matlab (function fmincon)! Please, help me!

Thanks.
Amanda.

Michael P O'Keefe

unread,
Nov 1, 2015, 9:26:59 AM11/1/15
to ADVISOR and adv-vehicle-sim Software Discussion Forum
Hi Amanda:

Have you already checked out the example files that shipped with ADVISOR?

For example,


There is an example of a "con" (con = constraint) function there.

Cheers,

Michael

Amanda Cristina Santana

unread,
Nov 2, 2015, 5:01:07 PM11/2/15
to ADVISOR and adv-vehicle-sim Software Discussion Forum
Hello Michael,

I finally could make Advisor work, however the optimization's results are not good.
I would like to know how I write the values generation in Autosize to the vectors X0, LB and UB in file "optim_size_control_matlab.m" because this vector uses "scaling factor" and Autosize doesn't use "scaling factor". How could I converte it?
I saw that my optimization's result exitflag = -2 = No feasible point was found. I think this result is due initial points. The values in vector X did not change. Would you know how to solve this "exitflag" problem? In attach there are some details about my program and my results.

Could you help me please?

Thank you very much.
Amanda.

file_con.png
file_main.png
file_obj.png
Parametros_Autosize.png
result_optimization.png

Michael P O'Keefe

unread,
Nov 2, 2015, 8:20:44 PM11/2/15
to ADVISOR and adv-vehicle-sim Software Discussion Forum
For mapping to autosize, scale factor is scaling on torque which directly maps to peak power. Based on what you have in the GUI, the mc_pwr_scale would be (lower bound) 5/7 and upper bound 7/7. The number of modules is just ess_mod_num. You can find these variables by looking at the ADVISOR appendix (http://adv-vehicle-sim.sourceforge.net/advisor_appendices.html) or in the GUI under "variable list" on the "vehicle input" screen.

One observation is that you have a whole heck of a lot of design variables. The more design variables you have, the harder it is to do optimization. If you are failing with fmincon, you might try DIRECT.

Setting up optimization in ADVISOR is a pretty advanced topic. I recommend taking it slow. Perhaps add printing to the workspace from within your constraint and objective functions so you can see what the algorithm is doing. You may also try to put your objective and constraint functions in one m-file that automates calling them through 1 iteration to be sure that the things you are changing make sense.

Try to start with the existing scripts, make sure they are working 100% and you understand what they're doing. Make one change, make sure it's still working, repeat. Etc. 

Hope that helps,

Michael
Reply all
Reply to author
Forward
0 new messages