Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<torch::jit::IValue> generate_binary_vector_representation(uint32_t n_agents, uint32_t n_tasks)
- {
- // This is a ridiculous way of setting the elements' values,
- // but I couldn't find a better way to do it. Feel free to replace this
- // with something more efficient, since this is really damn costly.
- std::vector<int> vector_representation; vector_representation.reserve(n_agents * n_tasks);
- for (uint32_t agent_j = 0; agent_j < n_agents; agent_j++)
- {
- for (uint32_t task_i = 0; task_i < n_tasks; task_i++)
- {
- if (is_agent_in_coalition(agent_j, task_i))
- {
- vector_representation.push_back(1.0f);
- }
- else
- {
- vector_representation.push_back(0.0f);
- }
- }
- }
- torch::Tensor tensor = torch::from_blob(vector_representation.data(), { 1, n_agents * n_tasks });
- return std::vector<torch::jit::IValue>{std::move(tensor)};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement