Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

best algorithm for optimizing building using OpenStudio and GenOpt

asked 2015-06-05 07:14:40 -0500

updated 2015-06-05 07:15:11 -0500

Hello everyone,

I am playing around with optimization of OpenStudio models using genOpt. It all has been working OK when optimizing Insulation thickness and WWR and overhangs, but now I want to try some discrete variables (i.e. number of glazing layers in windows)... discrete variables are bothering me. I have been reading the genOpt manual and Literature, but I am still not sure of anything.

So, I wanted to know what algorithms do you recommend for optimizing a building design, using EnergyPlus (OpenStudio) including continous and discrete variables.

I understand genetic algorithms CAN do this... but I am kind of skeptical to those 'magic' things. What about them?


edit retag flag offensive close merge delete


Update: I tried the following, but got an error message ... java.lang.ArrayIndexOutOfBoundsException: 0

Main = GPSPSOCCHJ; NeighborhoodTopology = vonNewmann; // gbest | lbest | vonNewmann NeighborhoodSize = 1; // 0< ... Ignored for vonNewman and gbest NumberOfParticle = #{10n_vars}; NumberOfGeneration = 15; Seed = 12; CognitiveAcceleration = 1.5; SocialAcceleration = 1.5; MaxVelocityGainContinuous = 1; MaxVelocityDiscrete = 1; ConstrictionGain = 0.8; MeshSizeDivider = 2; InitialMeshSizeExponent = 0; MeshSizeExponentIncrement = 1; NumberOfStepReduction = 4; *

gmolina's avatar gmolina  ( 2015-06-05 13:12:38 -0500 )edit

I would need the full error message and probably also the files needed to reproduce it. The following values work for

NeighborhoodTopology = vonNeumann;
NeighborhoodSize = 1;
NumberOfParticle = 20;
NumberOfGeneration = 15;
Seed = 1;
CognitiveAcceleration = 1.5;
SocialAcceleration = 1.5;
MaxVelocityGainContinuous = 1;
MaxVelocityDiscrete = 1;
ConstrictionGain = 0.8;
MeshSizeDivider = 2;
InitialMeshSizeExponent = 0;
MeshSizeExponentIncrement = 1;
NumberOfStepReduction = 4;}

in example/quad/GPSPS

Michael Wetter's avatar Michael Wetter  ( 2015-06-05 14:08:30 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2015-06-05 10:53:09 -0500

The OpenStudio Analysis Spreadsheet is a tool built just for this purpose. It applies a measure based workflow to an OpenStudio model and makes this workflow available to several class of Optimization (Calibration) algorithms in addition to sampling, design of experiments and others. The spreadsheet tool can be found at

It sounds like there may already be measures for what you want to change. The is a good resource for existing measures. The spreadsheet documentation will lead you through setting up a problem for optimization. There are also a few canned examples you can run.

OpenStudio-Server has the following algorithms in it:

  1. Multi-Objective optimization

    • NSGA2 (Non-dominated Sorting Genetic Algorithm) Parallel F evaluations Mixed Continuous or Discrete variables
    • SPEA2 (Strength Pareto Evolutionary Algorithm) Parallel F evaluations Continuous variables only
  2. Single-Objective optimization

    • Rgenoud (GENetic Optimized Using Derivatives) Parallel F evaluations for genetic search Parallel gradient calculation for continuous variables

    • Optim (quasi-Newton method with bounds) Parallel gradient calculation Continuous variables only

Since you want to use discrete variables in your optimization, I suggest using the NSGA2 multi-objective solver. This will allow you to find trade offs between Gas vs Electric, heating vs cooling, etc. There are also visualization tools avail on thru OS-Server to find parateo fronts and to visualize them on a parallel coordinate plot to look at sensitivities and ranges of "optimal" parameters.

NSGA2 is a genetic based algorithm. Loosely speaking, it will start with an initial population which is a sample of your variable space. It will then sort and rank the population and only keep the "best" values. It will then create a new population based off the previous best values and continue the process for a fixed number of "generations". I've had very good success using this algorithm for both Optimization and Calibration with OpenStudio.

edit flag offensive delete link more


It's also possible to extend the algorithm set. OS Server uses R at its core, and R algorithms that can be parallelized are good candidates for addition. If there's interest in this topic we could probably create a Q&A on how to go about this.

ljbrackney's avatar ljbrackney  ( 2015-06-05 18:54:30 -0500 )edit

Thanks for your comments. I tried to use the SpreadSheet one, and it did not really work for me. I understood measures, how to script them, and that is something I mixed with GenOpt... quite easy and very powerful.

I will have a look to the spreadsheet again.


gmolina's avatar gmolina  ( 2015-06-08 07:34:51 -0500 )edit

I know Brian would very much appreciate feedback on your experience with the spreadsheet workflow - particularly now that he has begun creating more extensive tutorial materials for it.

It would also be interesting to learn more about the details of your OS/GenOpt workflow.

ljbrackney's avatar ljbrackney  ( 2015-06-08 07:53:47 -0500 )edit

answered 2015-06-05 09:29:38 -0500


To use GenOpt with continuous and discrete parameters, I suggest to use either a hybrid Particle Swarm and Pattern Search Algorithm or the Particle Swarm Optimization algorithm by itself. See Sections 5.5 and 5.4, respectively.

GAs should also work, but they are not part of the GenOpt distribution. See also the paper

Michael Wetter and Jonathan Wright. A comparison of deterministic and probabilistic optimization algorithms for nonsmooth simulation-based optimization. Building and Environment, 39(8):989--999, 2004.

that compares a variety of optimization algorithms used with GenOpt and EnergyPlus, including a GA.

edit flag offensive delete link more


Thanks, Michael!

The error I showed before is the only thing I get in the console AND the log file. Ut just says "java.lang.ArrayIndexOutOfBoundsException: 0" after succesfully simulating the first generation, but it never gets to the second one.

Any ideas?

I will read that paper. THanks

gmolina's avatar gmolina  ( 2015-06-08 07:18:08 -0500 )edit

Could you please email me the GenOpt files, in particular the command and initialization file. I will need to reproduce it to see why this is happening. If you can simplify the files (e.g., remove the number of parameters) as much as possible, this would help.

Michael Wetter's avatar Michael Wetter  ( 2015-06-08 09:27:20 -0500 )edit

THanks for worying!

I think, Michael, that the problem was on my computer, shutting itself down because of overheating... I already fixed this, and am going to try these files again soon. I will let you know if it keeps failing.


gmolina's avatar gmolina  ( 2015-06-12 15:18:03 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Question Tools



Asked: 2015-06-05 07:14:40 -0500

Seen: 664 times

Last updated: Jun 05 '15