Forum Discussion

FICO's avatar
FICO
Community Manager
14 years ago

Loading an MIP solution

I'm having trouple loading an existing MIP solution into XPRESS using C++. The documentation for "load MIP solution" has the following example based on C:

XPRBprob expl2;double vals[] = {1.5, 1, 0, 4, 2.2};expl2 = XPRBnewprob("example2");if (XPRBloadmipsol(expl2, vals, 5, 0)!=0) printf("Loading the solution failed.");

Here, vals is an array (of size 5) that holds the MIP solution you want to feed in, and expl2 is the name of your problem.

This all seems fine, but I am implementing a similar system in C++, so I have written the following code:

XPRBprob expl2("example2");double vals[] = {1.5, 1, 0, 4, 2.2};if (XPRBloadmipsol(expl2, vals, 5, 0)!=0)        cout<<"Loading the solution failed.";

However, the XPRBloadmipsol statement does not work. Specifically, I get the following error when I compile:

error C2664: 'xbloadmipsol_prob' : cannot convert parameter 1 from 'class dashoptimization::XPRBprob' to 'struct Xbprob *'

This suggests that the paramters for the C++ version of this function are different to the C version. But I cannot find any documentation on this.

Could anyone offer any help?

Thanks

Rhyd

1 Reply

  • FICO's avatar
    FICO
    Community Manager

    Problem solved.

    Here's the c++ code that will work

    if(expl2.loadMIPSol(vals, 5, 0)!=0)     cout<<"Loading the solution failed.";

    The fact the "MIP" is in upper-case in the C++ command and lower-case in the C command was not particularly helpful!