void YUMPlugin::on_buttonBox_accepted() { for(int index = 0; index < DataFlow::pluginDataListSize(); ++index) { PluginData pluginNode = DataFlow::getPluginDataList().at(index); QFile file(pluginNode.pluginFileName); file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream inFlow(&file); inFlow.setCodec("UTF-8"); QString pluginData = inFlow.readAll(); QTextStream editFlow(&pluginData); editFlow.setCodec("UTF-8"); file.close(); file.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text); QTextStream outFlow(&file); outFlow.setCodec("UTF-8"); int line = 0; for(;!editFlow.atEnd();) { if(line == (pluginNode.pluginEnabledPosition - 1)) { outFlow << "enabled=" << pluginNode.pluginEnabled[1] << "\n"; editFlow.readLine(); ++line; continue; }// if outFlow << editFlow.readLine() << "\n"; ++line; }// for outFlow.flush(); file.close(); }// for this->accept(); }// Accepted
void LpSolver::populatebyrow (CplexConverter& cplexConverter, IloModel model, IloNumVarArray x, IloRangeArray c) { IloEnv env = model.getEnv(); // CAPITAL LETTERS MEAN I NEED YOUR HELP, here is help // IloExpr cost(env); // Create Variables // cout << "size of var: " << cplexConverter.variables.size() << endl; for (int i = 0; i < cplexConverter.variables.size(); ++i){ IloNumVar iloVar(env, 0.0, cplexConverter.capacities[i], IloNumVar::Int); // cout << iloVar << endl; x.add(iloVar); } //Capacity Constraints for (auto &it : cplexConverter.atomicIdToVarIdDict){ IloExpr t(env); // cout << "adding constraint "; for (int j = 0; j < it.second.size(); j++){ // cout << "x[" << it.second[j] << "] + "; t += x[it.second[j]]; } // cout << endl; c.add(t <= cplexConverter.graph->atomicEdges[it.first]->capacity); // cout << c << endl; t.end(); } // other constraints for (auto nodePair : cplexConverter.graph->nodes){ // For all nodes Node* n = nodePair.second; if(n == cplexConverter.src){ // source constraints // IloExpr inFlow(env); IloExpr outFlow(env); for(auto &atoIn : n->atomicEdge_in){ int aeId = atoIn.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; outFlow += x[vId]; // cost += cplexConverter.graph->atomicEdges[cplexConverter.variables[vId].atomicEdgeId]->interest_rate * x[vId]; } } for (auto &atoOut : n->atomicEdge_out){ int aeId = atoOut.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; // inFlow += x[vId]; c.add(x[vId] == 0); // cost -= cplexConverter.graph->atomicEdges[cplexConverter.variables[vId].atomicEdgeId]->interest_rate * x[vId]; } } c.add(outFlow == cplexConverter.request); // inFlow.end(); outFlow.end(); } else if(n == cplexConverter.dest){ // destination constraints IloExpr inFlow(env); // IloExpr outFlow(env); for(auto &atoIn : n->atomicEdge_in){ int aeId = atoIn.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; // outFlow += x[vId]; c.add(x[vId] == 0); } } for (auto &atoOut : n->atomicEdge_out){ int aeId = atoOut.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; inFlow += x[vId]; } } c.add(inFlow == cplexConverter.request); inFlow.end(); // outFlow.end(); } else { // Monotonicity Constraints for (int i = 0; i < credNetConstants.totalIrs.size(); ++i){ IloExpr tempin(env); IloExpr tempout(env); for (auto &atoIn : n->atomicEdge_in){ int aeId = atoIn.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; if (cplexConverter.variables[vId].interest_rate <= credNetConstants.totalIrs[i]){ tempout += x[vId]; } } } for (auto &atoOut : n->atomicEdge_out){ int aeId = atoOut.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; if (cplexConverter.variables[vId].interest_rate <= credNetConstants.totalIrs[i]){ tempin += x[vId]; } } } c.add(tempout - tempin >= 0); tempout.end(); tempin.end(); } //Flow Constraints IloExpr inFlow(env); IloExpr outFlow(env); for(auto &atoIn : n->atomicEdge_in){ int aeId = atoIn.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; outFlow += x[vId]; } } for (auto &atoOut : n->atomicEdge_out){ int aeId = atoOut.second->atomicEdgeId; for (int j = 0; j < cplexConverter.atomicIdToVarIdDict[aeId].size(); j++){ // var Id int vId = cplexConverter.atomicIdToVarIdDict[aeId][j]; inFlow += x[vId]; } } c.add(inFlow - outFlow == 0); inFlow.end(); outFlow.end(); } } model.add(c); // model.add(IloMinimize(env, cost)); // model.add(IloMaximize(env,cost)); //option to minimize cost // cost.end(); } // END populatebyrow