May i ask has anyone know how to save the final agents for multi-anegt reforcement learning ?

5 visualizzazioni (ultimi 30 giorni)
For a multi-agent RL with three agents , after the agents are well trained, i use the follow command
trainingOpts.SaveAgentDirectory = pwd + "\Agents";
save(trainingOpts.SaveAgentDirectory + "/finalAgent1.0.mat",'agent')
to save the trained agents, but the commond window shows
Variable 'agent' not found
I have used this command to save the single agent, and it worked.
Has anyone know how to save the final agents for multi-anegt reforcement learning ?
thank you

Risposte (1)

arushi
arushi il 6 Set 2024
Hi 张 冠宇 ,
I understand that you have multi-agent reinforcement learning and want to save multiple agents, here is how you can do the same.
  • Create a cell array or structure to store the agents. Each element of the cell array or structure represents an agent.
  • Assign the trained agents to the corresponding elements of the cell array or structure.
  • Use the save command to save the entire cell array or structure containing the agents.
Here's an example of how you can modify your code to save multiple agents:
% crate cell array to store the agents
agents = cell(1, 3);
agents(1) = agentA;
agents(2) = agentB;
agents(3) = agentC;
%save agents
save("Agents/finalAgents.mat", 'agents');
Make sure the directory "Agents" exists before saving the agents, or adjust the path accordingly to a valid directory where you want to save the agents.
Please find links to below documentation which I believe will help you for further reference.
Hope this helps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by