Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Overview

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. 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

Blackboxes are defined in the admin panel under

...

Slug
Unique identifier of that blackbox. Used to reference this blackbox from a score.

Writing blackbox scripts

A blackbox can be considered a function that returns a value or an object.

...

Code Block
languagejs
const propertyValue = variables.custom.qualificationNeeded

switch (propertyValue) {
	case true:
		return 0.35
	case false:
		return 1.0
	default:
		return null
}

Scores

Scores can aggregate blackbox results into an overall result

Defining scores

Scores are defined in the admin panel under

...

Filterable
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.

...

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.

...

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

Text scores

The result of text scores is a String (text) - as opposed to numerical scores that produce numerical results. They can be used in charts with the type Text.

...

For a more comprehensive example 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.

...

Code Block
// valid
function abc() {
  return 1;
}

// invalid
return 1;

How to debug blackboxes and scores

The results of blackbox and score calculations can be verified in several places in the admin panel

Show parts with errors in the calculation

  1. Go to Parts
    Home › B3_Ampi › Parts

  2. Use the filter option With errors

  3. Any part still visible in the list now has an error somewhere in the calculation

  4. Open the part details

  5. Scroll down to the blackbox results

  6. Check the list of blackboxes for those with an error

...

Overview of all calculation results for one particular part

To see all the score and blackbox results for one particular part, do the following

...

You’ll reach a table with all score results for this part and a table with all blackbox results just below.

...

Verifying the calculation results of one score or blackbox for one part

To see detailed results of a score or blackbox including all input variables for one particular part do the following:

...

Detailed input used in the blackbox and score calculations

...

Triggering recalculation

For performance reasons and to reduce server load, blackbox and score results are only calculated once and then stored for repeated use. If a blackbox or score script is changed, you need to manually trigger a re-calculation of blackbox and score results. It is sufficient to trigger the recalculation once at the end of your editing actions.

...

  1. In any formula perform a zero impact change, e.g.

    1. add a space at the end of a line

    2. add an empty new line

  2. Save your changes

  3. Click Recalculate on the recalculation banner.

Appendix

Example

Full econ score script

...