fix: default is global-error-probability=1/100_000

This commit is contained in:
rudy
2022-11-18 15:13:49 +01:00
committed by rudy-6-4
parent ee2ae3ead3
commit bb756a6426
3 changed files with 19 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ namespace mlir {
namespace concretelang {
namespace optimizer {
constexpr double P_ERROR_4_SIGMA = 1.0 - 0.999936657516;
constexpr double DEFAULT_P_ERROR = 1.0 / 100000.0;
constexpr double UNSPECIFIED_P_ERROR = NAN; // will use the default p error
constexpr double NO_GLOBAL_P_ERROR = NAN; // will fallback on p error
constexpr uint DEFAULT_SECURITY = 128;

View File

@@ -142,14 +142,14 @@ class CompilationOptions(WrapperCpp):
Raises:
TypeError: if the value to set is not float
ValueError: if the value to set is not in interval ]0; 1[
ValueError: if the value to set is not in interval ]0; 1]
"""
if not isinstance(p_error, float):
raise TypeError("can't set p_error to a non-float value")
if p_error in (0.0, 1.0):
raise ValueError("p_error cannot be 0 or 1")
if p_error == 0.0:
raise ValueError("p_error cannot be 0")
if not 0.0 <= p_error <= 1.0:
raise ValueError("p_error should be a probability in ]0; 1[")
raise ValueError("p_error should be a probability in ]0; 1]")
self.cpp().set_p_error(p_error)
def set_display_optimizer_choice(self, display: bool):
@@ -186,12 +186,12 @@ class CompilationOptions(WrapperCpp):
Raises:
TypeError: if the value to set is not float
ValueError: if the value to set is not in interval ]0; 1[
ValueError: if the value to set is not in interval ]0; 1]
"""
if not isinstance(global_p_error, float):
raise TypeError("can't set global_p_error to a non-float value")
if global_p_error in (0.0, 1.0):
raise ValueError("global_p_error cannot be 0 or 1")
if global_p_error == 0.0:
raise ValueError("global_p_error cannot be 0")
if not 0.0 <= global_p_error <= 1.0:
raise ValueError("global_p_error be a probability in ]0; 1[")
raise ValueError("global_p_error be a probability in ]0; 1]")
self.cpp().set_global_p_error(global_p_error)

View File

@@ -172,12 +172,19 @@ llvm::Expected<V0Parameter> getParameter(optimizer::Description &descr,
optimizer::Config config) {
namespace chrono = std::chrono;
auto start = chrono::high_resolution_clock::now();
auto naive_user =
std::isnan(config.p_error) && std::isnan(config.global_p_error);
if (std::isnan(config.p_error)) {
config.p_error = optimizer::P_ERROR_4_SIGMA;
if (naive_user) {
config.global_p_error = optimizer::DEFAULT_P_ERROR;
}
if (std::isnan(config.p_error)) {
// We always need a valid p-error
// getV0Parameter relies only on p_error
// getV1Parameter relies on p-error and if set global-p-error
config.p_error = config.global_p_error;
}
auto sol = (!descr.dag || config.strategy_v0)
? getV0Parameter(descr.constraint, config)
: getV1Parameter(descr.dag.getValue(), config);