Пример #1
0
int main(int argc, char *argv[])
{
    GenericAgentConfig config = CheckOpts(argc, argv);

    GenericInitialize("knowledge", config);
    ThisAgentInit();

    KeepKnowControlPromises();

    if (strlen(STORY) > 0)
    {
#ifdef HAVE_CONSTELLATION
       if (strncmp(STORY, "SHA=", 4) == 0)
       {
          char buffer[CF_BUFSIZE];
          
                Constellation_HostStory(STORY, buffer, CF_BUFSIZE);
                printf("%s\n", buffer);
       }
       else
       {
          strcpy(TOPIC_CMD, STORY);
          
          printf("Let's start with stories about cause-effect:\n\n");
          CfGenerateStories(TOPIC_CMD, cfi_cause);
          printf("Now looking for stories about connections between things:\n\n");
          CfGenerateStories(TOPIC_CMD, cfi_connect);
          printf("Anything about structure:\n\n");
                CfGenerateStories(TOPIC_CMD, cfi_part);
       }
#endif
            exit(0);
            
    }
    
    if (GENERATE_XML)
    {
        GenerateXml();
    }
    else if (strlen(TOPIC_CMD) == 0)
    {
        int complete;
        double percent;

        KeepPromiseBundles();
        WriteKMDB();
        GenerateManual();
        ShowWords();
        ShowSingletons();

        complete = (double) CF_TOPICS *(CF_TOPICS - 1);

        percent = 100.0 * (double) CF_EDGES / (double) complete;
        CfOut(cf_inform, "", " -> Association density yields %d/%d = %.4lf%%\n", CF_EDGES, complete, percent);
        percent = 100.0 * (double) CF_OCCUR / (double) CF_TOPICS;
        CfOut(cf_inform, "", " -> Hit probability (efficiency) yields %d/%d = %.4lf%%\n", CF_OCCUR, CF_TOPICS, percent);
    }

    return 0;
}
Пример #2
0
void KeepPromises(EvalContext *ctx, const Policy *policy, GenericAgentConfig *config)
{
    if (paths_acl    != NULL || classes_acl != NULL || vars_acl    != NULL ||
        literals_acl != NULL || query_acl   != NULL || bundles_acl != NULL ||
        roles_acl    != NULL || SV.path_shortcuts != NULL)
    {
        UnexpectedError("ACLs are not NULL - we are probably leaking memory!");
    }

    paths_acl     = calloc(1, sizeof(*paths_acl));
    classes_acl   = calloc(1, sizeof(*classes_acl));
    vars_acl      = calloc(1, sizeof(*vars_acl));
    literals_acl  = calloc(1, sizeof(*literals_acl));
    query_acl     = calloc(1, sizeof(*query_acl));
    bundles_acl   = calloc(1, sizeof(*bundles_acl));
    roles_acl     = calloc(1, sizeof(*roles_acl));
    SV.path_shortcuts = StringMapNew();

    if (paths_acl    == NULL || classes_acl == NULL || vars_acl    == NULL ||
        literals_acl == NULL || query_acl   == NULL || bundles_acl == NULL ||
        roles_acl    == NULL || SV.path_shortcuts == NULL)
    {
        Log(LOG_LEVEL_CRIT, "calloc: %s", GetErrorStr());
        exit(255);
    }

    KeepControlPromises(ctx, policy, config);
    KeepPromiseBundles(ctx, policy);
}
Пример #3
0
void KeepPromises()

{
KeepContextBundles();
KeepControlPromises();
KeepPromiseBundles();
}
Пример #4
0
void KeepPromises()

{ double efficiency;
 
BeginAudit();
KeepControlPromises();
KeepPromiseBundles();
EndAudit();

// TOPICS counts the number of currently defined promises
// OCCUR counts the number of objects touched while verifying config

efficiency = 100.0*CF_OCCUR/(double)(CF_OCCUR+CF_TOPICS);

NoteEfficiency(efficiency);

CfOut(cf_verbose,""," -> Checked %d objects with %d promises, efficiency %.2lf",CF_OCCUR,CF_TOPICS,efficiency);
}
Пример #5
0
static void KeepPromises(Policy *policy, GenericAgentConfig *config, const ReportContext *report_context)
{
    double efficiency, model;

    KeepControlPromises(policy);
    KeepPromiseBundles(policy, config, report_context);

// TOPICS counts the number of currently defined promises
// OCCUR counts the number of objects touched while verifying config

    efficiency = 100.0 * CF_OCCUR / (double) (CF_OCCUR + CF_TOPICS);
    model = 100.0 * (1.0 - CF_TOPICS / (double)(PR_KEPT + PR_NOTKEPT + PR_REPAIRED));
    
    NoteEfficiency(efficiency);

    CfOut(cf_verbose, "", " -> Checked %d objects with %d promises, i.e. model efficiency %.2lf%%", CF_OCCUR, CF_TOPICS, efficiency);
    CfOut(cf_verbose, "", " -> The %d declared promise patterns actually expanded into %d individual promises, i.e. declaration efficiency %.2lf%%", (int) CF_TOPICS, PR_KEPT + PR_NOTKEPT + PR_REPAIRED, model);

}
Пример #6
0
void KeepPromises(EvalContext *ctx, Policy *policy, GenericAgentConfig *config)
{
    KeepContextBundles(ctx, policy);
    KeepControlPromises(ctx, policy, config);
    KeepPromiseBundles(ctx, policy);
}
Пример #7
0
void KeepPromises(EvalContext *ctx, Policy *policy, GenericAgentConfig *config, const ReportContext *report_context)
{
    KeepContextBundles(ctx, policy, report_context);
    KeepControlPromises(ctx, policy, config);
    KeepPromiseBundles(ctx, policy, report_context);
}