#include <stdio.h>
#include "Mindopt.h"
#define MDO_CHECK_CALL(MDO_CALL) \
code = MDO_CALL; \
if (code != MDO_OKAY) \
{ \
Mdo_explainResult(model, code, str); \
Mdo_freeMdl(&model); \
fprintf(stderr, "===================================\n"); \
fprintf(stderr, "Error : code <%d>\n", code); \
fprintf(stderr, "Reason : %s\n", str); \
fprintf(stderr, "===================================\n"); \
return (int)code; \
int main(void)
char str[1024] = { "\0" };
MdoMdl
* model = NULL;
MdoResult code = MDO_OKAY;
MdoStatus status = MDO_UNKNOWN;
const int row1_idx[] = { 0, 1, 2, 3 };
const double row1_val[] = { 1.0, 1.0, 2.0, 3.0 };
const int row2_idx[] = { 0, 2, 3 };
const double row2_val[] = { 1.0, -1.0, 6.0 };
MDO_CHECK_CALL(Mdo_createMdl(&model));
MDO_CHECK_CALL(Mdo_setIntAttr(model, MDO_INT_ATTR_MIN_SENSE, MDO_YES));
MDO_CHECK_CALL(Mdo_addCol(model, 0.0, 10.0, 1.0, 0, NULL, NULL, "x0", MDO_YES));
MDO_CHECK_CALL(Mdo_addCol(model, 0.0, MDO_INFINITY, 1.0, 0, NULL, NULL, "x1", MDO_YES));
MDO_CHECK_CALL(Mdo_addCol(model, 0.0, MDO_INFINITY, 1.0, 0, NULL, NULL, "x2", MDO_YES));
MDO_CHECK_CALL(Mdo_addCol(model, 0.0, MDO_INFINITY, 1.0, 0, NULL, NULL, "x3", MDO_NO));
MDO_CHECK_CALL(Mdo_addRow(model, 1.0, MDO_INFINITY, 4
, row1_idx, row1_val, "c0"));
MDO_CHECK_CALL(Mdo_addRow(model, 1.0, 1.0, 3, row2_idx, row2_val, "c1"));
MDO_CHECK_CALL(Mdo_solveProb(model));
Mdo_displayResults(model);
Mdo_freeMdl(&model);
return (int)code;
}