Created
November 22, 2014 21:39
-
-
Save colomon/6eb0ea455f81b5f19490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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