当前位置: 首页>>代码示例>>C++>>正文


C++ Partition::addAttribute方法代码示例

本文整理汇总了C++中Partition::addAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Partition::addAttribute方法的具体用法?C++ Partition::addAttribute怎么用?C++ Partition::addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Partition的用法示例。


在下文中一共展示了Partition::addAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: constraints


//.........这里部分代码省略.........
                ctx->ind[j] = z(e,a,p,q);
                ctx->val[j] = -1.0;
                j++;
            }
            error = GRBaddconstr(ctx->model, e->A + 1, ctx->ind, ctx->val,
                                 GRB_GREATER_EQUAL, 0.0, NULL);
            if (error) return error;
        }
    }


    /* 6th set of constraints */
    for (int a = 0; a < e->A; ++a) {
        for (int p = 0; p < e->P; ++p) {
            for (int q = 0; q < e->Q; ++q) {
                ctx->ind[0] = z(e,a,p,q);
                ctx->val[0] = 1.0;
                ctx->ind[1] = x(e,a,p);
                ctx->val[1] = -1.0;
                ctx->ind[2] = y(e,p,q);
                ctx->val[2] = -1.0;
                error = GRBaddconstr(ctx->model, 3, ctx->ind, ctx->val,
                                     GRB_GREATER_EQUAL, -1.0, NULL);
                if (error) return error;
            }
        }
    }

    /* 7th set of constraints */
    for (int p = 0; p < e->P; ++p) {
        j = 0;
        for (int a = 0; a < e->A; ++a) {
            ctx->ind[j] = x(e,a,p);
            ctx->val[j] = 1.0;
            j++;
        }
        ctx->ind[j] = u(e,p);
        ctx->val[j] = -1.0;
        error = GRBaddconstr(ctx->model, e->A+1, ctx->ind, ctx->val,
                             GRB_GREATER_EQUAL, 0.0, NULL);
        if (error) return error;

    }

    /* 8th set of constraints */
    for (int p = 0; p < e->P; ++p) {
        j = 0;
        ctx->ind[j] = u(e,p);
        ctx->val[j] = K();
        j++;
        for (int a = 0; a < e->A; ++a) {
            ctx->ind[j] = x(e,a,p);
            ctx->val[j] = -1.0;
            j++;
        }
        error = GRBaddconstr(ctx->model, e->A+1, ctx->ind, ctx->val,
                             GRB_GREATER_EQUAL, 0.0, NULL);
        if (error) return error;
    }



    auto const & attributes = workload->getAttributes();
    Cost cost(stats);
    Partition part;
    for_each(attributes.begin(), attributes.end(), [&] (Attribute const * attr) {
            part.addAttribute(attr);
        });

    double limit =  cost.getPartitionSize(part) * (1 + alpha());
    double u_const =
        (SystemConstants::edgeIdSize + SystemConstants::timestampSize) * c_e()
        + (SystemConstants::headVertexSize + SystemConstants::numEntriesSize) * c_n();

    /* 9th set of constraints */
    j = 0;
    for (int p = 0; p < e->P; ++p) {
        ctx->ind[j] = u(e,p);
        ctx->val[j] = u_const;
        j++;
    }

    for (int p = 0; p < e->P; ++p) {
        for (int a = 0; a < e->A; ++a) {
            ctx->ind[j] = x(e,a,p);
            ctx->val[j] = stats.getAvgSize(workload->getAttribute(a).getIndex()) * c_e();
            j++;
        }
    }

    error = GRBaddconstr(ctx->model, e->P + e->P*e->A, ctx->ind, ctx->val,
                         GRB_LESS_EQUAL, limit, NULL);
    if (error) return error;


    error = GRBupdatemodel(ctx->model);
    if (error) return error;

    return error;
}
开发者ID:usi-systems,项目名称:railwaydb,代码行数:101,代码来源:OptimalOverlapping.cpp

示例2: constraints


//.........这里部分代码省略.........
            error = GRBaddconstr(ctx->model, e->A + 1, ctx->ind, ctx->val,
                                 GRB_GREATER_EQUAL, 0.0, NULL);
            if (error) return error;
        }
    }

    /* Third set of constraints */
    for (int p = 0; p < e->P; ++p) {
        for (int q = 0; q < e->Q; ++q) {
            j = 0;
            ctx->ind[j] = y(e,p,q);
            ctx->val[j] = K();
            j++;
            for (int a = 0; a < e->A; ++a) {
                ctx->ind[j] = x(e,a,p);
                ctx->val[j] = -(accesses(queries,q,a));
                j++;
            }
            error = GRBaddconstr(ctx->model, e->A + 1, ctx->ind, ctx->val,
                                 GRB_GREATER_EQUAL, 0.0, NULL);
            if (error) return error;
        }
    }

    /* Fourth set of constraints */
    for (int a = 0; a < e->A; ++a) {
        for (int p = 0; p < e->P; ++p) {
            for (int q = 0; q < e->Q; ++q) {
                ctx->ind[0] = z(e,a,p,q);
                ctx->val[0] = 1.0;
                ctx->ind[1] = x(e,a,p);
                ctx->val[1] = -1.0;
                ctx->ind[2] = y(e,p,q);
                ctx->val[2] = -1.0;
                error = GRBaddconstr(ctx->model, 3, ctx->ind, ctx->val,
                                     GRB_GREATER_EQUAL, -1.0, NULL);
                if (error) return error;
            }
        }
    }

    /* Fifth set of constraints */
    for (int p = 0; p < e->P; ++p) {
        j = 0;
        for (int a = 0; a < e->A; ++a) {
            ctx->ind[j] = x(e,a,p);
            ctx->val[j] = 1.0;
            j++;
        }
        ctx->ind[j] = u(e,p);
        ctx->val[j] = -1.0;
        error = GRBaddconstr(ctx->model, e->A+1, ctx->ind, ctx->val,
                             GRB_GREATER_EQUAL, 0.0, NULL);
        if (error) return error;

    }

    /* Sixth set of constraints */
    for (int p = 0; p < e->P; ++p) {
        j = 0;
        ctx->ind[j] = u(e,p);
        ctx->val[j] = K();
        j++;
        for (int a = 0; a < e->A; ++a) {
            ctx->ind[j] = x(e,a,p);
            ctx->val[j] = -1.0;
            j++;
        }
        error = GRBaddconstr(ctx->model, e->A+1, ctx->ind, ctx->val,
                             GRB_GREATER_EQUAL, 0.0, NULL);
        if (error) return error;
    }


    auto const & attributes = workload->getAttributes();
    Cost cost(stats);
    Partition part;
    for_each(attributes.begin(), attributes.end(), [&] (Attribute const * attr) {
            part.addAttribute(attr);
        });

    double limit = 1.0 + alpha() /  (1.0 - (s(workload->getAttributes(), stats) * c_e()) / cost.getPartitionSize(part));

    /* 6th set of constraints */
    j = 0;
    for (int p = 0; p < e->P; ++p) {
        int index = u(e,p);
        ctx->ind[j] = index;
        ctx->val[j] = 1;
        j++;
    }
    error = GRBaddconstr(ctx->model, e->P, ctx->ind, ctx->val,
                         GRB_LESS_EQUAL, limit, NULL);
    if (error) return error;

    error = GRBupdatemodel(ctx->model);
    if (error) return error;

    return error;
}
开发者ID:usi-systems,项目名称:railwaydb,代码行数:101,代码来源:OptimalNonOverlapping.cpp


注:本文中的Partition::addAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。