No, there is no requirement that all arrays in the summation have the same dimension and same index sets. All that is required is that every index variable is being set to a valid value.
You might want try removing individual elements of the constraint, one at a time, and seeing if the error goes away. (The model will be incorrect, but we don't need to solve it. We just want to find which part of the constraint is offending CPLEX.) I would start by removing the `ord(vehicle, v) >= 1` condition first. If the error persists, replace that and set the right hand side to 0. If the error persists, it is on the left side; if the error goes away, the right side is the culprit. Eventually you can hopefully find one specific term that is producing the error.
Before doing that, though, there is one other thing to check. Does the MILEAGE parameter have a numerical value for every combination of subscript values? If it is undefined for any combination, that would cause a problem extracting the constraint.
------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
------------------------------
Original Message:
Sent: Fri March 18, 2022 08:14 AM
From: Jia Zhong
Subject: Sum aggregation cannot extract expression
I got professor Rubin's feedback when I replied with the information below. But would like to post my feedback here. Sorry I am so new that I messed up with the posts and threads.
Thanks. I look into the arrays. I declare everyone of them either as parameters float or as variables.
I think the problem is the sum over the s (segment) that not every array defined has, or MILEAGE does not have vmtgrp (because they are the same across each vmt group).
float MILEAGE[t][segment][vehicle][agev]; //the final MPG model generateddvar float+ MILECONSUMP[t][segment][vehicle][agev][vmtgrp]; // millionn Miles consumption dvar float+ Fuel[t][vehicle][agev][vmtgrp]; //fuel consumption
Does it indicate that within the sum operation, we need to make sure all the sets declared for MILECONSUM: [t][segment][vehicle][agev][vmtgrp], should be also declared to MILEAGE? But here MILEAGE does not have [vmtgrp] so that CPLEX cannot extract expression?
Thanks agian
------------------------------
Jia Zhong
Original Message:
Sent: Wed March 16, 2022 03:30 PM
From: Paul Rubin
Subject: Sum aggregation cannot extract expression
It might help to see the declarations for the various arrays, to rule out the possibility that CPLEX is tripping over an item that is undeclared.
------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
Original Message:
Sent: Wed March 16, 2022 02:57 PM
From: Jia Zhong
Subject: Sum aggregation cannot extract expression
Hi Paul,
Thanks for your instant reply. I added more details in the original post. MILEAGE is a parameter input into the model. It is a linear model.
Best,
Jia
------------------------------
Jia Zhong
Original Message:
Sent: Wed March 16, 2022 02:52 PM
From: Paul Rubin
Subject: Sum aggregation cannot extract expression
You did not indicate which things are variables and which (if any) are parameters. If MILEAGE is a variable, then your constraints are neither linear nor quadratic, and CPLEX only allows linear and (some) quadratic constraints.
------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
Original Message:
Sent: Wed March 16, 2022 11:42 AM
From: Jia Zhong
Subject: Sum aggregation cannot extract expression
Hi all,
I am new to CPLEX, and I previously use GAMS to run the model and so I am still in the progress in picking up the syntax.
I have question in the sum expression when I only sum over one set and have division for each element to be sum over.
forall(ti in t, v in vehicle, a in agev, vmt in vmtgrp: ord(vehicle,v) >=1) sum(s in segment)(MILECONSUMP[ti][s][v][a][vmt]/MILEAGE[ti][s][v][a] )==Fuel[ti][v][a][vmt]/(1-UfactorPHEV[v]); //MILEPROD
What I am trying to code here is basically
∑s(Milet,s,v,a,vmt/MPGt,s,v,a=Fuelt,v,a,vmt for all the t,v,a,vmt. Note that I only sum over set s and get total fuel consumption that way.
I got 5 errors with this statement, and I have no idea how to correct it. I was thinking CPLEX is confused about my expression but the parenthesis operation does not help. I need help.

Thanks in advance! Jia
------------------------------
Jia Zhong
------------------------------
#DecisionOptimization