// // Copyright : MOSEK ApS // // File : rmt.cc // // Purpose : Template to use with solve.mosek.com #include #include #include using namespace mosek::fusion; using namespace monty; int main(int argc, char ** argv) { /* SET UP THE PROBLEM HERE */ // Setup a simple test problem Model::t M = new Model(); Variable::t x = M->variable("x", 3, Domain::greaterThan(0.0)); M->constraint("lc", Expr::dot(new_array_ptr({1.0, 1.0, 2.0}), x), Domain::equalsTo(1.0)); M->objective("obj", ObjectiveSense::Minimize, Expr::sum(x)); /* END PROBLEM SETUP */ // Attach log handler M->setLogHandler([](const std::string & msg) { std::cout << msg << std::flush; } ); // Solve remotely try { M->optserverHost("http://solve.mosek.com:30080"); M->solve(); std::cout << "Problem status: " << M->getProblemStatus() << std::endl; // Fetch and use the solution here // ... } catch (const OptimizeError& e) { std::cout << "Optimization failed. Error: " << e.what() << "\n"; } M->dispose(); return 0; }