Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

AMPI offers two main concepts for doing calculations: Scores and Blackboxes. Blackboxes are meant to evaluate one or several part Properties. That means a blackbox looks at the value of one property (can also be several properties if they are correlated) and decides whether that value is rather good (for AM) or rather bad (for AM).
Scores are meant to evaluate one or several Blackboxes, to produce an overall assessment of a part’s characteristics. Through reports and charts, the score results can then be shown to users.

...

Blackboxes and Scores are written in Javascript. It For making adjustments to the calculation logic, it is helpful to have some prior exposure to any kind of scriptwriting or programming .

Blackboxes

Defining blackboxes

...

If selected, this score will be available for filtering on the part list. Should only be enabled for numerical scores.
Only scores marked as filterable will be included in CSV exports.

Writing score scripts

A score can be considered a function that returns an object with a result value. The result value can then be displayed in charts.

Example:

A basic calculated score

Code Block
const calculated_result = 0.3 + 0.5

return {
	result: calculated_result,
}

All blackboxes are calculated before calculating scores. Within scores scripts, blackbox results are accessible through the results variable. Hence scores can access blackbox results through the results variable and the corresponding blackbox slug.

Example:

A score script retrieving the result of the BbEconLeadTimeExact blackbox

Code Block
// Slug of the blackbox that I want to retrieve
const LEAD_TIME_EXACT = 'BbEconLeadTimeExact'

// Retrieving blackbox result
const value = results[LEAD_TIME_EXACT].result

Tech and Econ scores

Tech and Econ scores are numerical scores that calculate the technical and economic suitability of a part within a range of [0, 1]. Values towards 0 indicate poor suitability, values towards 1 indicate good suitability for AM.

...

The weights of the blackbox can be adjusted to indicate how much impact an individual blackbox should have on the score. By convention, the weights are between 0..1. Values towards 0 indicate low impact, values towards 1 indicate a strong impact on the score result.

For a complete example of an econ score, see the Appendix

Helper functions

Helper functions are functions that are often used throughout multiple blackboxes or scores. To avoid defining such functions in each blackbox where it is used, they can just be defined once as a helper function. Then all blackboxes and scores can just use them without the need to define them redundantly.

...

How to debug blackboxes and scores

Appendix

Example

Full econ score script

Code Block
// Blackbox IDs
const LEAD_TIME_EXACT = 'BbEconLeadTimeExact'
const MIN_ORDER_QTY = 'BbEconMinOrderQuantity'
const PART_PRICE = 'BbEconCurrentPartPrice'
const PRICE_PER_KG = 'BbEconPricePerKg'
const QUALIFICATION_NEEDED = 'BbEconQualificationNeeded'
const SELECTION_LOGIC_ECON = 'BbEconSelectionLogic'

// Define blackbox weights
const blackboxes = [
	{
		name: 'Part price',
		weight: 0.5,
		id: PART_PRICE,
	},
	{
		name: 'Lead time',
		weight: 0.7,
		id: LEAD_TIME_EXACT,
	},
	{ name: 'Price/kg', weight: 0.5, id: PRICE_PER_KG },
	{
		name: 'Sel. Logic',
		weight: 1.0,
		id: SELECTION_LOGIC_ECON,
	},
]

let resultsBlackboxes = new Set()

let score = 0
let weightsum = 0
let weighttotal = 0

for (const { id, name, weight } of blackboxes) {
    
    // Retrieve blackbox result
	const value = results[id].result
	
	if (value !== null) {
		score += weight * value
		weightsum += weight

		resultsBlackboxes.add({
			name: name,
			weight: weight,
			id: id,
			result: value,
		})
	}
	weighttotal += weight
}
let result = score / weightsum
let certainty = weightsum / weighttotal

return {
	result: result,
	certainty: certainty,
	resultsBlackboxes: resultsBlackboxes,
}