{"action":"created","issue":{"url":"https://api.github.com/repos/google/or-tools/issues/912","repository_url":"https://api.github.com/repos/google/or-tools","labels_url":"https://api.github.com/repos/google/or-tools/issues/912/labels{/name}","comments_url":"https://api.github.com/repos/google/or-tools/issues/912/comments","events_url":"https://api.github.com/repos/google/or-tools/issues/912/events","html_url":"https://github.com/google/or-tools/issues/912","id":375372720,"node_id":"MDU6SXNzdWUzNzUzNzI3MjA=","number":912,"title":"Cut generators in CPModelProto","user":{"login":"TheCoolRob","id":3518425,"node_id":"MDQ6VXNlcjM1MTg0MjU=","avatar_url":"https://avatars0.githubusercontent.com/u/3518425?v=4","gravatar_id":"","url":"https://api.github.com/users/TheCoolRob","html_url":"https://github.com/TheCoolRob","followers_url":"https://api.github.com/users/TheCoolRob/followers","following_url":"https://api.github.com/users/TheCoolRob/following{/other_user}","gists_url":"https://api.github.com/users/TheCoolRob/gists{/gist_id}","starred_url":"https://api.github.com/users/TheCoolRob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheCoolRob/subscriptions","organizations_url":"https://api.github.com/users/TheCoolRob/orgs","repos_url":"https://api.github.com/users/TheCoolRob/repos","events_url":"https://api.github.com/users/TheCoolRob/events{/privacy}","received_events_url":"https://api.github.com/users/TheCoolRob/received_events","type":"User","site_admin":false},"labels":[{"id":179258464,"node_id":"MDU6TGFiZWwxNzkyNTg0NjQ=","url":"https://api.github.com/repos/google/or-tools/labels/Feature%20Request","name":"Feature Request","color":"006b75","default":false},{"id":1044855300,"node_id":"MDU6TGFiZWwxMDQ0ODU1MzAw","url":"https://api.github.com/repos/google/or-tools/labels/Solver:%20CP%20/%20CP-SAT%20Solver","name":"Solver: CP / CP-SAT Solver","color":"166c93","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2018-10-30T08:31:28Z","updated_at":"2018-12-11T07:49:15Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi\r\n\r\nFollowing on from #666 - I found the reason why I wasn't using the `CPModelProto`. I've got some custom cutting planes I'm implementing over a SAT model and using the CutGenerator callbacks. \r\n\r\nI wasn't able to find an interface on the `CPModelProto` that allows for adding a cut-callback. I would prefer to work at the CPModel level rather than SAT (as per Laurents' suggestion) but perhaps I'm just missing the part of the API that gives the appropriate functionality? \r\n\r\nIt could be that it's not available at that level - passing a pointer to a callback over the proto model seems like a bad idea and something that probably wouldn't be supported. I suppose this issue is simply then for confirmation that this is the case or not.\r\n\r\nThanks\r\n"},"comment":{"url":"https://api.github.com/repos/google/or-tools/issues/comments/446104228","html_url":"https://github.com/google/or-tools/issues/912#issuecomment-446104228","issue_url":"https://api.github.com/repos/google/or-tools/issues/912","id":446104228,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjEwNDIyOA==","user":{"login":"TheCoolRob","id":3518425,"node_id":"MDQ6VXNlcjM1MTg0MjU=","avatar_url":"https://avatars0.githubusercontent.com/u/3518425?v=4","gravatar_id":"","url":"https://api.github.com/users/TheCoolRob","html_url":"https://github.com/TheCoolRob","followers_url":"https://api.github.com/users/TheCoolRob/followers","following_url":"https://api.github.com/users/TheCoolRob/following{/other_user}","gists_url":"https://api.github.com/users/TheCoolRob/gists{/gist_id}","starred_url":"https://api.github.com/users/TheCoolRob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheCoolRob/subscriptions","organizations_url":"https://api.github.com/users/TheCoolRob/orgs","repos_url":"https://api.github.com/users/TheCoolRob/repos","events_url":"https://api.github.com/users/TheCoolRob/events{/privacy}","received_events_url":"https://api.github.com/users/TheCoolRob/received_events","type":"User","site_admin":false},"created_at":"2018-12-11T07:49:15Z","updated_at":"2018-12-11T07:49:15Z","author_association":"CONTRIBUTOR","body":"This is a snippet of the CPModelProto that I'm using:\r\n```\r\n  CpModelProto cp_model;\r\n\r\n  auto new_variable = [&cp_model](int64 lb, int64 ub) {\r\n    CHECK_LE(lb, ub);\r\n    const int index = cp_model.variables_size();\r\n    IntegerVariableProto *const var = cp_model.add_variables();\r\n    var->add_domain(lb);\r\n    var->add_domain(ub);\r\n    return index;\r\n  };\r\n\r\n  auto new_linear_constraint =\r\n      [&cp_model](vector<int> indexes, vector<int> coef, double lb, double ub) {\r\n        LinearConstraintProto *const lin =\r\n            cp_model.add_constraints()->mutable_linear();\r\n        for (int i = 0; i < indexes.size(); i++) {\r\n          lin->add_vars(indexes[i]);\r\n          lin->add_coeffs(coef[i]);\r\n        }\r\n        lin->add_domain(lb);\r\n        lin->add_domain(ub);\r\n      };\r\n\r\n  vector<vector<int>> vars;\r\n\r\n  auto objective = cp_model.mutable_objective();\r\n\r\n  for (int i = 0; i < basedim; i++) {\r\n    vector<int> tmp;\r\n    for (int j = 0; j < basedim; j++) {\r\n      int ub = i == j ? 0 : 1;  // diagonals not allowed\r\n      tmp.push_back(new_variable(0, ub));\r\n      objective->add_vars(tmp.back());\r\n      objective->add_coeffs((int64)(distance_matrix[i][j] * 1000));\r\n    }\r\n    vars.push_back(tmp);\r\n  }\r\n\r\n  for (int i = 0; i < basedim; i++) {\r\n    vector<int> indexes;\r\n    vector<int> coefficients;\r\n    for (int j = 0; j < basedim; j++) {\r\n      indexes.push_back(vars[i][j]);\r\n      coefficients.push_back(1.0);\r\n    }\r\n    new_linear_constraint(indexes, coefficients, 1, 1);\r\n  }\r\n\r\n  auto circuit = cp_model.add_constraints()->mutable_circuit();\r\n\r\n  for (int i = 0; i < basedim; i++) {\r\n    vector<int> indexes;\r\n    vector<int> coefficients;\r\n    for (int j = 0; j < basedim; j++) {\r\n      indexes.push_back(vars[j][i]);\r\n      coefficients.push_back(1.0);\r\n\r\n      circuit->add_tails(i);\r\n      circuit->add_heads(j);\r\n      circuit->add_literals(vars[i][j]);\r\n    }\r\n    new_linear_constraint(indexes, coefficients, 1, 1);\r\n  }\r\n\r\n  Model model;\r\n  const CpSolverResponse response = SolveCpModel(cp_model, &model);\r\n  std::cout << \"SAT solve time: \" << response.wall_time() << std::endl;\r\n```\r\nThis doesn't use the connect cuts that you've written up for the model from what I can tell (unless there's some magic behind the circuit when the model gets handled behind the proto layer).\r\n\r\nI can run a separate test against your connect cuts to confirm where it lies on the performance curve?\r\n\r\n"}}
{"actor":{"display_login":"TheCoolRob"}}