Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@colomon
Created November 22, 2014 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colomon/6eb0ea455f81b5f19490 to your computer and use it in GitHub Desktop.
Save colomon/6eb0ea455f81b5f19490 to your computer and use it in GitHub Desktop.
sub CompareObjectInstances($model-instances, $current-instances) {
# each of those is a list of systems
my $tolerance = 1e-4;
my @current = @$current-instances;
for @$model-instances -> $model {
my $match;
my $shortest-distance = Inf;
for @current.kv -> $i, $current {
my $d = system-distance($model<System>, $current<System>);
if $d < $shortest-distance {
$shortest-distance = $d;
$match = $i;
}
}
if $shortest-distance < $tolerance {
@current.splice($match, 1);
} else {
say colored("model instance " ~ $model.perl ~ " is not matched in current", "red");
}
}
for @current -> $current {
say colored("current instance " ~ $current.perl ~ " is not matched in model", "red");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment