Example #1
0
void main()
{
	treeNode* n7 = makeRootNode('D', NULL, NULL);
	treeNode* n6 = makeRootNode('C', NULL, NULL);
	treeNode* n5 = makeRootNode('B', NULL, NULL);
	treeNode* n4 = makeRootNode('A', NULL, NULL);
	treeNode* n3 = makeRootNode('/', n6, n7);
	treeNode* n2 = makeRootNode('*', n4, n5);
	treeNode* n1 = makeRootNode('-', n2, n3);

	printf("\n preorder  : ");
	preorder(n1);
	
	printf("\n inorder   : ");
	inorder(n1);
	
	printf("\n postorder : ");
	postorder(n1);

	getchar();
}
Example #2
0
int main(int argc, char** argv) {
    // Dimension
    int n = 2;
    // Box size
    int d = 3;
    // Accuracy 
    double eps = 0.1;
    // Cut analysis depth
    int ldepth = 1;
    // Use or not boxed cut
    bool boxedcut = true;


    if (argc != 7)
        BNB_ERROR_REPORT("Usage runpolymi.exe dimension box_size polynom cut_depth use_boxed_cut (0/1) record");
    n = atoi(argv[1]);
    d = atoi(argv[2]);
    ldepth = atoi(argv[4]);
    boxedcut = (atoi(argv[5]) == 0) ? false : true;
    double record = atof(argv[6]);

    PolyMIFactory polymifact(n, d, argv[3]);
    NlpProblem<double>* nlp = polymifact.getProb();


    /* Setup cut generators */
    /* Cut generator for objective*/
    NlpRecStore<double> ors(record, nlp);
    PointCutFactory<double> pfact(&ors);
    PolyObjective<double>* obj = dynamic_cast<PolyObjective<double>*> (nlp->mObj);
    PolyEigenSupp objEigenSupp(obj);
    EigenCutFactory<double> objEigenCutFact(&ors, &objEigenSupp, obj, eps);

    /* Setup composite cut factory  */
    CompCutFactory <double> fact;
    fact.push(&pfact);
    fact.push(&objEigenCutFact);

    /* Setup cut applicator */
    SmartCutApplicator<double> sca(nlp->mVariables);
    
    if (boxedcut == 0)
        sca.getOptions() = SmartCutApplicator<double>::Options::CUT_BALL_SIMPLE;
    if (boxedcut == 1)
        sca.getOptions() = SmartCutApplicator<double>::Options::CUT_BALL_BOXED;
    if (boxedcut == 2)
        sca.getOptions() = (SmartCutApplicator<double>::Options::CUT_BALL_SIMPLE
            | SmartCutApplicator<double>::Options::CUT_BALL_BOXED);


    /* Setup splitter */
    //StdBoxSplitter<double> splt;
    MIBoxSplitter<double> splt(nlp->mVariables);

    /* Setup solver */
    BNCSolver<double> bnc(&fact, &sca, &splt, ldepth);
    BNBTree tree(makeRootNode(*nlp));
    BNBNode* root = tree.getRoot();
    WFSDFSManager manager;
    manager.setOptions(WFSDFSManager::Options::DFS);
    manager.reg(root);
    BNCState<double> state(&manager, &ors);
    state.mForest.push_back(&tree);


    /* Solving problem */
    bool ru;
    long long int iters = 10000000;

    bnc.solve(iters, state, ru);

    /* Printing results*/
    std::cout << iters << " iterations\n";
    std::cout << "Record = " << state.mRecord->getValue() << "\n";
    VecUtils::vecPrint(n, (double*) ors.getX());

    return 0;
}
Example #3
0
void main()
{
 	treeNode* n11 = makeRootNode('H', NULL, NULL);
 	treeNode* n10 = makeRootNode('I', NULL, NULL);
 	treeNode* n9 = makeRootNode('J', NULL, NULL);
 	treeNode* n8 = makeRootNode('K', NULL, NULL);

 	treeNode* n7 = makeRootNode('D', n11, NULL);
	treeNode* n6 = makeRootNode('E', n10, n9);
	treeNode* n5 = makeRootNode('F', NULL, NULL);
	treeNode* n4 = makeRootNode('G', NULL, n8);

 	treeNode* n3 = makeRootNode('B', n7, n6);
 	treeNode* n2 = makeRootNode('C', n5, n4);

	treeNode* n1 = makeRootNode('A', n3, n2);

 	getchar();
}