anthonyocallaghan

4 Reputation

0 Badges

17 years, 217 days

MaplePrimes Activity


These are answers submitted by anthonyocallaghan

Thank you Darin, that seems to have solved the problem. best regards, Tony

Hi guys,

Thanks for all the replies,

first I must say that it's not really an option for us to change the tables, and therefore it not an option to change the equation per se. If we actually knew what was causing this error we could possibly work around it.

Paul, you said that you wrote a quick openMaple app that solved this equation. I have tried using maple 12 beta 2 on os x 10.4.11 but this came back with the same error. Would you mind telling me what operating system you are using. I'll post code below to show how I am calling maple.

Also this error isn't limited to the calendar application, we have other examples that produce the same error, if it would help you guys I can post other examples.

Any suggestion / help is more than welcome, we are really stuck on this problem.

The equation in the previous post was obtained from the variable "inString" at the point denoted by /** HERE **/ in the booleanSimplify function below.

The start and stop maple functions are below, along with the textCallBack.

Once again, thanks for taking the time to look at this problem.

regards, Tony

 

char * booleanSimplify(char * inString)
{
    if (inString == NULL) {
        fatalError("invalid input params",__FILE__,__LINE__,(char *)__func__,EX_USAGE);
    }
   
    if (KV == NULL) {
        fatalError("maple was not initialised",__FILE__,__LINE__,(char * )__func__,EX_USAGE);
    }
    char * string = NULL;
    char * output = NULL;
   
    M_BOOL result = TRUE;
   
    ALGEB dag;  /* eval result (Maple data-structure) */
    int len;
   
   
    /* catch ^C */
   
    signal(SIGINT,catch_intr);
   
    string = convertBooleanStringToLogical(inString);
    inString = string;

 

/** HERE **/
    string = NULL;
       
    if ((result = RestartMaple(KV,err)) == NULL) {
        fatalError("could not restart maple",__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
    }
   
    string = calloc(1,(unsigned) strlen("BooleanSimplify();") + strlen(inString) + 1);
    strcpy(string,"BooleanSimplify(");
    strcat(string,inString);
    strcat(string,");");
   
    free(inString);
    inString = NULL;
   
   
    // !!!:tonyocallaghan:20080123 this tells maple that we wish to use the Logic package
    dag = EvalMapleStatement(KV,"with(Logic):");
   
    if( dag && IsMapleStop(KV,dag) )
        fatalError("Maple stopped",__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
   
    if (TextOutput != NULL) {
        free(TextOutput);
        TextOutput = NULL;
    }
   
   
    dag = EvalMapleStatement(KV,string);
   
    if( dag && IsMapleStop(KV,dag) )
        fatalError("Maple stopped",__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
   
           
    if( dag && IsMapleStop(KV,dag) )
        fatalError("Maple stopped",__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
   
    if (TextOutput == NULL) {
        fatalError("global variable text output was not populated",__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
    }
   
    output = findAndReplace(TextOutput,"`","");
   
    if (TextOutput != NULL) {
        free(TextOutput);
        TextOutput = NULL;
    }
   
    free(string);
   
    string = output;
   
    output = convertLogicalStringtoBoolean(output);
   
    free(string);
   
    return output;
}

 

 

void startMapleMW()
{  
    if (KV != NULL) {
        fatalError("cannot start maple, instance already running",__FILE__,__LINE__,(char *)__func__,EX_USAGE);
    }
   
   
    MCallBackVectorDesc cb = {  textCallBack,
        errorCallBack,   /* errorCallBack not used */
        statusCallBack,   /* statusCallBack not used */
        0,   /* readLineCallBack not used */
        0,   /* redirectCallBack not used */
        0,   /* streamCallBack not used */
        queryInterrupt,
        0    /* callBackCallBack not used */
    };
   
    /* initialize Maple */
    if( (KV =StartMaple(NULL,NULL,&cb,NULL,NULL,err)) == NULL ) {
        fatalError("could not start maple",__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
    }
   
}

void stopMapleMW()
{
    if (KV == NULL) {
        fatalError("could not stop maple, no instance running",__FILE__,__LINE__,(char *)__func__,EX_USAGE);
    }
   
    StopMaple(KV);
    KV = NULL;
}

 

 

static void M_DECL textCallBack( void *data, int tag, char * output )
{
    if (tag != MAPLE_TEXT_OUTPUT) {
        char * textType = NULL;
        switch (tag) {
        case MAPLE_TEXT_DIAG:
            textType = strdup("maple text dialogue");
            break;
        case MAPLE_TEXT_MISC:
            textType = strdup("maple misc text");
            break;
        case MAPLE_TEXT_QUIT:
            textType = strdup("maple text quit");
            break;
        case MAPLE_TEXT_WARNING:
            textType = strdup("maple text warning");
            break;
        case MAPLE_TEXT_ERROR:
            textType = strdup("maple text error");
            break;
        case MAPLE_TEXT_STATUS:
            textType = strdup("maple text status");
            break;
        case MAPLE_TEXT_PRETTY:
            textType = strdup("maple text pretty");
            break;
        case MAPLE_TEXT_HELP:
            textType = strdup("maple text help");
            break;
        case MAPLE_TEXT_DEBUG:
            textType = strdup("maple text debug");
            break;
        default:
            break;
        }
        char * msg = "\n Maple could not output a text output, it returned with the following text :\n";
        char * string = calloc(1,(unsigned) strlen(msg) + strlen(output) + strlen(textType) + 1);
       
        if (string == NULL) {
            fatalError("Maple error + could not allocate error message",__FILE__,__LINE__,(char *)__func__,EX_OSERR);
        }
       
        strcpy(string,msg);
        strcat(string,output);
        strcat(string,textType);
        free(textType);
        textType = NULL;
        printf(string);
        fflush(stdout);
        free(string);
        string = NULL;
    //    fatalError(string,__FILE__,__LINE__,(char *)__func__,EX_SOFTWARE);
    }else {
        TextOutput = strdup(output);
    }
}
 

Hi Jacques, Roman, An example of the string being passed into BooleanSimplify is shown below. I must warn you tho, it takes quite a while to verify. Also I'm using maple 11 on a powerpc Mac running os x 10.4.11 "((((((evalb(`M_31 = M_28_29`))) &and ((((evalb(`month mod 2 = 1`))) &and ((evalb(month < 8)))) &or (((evalb(`month mod 2 = 0`))) &and ((evalb(¬((evalb(month < 8))))))))) &or (((evalb(M_28_29 = M_28_29))) &and ((((evalb(`month = 2`))) &and ((evalb(`month mod 2 = 0`))) &and ((evalb(month < 8)))))) &or (((evalb(`M_30 = M_28_29`))) &and ((((evalb(¬((evalb(`month = 2`)))))) &and ((evalb(`month mod 2 = 0`))) &and ((evalb(month < 8)))) &or (((evalb(`month mod 2 = 1`))) &and ((evalb(¬((evalb(month < 8)))))))))) &and (((evalb(¬((evalb(¬ (evalb(month < 12)))) &and (evalb(¬ (evalb(`month = 12`)))) &or (evalb(month < 1))))))))) &and ((evalb(¬((evalb(day < 1))))) &and (((( (evalb(day < 29))) &or ((evalb(`day = 29`)) )) &and (((((evalb(`CommonYear = LeapYear`))) &and ((((evalb(¬((evalb(`year mod 4 = 0`))))) &or ((evalb(`year mod 100 = 0`)) &and (evalb(¬((evalb(`year mod 400 = 0`))))) ))))) &or (((evalb(LeapYear = LeapYear))) &and ((((evalb(`year mod 4 = 0`)) &and ((evalb(¬((evalb(`year mod 100 = 0`))))) &or (evalb(`year mod 400 = 0`)) )))))) &and (((evalb(¬((evalb(¬ (evalb(year < 2080)))) &and (evalb(¬ (evalb(`year = 2080`)))) &or (evalb(year < 1812)))))) ))) &or ((( (evalb(day < 28))) &or ((evalb(`day = 28`)) )) &and (((((evalb(CommonYear = CommonYear))) &and ((((evalb(¬((evalb(`year mod 4 = 0`))))) &or ((evalb(`year mod 100 = 0`)) &and (evalb(¬((evalb(`year mod 400 = 0`))))) ))))) &or (((evalb(`LeapYear = CommonYear`))) &and ((((evalb(`year mod 4 = 0`)) &and ((evalb(¬((evalb(`year mod 100 = 0`))))) &or (evalb(`year mod 400 = 0`)) )))))) &and (((evalb(¬((evalb(¬ (evalb(year < 2080)))) &and (evalb(¬ (evalb(`year = 2080`)))) &or (evalb(year < 1812)))))) ))))) &and ((evalb(¬(((evalb(¬ (evalb(year < 2080)))) &and (evalb(¬ (evalb(`year = 2080`)))) &or (evalb(year < 1812)))))&or ((evalb(¬ (evalb(month < 12)))) &and (evalb(¬ (evalb(`month = 12`)))) &or (evalb(month < 1)))))" If anyone has any idea or any suggestion, please let me know. Thank you, /Tony
Page 1 of 1