2021-04-12 12:31:43 -07:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Top contributors (to current version):
|
2022-04-05 13:38:57 -07:00
|
|
|
* Mudathir Mohamed, Gereon Kremer, Andres Noetzli
|
2021-04-12 12:31:43 -07:00
|
|
|
*
|
|
|
|
|
* This file is part of the cvc5 project.
|
|
|
|
|
*
|
2024-03-12 09:35:09 -07:00
|
|
|
* Copyright (c) 2009-2024 by the authors listed in the file AUTHORS
|
2021-04-12 12:31:43 -07:00
|
|
|
* in the top-level source directory and their institutional affiliations.
|
|
|
|
|
* All rights reserved. See the file COPYING in the top-level source
|
|
|
|
|
* directory for licensing information.
|
|
|
|
|
* ****************************************************************************
|
|
|
|
|
*
|
2021-11-16 12:13:19 -06:00
|
|
|
* An example of accessing cvc5's statistics using the Java API.
|
2021-04-12 12:31:43 -07:00
|
|
|
*/
|
2019-05-16 00:18:48 +00:00
|
|
|
|
2022-03-30 21:09:03 -07:00
|
|
|
import static io.github.cvc5.Kind.*;
|
2019-05-16 00:18:48 +00:00
|
|
|
|
2022-03-30 21:09:03 -07:00
|
|
|
import io.github.cvc5.*;
|
2021-10-01 18:21:02 -05:00
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
2019-05-16 00:18:48 +00:00
|
|
|
|
2021-10-01 18:21:02 -05:00
|
|
|
public class Statistics
|
|
|
|
|
{
|
|
|
|
|
public static void main(String[] args)
|
|
|
|
|
{
|
2022-10-04 12:06:02 -05:00
|
|
|
Solver solver = new Solver();
|
2021-10-01 18:21:02 -05:00
|
|
|
{
|
2021-11-03 16:32:10 -05:00
|
|
|
// Get the statistics from the `Solver` and iterate over them. The
|
|
|
|
|
// `Statistics` class implements the `Iterable<Pair<String, Stat>>` interface.
|
2022-03-30 21:09:03 -07:00
|
|
|
io.github.cvc5.Statistics stats = solver.getStatistics();
|
2021-11-03 16:32:10 -05:00
|
|
|
// short version
|
|
|
|
|
System.out.println("Short version:");
|
|
|
|
|
System.out.println(stats);
|
|
|
|
|
|
|
|
|
|
System.out.println("-------------------------------------------------------");
|
|
|
|
|
|
|
|
|
|
System.out.println("Long version:");
|
|
|
|
|
|
|
|
|
|
// long version
|
2022-03-23 23:59:23 +01:00
|
|
|
for (Map.Entry<String, Stat> pair : stats)
|
2021-10-01 18:21:02 -05:00
|
|
|
{
|
2022-03-23 23:59:23 +01:00
|
|
|
Stat stat = pair.getValue();
|
2021-11-03 16:32:10 -05:00
|
|
|
if (stat.isInt())
|
2021-10-01 18:21:02 -05:00
|
|
|
{
|
2022-03-23 23:59:23 +01:00
|
|
|
System.out.println(pair.getKey() + " = " + stat.getInt());
|
2021-11-03 16:32:10 -05:00
|
|
|
}
|
|
|
|
|
else if (stat.isDouble())
|
|
|
|
|
{
|
2022-03-23 23:59:23 +01:00
|
|
|
System.out.println(pair.getKey() + " = " + stat.getDouble());
|
2021-11-03 16:32:10 -05:00
|
|
|
}
|
|
|
|
|
else if (stat.isString())
|
|
|
|
|
{
|
2022-03-23 23:59:23 +01:00
|
|
|
System.out.println(pair.getKey() + " = " + stat.getString());
|
2021-11-03 16:32:10 -05:00
|
|
|
}
|
|
|
|
|
else if (stat.isHistogram())
|
|
|
|
|
{
|
|
|
|
|
System.out.println("-------------------------------------------------------");
|
2022-03-23 23:59:23 +01:00
|
|
|
System.out.println(pair.getKey() + " : Map");
|
2021-11-03 16:32:10 -05:00
|
|
|
for (Map.Entry<String, Long> entry : stat.getHistogram().entrySet())
|
|
|
|
|
{
|
|
|
|
|
System.out.println(entry.getKey() + " = " + entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
System.out.println("-------------------------------------------------------");
|
2021-10-01 18:21:02 -05:00
|
|
|
}
|
|
|
|
|
}
|
2019-05-16 00:18:48 +00:00
|
|
|
}
|
2023-10-02 01:20:26 -05:00
|
|
|
Context.deletePointers();
|
|
|
|
|
}
|
2019-05-16 00:18:48 +00:00
|
|
|
}
|