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,96 +4268,99 @@ 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;
else if (kl->merge & (MERGE_P_ADD | MERGE_P_PAR)) {
if ((vl->type == PROP_STRING || vl->type == PROP_EXPRESSION) &&
(kl->type != vl->type))
PromoteProperty(kl, vl, obp, tp1);
if (vl->type == PROP_INTEGER) {
tval = (double)vl->value.ival;
tslop = (double)kl->slop.ival;
}
else if (vl->type == PROP_STRING) {
/* This is unlikely---no method to merge string properties! */
tval = (double)vl->value.string[0]
+ (double)vl->value.string[1] / 10.0;
tslop = (double)0;
}
else {
tval = vl->value.dval;
tslop = kl->slop.dval;
}
if (merge_type == MERGE_NONE) /* Get the property value and slop. Promote if needed. Save */
{ /* property and slop as type double so they can be sorted. */
merge_type = kl->merge & (MERGE_P_ADD | MERGE_P_PAR);
cval = tval; if ((vl->type == PROP_STRING || vl->type == PROP_EXPRESSION) &&
slop = tslop; (kl->type != vl->type))
} PromoteProperty(kl, vl, obp, tp1);
else { if (vl->type == PROP_INTEGER) {
if ((c == (char)0) || (toupper(vl->key[0]) > c)) { tval = (double)vl->value.ival;
c = toupper(vl->key[0]); tslop = (double)kl->slop.ival;
aval = tval; }
} else if (vl->type == PROP_STRING) {
} /* This is unlikely---no method to merge string properties! */
tval = (double)vl->value.string[0]
+ (double)vl->value.string[1] / 10.0;
tslop = (double)0;
} }
else { else {
if ((c == (char)0) || (toupper(vl->key[0]) > c)) { tval = vl->value.dval;
if (vl->type == PROP_INTEGER) { tslop = kl->slop.dval;
aval = (double)vl->value.ival; }
c = toupper(vl->key[0]);
} if (kl->merge & MERGE_P_CRIT) {
else if (vl->type == PROP_DOUBLE) { has_crit = TRUE;
aval = vl->value.dval; pval = tval;
c = toupper(vl->key[0]); 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);
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 (merge_type == MERGE_P_ADD) { if (has_crit == TRUE) {
proplist[i].value = cval * (double)mval; /* If there is a critical value, then sort first */
proplist[i].avalue = aval; /* by critical value */
proplist[i].slop = tslop; proplist[i].value = pval;
if (ml) ml->value.ival = 1; proplist[i].slop = pslop;
}
else if (merge_type == MERGE_P_PAR) { /* then sort on additive value times M */
proplist[i].value = cval / (double)mval; /* or on non-additive value. */
proplist[i].avalue = aval; if (merge_type == MERGE_P_ADD)
proplist[i].slop = tslop; proplist[i].avalue = aval * (double)mval;
if (ml) ml->value.ival = 1; else if (merge_type == MERGE_P_PAR)
proplist[i].avalue = aval / (double)mval;
else
proplist[i].avalue = (double)mval;
} }
else { else {
/* If there are no additive values, then sort first by M */ if (merge_type != MERGE_NONE) {
/* and second by aval */ proplist[i].value = aval;
proplist[i].value = (double)mval; proplist[i].slop = aslop;
proplist[i].avalue = aval; proplist[i].avalue = (double)mval;
proplist[i].slop = (double)0; }
else {
proplist[i].value = (double)mval;
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;