Analytica > Blogs > An Analytica advantage over MATLAB

I’m working on a model translation project for the California Energy Commission, going from MATLAB to Analytica. The transportation system model I’m working with has variables with many dimensions, including time, vehicle type, fuel, mode, and vintage. The MATLAB implementation includes pervasive use of the repmat (repeat matrix) and the reshape functions, which obscure the core model logic (and looks like a pain to have had to implement). As I’m translating, I’m reminded of how nice Analytica’s Intelligent Arrays are to work with, for reasons I’ll illustrate below.

Many parts of the model are conceptually straightforward. For example, fuel cost is the product of fuel cost by vehicle type and number of vehicles of each type over time. Surrounded by the reshaping and repeating function calls necessary to perform a simple element-wise multiplication, this logic takes some time to figure out within the MATLAB code:

dollarsPerMile = repmat(reshape(fuelPrice(car,:,:),
[dimension.fuelType 1 1 dimension.Time]), [1 dimension.class
dimension.vintage 1]) ./ repmat(milesPerFuelUnit, [1 1 1
dimension.Time]);

totalCost = sum(sum(sum(vehicles .* dollarsPerMile,3),2),1);

versus the Analytica implementation:

dollarsPerMile := fuelPrice / milesPerFuelUnit;

totalCost := sum( vehicles * dollarsPerMile, class, fuelType, vintage);

Analytica’s Intelligent Array abstraction takes care of this behind the scenes, so I just need to make sure I’ve implemented the correct logic. I don’t have to think about the dimensionality of the data until it’s relevant to the logic I’m implementing. Another example: in computing what fraction of the vehicle fleet is electric I need to calculate the size of the fleet to figure out my denominator, summing over all types of vehicles. When I do compute that sum, thankfully I don’t need to remember that vehicle type is the third of five array dimensions. (As I read through the MATLAB code, my scratch paper filled with of ordered lists of dimensions for the MATLAB arrays to track what dimension was being repeated or summed.)

So, if you’re working in MATLAB and find yourself using repmat and reshape, consider letting Analytica do that unenjoyable dimension management on your behalf so you can focus on building out a model to help you analyze whatever system or problem you’re tackling. You know, the fun stuff!

Share now

Heat pumps & hybrid systems in cold climates

Recent advancements in cold-climate heat pump technology have proven their effectiveness in heating homes even in areas with harsh winters. However, there’s been less research

The units state of America

It would be much easier to do calculations if we used kWh and GJ versus British thermal units and gallons. How did the US end up as the only place

Analytica software top in user satisfaction on G2

We’re thrilled to announce that Analytica has achieved the highest satisfaction score in G2’s business process simulation (BPS) category! G2 is the leading software

Does GPT-4 pass the Turing test?

In 1950, Alan Turing proposed “The Imitation Game”, today known as the Turing test, as a hypothetical way of measuring whether a computer can think [1]. It stakes out the