The previous method change for sorting to accommodate capacitors and

other devices that do not have a "critical property" that determines
which properties can add together was flawed and messed up the sorting
of devices like transistors and resistors that do have a critical
property.  Reworked the sorting order so that it makes sense for both
situations.
This commit is contained in:
Tim Edwards 2021-05-28 21:20:39 -04:00
parent c83b6def5b
commit 00949970b4
2 changed files with 76 additions and 71 deletions

View File

@ -1 +1 @@
1.5.180 1.5.181

View File

@ -4254,10 +4254,12 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
struct objlist *obn, *obp; struct objlist *obn, *obp;
propsort *proplist; propsort *proplist;
struct property *kl; struct property *kl;
struct valuelist *vl, *ml; struct valuelist *vl;
int i, p, mval, merge_type, has_crit = FALSE; int i, p, mval, merge_type;
char c, *subs_crit = NULL; int has_crit;
double cval, tval, aval, slop, tslop; char ca, co;
double tval, tslop;
double aval, pval, oval, aslop, pslop;
obn = ob1->next; obn = ob1->next;
for (i = 0; i < idx1; i++) obn = obn->next; for (i = 0; i < idx1; i++) obn = obn->next;
@ -4266,34 +4268,37 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
* value and index. Then sort that list, then use the sorted * value and index. Then sort that list, then use the sorted
* indexes to sort the actual property linked list. * indexes to sort the actual property linked list.
* *
* If there is no critical property listed, then it will sort on * Collect properties of interest that we can potentially sort on.
* M first, and any additive property second, or any property at * That includes the M value, critical parameter, additive value(s),
* all if no additive property was found. It is doubtful that any * and finally any parameter. Keep these values and their slop.
* use case requires more than two properties for sorting. * If there is a critical value, then sort on additive values * M.
* If not, then sort on M and additive values.
*/ */
proplist = (propsort *)MALLOC(run * sizeof(propsort)); proplist = (propsort *)MALLOC(run * sizeof(propsort));
obp = obn; obp = obn;
mval = 1; mval = 1;
cval = aval = slop = 0.0; pval = aval = oval = 0.0;
for (i = 0; i < run; i++) { for (i = 0; i < run; i++) {
has_crit = FALSE;
merge_type = MERGE_NONE; merge_type = MERGE_NONE;
ml = NULL; ca = co = (char)0;
c = (char)0;
for (p = 0;; p++) { for (p = 0;; p++) {
vl = &(obp->instance.props[p]); vl = &(obp->instance.props[p]);
if (vl->type == PROP_ENDLIST) break; if (vl->type == PROP_ENDLIST) break;
if (vl->key == NULL) continue; if (vl->key == NULL) continue;
if ((*matchfunc)(vl->key, "M")) { if ((*matchfunc)(vl->key, "M")) {
mval = vl->value.ival; mval = vl->value.ival;
ml = vl; continue;
} }
kl = (struct property *)HashLookup(vl->key, &(tp1->propdict)); kl = (struct property *)HashLookup(vl->key, &(tp1->propdict));
if (kl == NULL) continue; /* Ignored property */ if (kl == NULL) continue; /* Ignored property */
if (kl->merge & MERGE_P_CRIT)
has_crit = TRUE; /* Get the property value and slop. Promote if needed. Save */
else if (kl->merge & (MERGE_P_ADD | MERGE_P_PAR)) { /* property and slop as type double so they can be sorted. */
if ((vl->type == PROP_STRING || vl->type == PROP_EXPRESSION) && if ((vl->type == PROP_STRING || vl->type == PROP_EXPRESSION) &&
(kl->type != vl->type)) (kl->type != vl->type))
PromoteProperty(kl, vl, obp, tp1); PromoteProperty(kl, vl, obp, tp1);
@ -4312,50 +4317,50 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
tslop = kl->slop.dval; tslop = kl->slop.dval;
} }
if (merge_type == MERGE_NONE) if (kl->merge & MERGE_P_CRIT) {
{ has_crit = TRUE;
pval = tval;
pslop = tslop;
}
else if (kl->merge & (MERGE_P_ADD | MERGE_P_PAR)) {
if ((ca == (char)0) || (toupper(vl->key[0]) > ca)) {
merge_type = kl->merge & (MERGE_P_ADD | MERGE_P_PAR); merge_type = kl->merge & (MERGE_P_ADD | MERGE_P_PAR);
cval = tval;
slop = tslop;
}
else {
if ((c == (char)0) || (toupper(vl->key[0]) > c)) {
c = toupper(vl->key[0]);
aval = tval; aval = tval;
aslop = tslop;
ca = toupper(vl->key[0]);
} }
} }
else if ((co == (char)0) || (toupper(vl->key[0]) > co)) {
oval = tval;
co = toupper(vl->key[0]);
}
}
if (has_crit == TRUE) {
/* If there is a critical value, then sort first */
/* by critical value */
proplist[i].value = pval;
proplist[i].slop = pslop;
/* then sort on additive value times M */
/* or on non-additive value. */
if (merge_type == MERGE_P_ADD)
proplist[i].avalue = aval * (double)mval;
else if (merge_type == MERGE_P_PAR)
proplist[i].avalue = aval / (double)mval;
else
proplist[i].avalue = (double)mval;
} }
else { else {
if ((c == (char)0) || (toupper(vl->key[0]) > c)) { if (merge_type != MERGE_NONE) {
if (vl->type == PROP_INTEGER) { proplist[i].value = aval;
aval = (double)vl->value.ival; proplist[i].slop = aslop;
c = toupper(vl->key[0]); proplist[i].avalue = (double)mval;
}
else if (vl->type == PROP_DOUBLE) {
aval = vl->value.dval;
c = toupper(vl->key[0]);
}
}
}
}
if (merge_type == MERGE_P_ADD) {
proplist[i].value = cval * (double)mval;
proplist[i].avalue = aval;
proplist[i].slop = tslop;
if (ml) ml->value.ival = 1;
}
else if (merge_type == MERGE_P_PAR) {
proplist[i].value = cval / (double)mval;
proplist[i].avalue = aval;
proplist[i].slop = tslop;
if (ml) ml->value.ival = 1;
} }
else { else {
/* If there are no additive values, then sort first by M */
/* and second by aval */
proplist[i].value = (double)mval; proplist[i].value = (double)mval;
proplist[i].avalue = aval;
proplist[i].slop = (double)0; proplist[i].slop = (double)0;
proplist[i].avalue = oval;
}
} }
proplist[i].idx = i; proplist[i].idx = i;
proplist[i].ob = obp; proplist[i].ob = obp;