문제점은 jade 에이전트를 실행하여 간단한 문제를 해결할 때 실행중인 에이전트의 양에 따라 jvm이 90s 이내에 힙 공간을 모두 소모한다는 것입니다. 에이전트의 목표는 여러 에이전트가로드 및 다른 세대를 나타내는 단순화 된 마이크로 그리드 모델에서로드와 생성의 균형을 맞추는 것입니다.JADE 에이전트가 힙 공간을 너무 빨리 사용함
public class House9 extends Agent
{
double load = 50;
boolean offline = false;
boolean valid = true;
int counter = 0;
double cur = 50;
int next;
public void setup()
{
addBehaviour(new SimpleBehaviour(this)
{
public void action()
{
//Adjusting load value
if(counter == 0)
{
load = (int)load;
cur = load;
next = 20+(int)(Math.random()*80);
//System.out.println("current: " + cur + " next " + next);
counter++;
}
else if(counter <= 1000)
{
load = load + ((next - cur)/1000);
//System.out.println("added " + ((next - cur)/1000) +" to load");
counter++;
}
else
{
counter = 0;
}
//System.out.println("counter " + counter);
//Sending result to the generator agent
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setContent(Double.toString(load));
msg.addReceiver(new AID("gen", AID.ISLOCALNAME));
myAgent.send(msg);
}
public boolean done()
{
return offline;
}
});
}
모든로드 에이전트이 동일하고, 다음과 같이 생성 에이전트는 다음 코드와 같이
로드 에이전트가 반복 될 때마다 새로운 값으로 발전기를 업데이트 동작이다 : 나는이 말에 옥 메시지 큐를 통해 삭제와 함께, 힙 공간을 소비 한 경우에 발생 에이전트에 대한 메시지 큐 크기를 제한하는 시도 이런 종류의 물건에 대한 인터넷에있는 다른 게시물에서
public class Generator extends Agent
{
int output = 100;
long time = System.currentTimeMillis();
int iter = 0;
public void setup()
{
System.out.println("Iterations,Time");
addBehaviour(new CyclicBehaviour(this)
{
public void action()
{
//myAgent.setQueueSize(2);
int temp = output;
ACLMessage reply = receive();
if(reply != null)
{
int load = Integer.parseInt(reply.getContent());
//System.out.println("current state--- output: " + output + " load: " + load);
if(load > output)
{
iter = 0;
while(load > output)
{
output = output + 10;
iter++;
}
//System.out.println((System.currentTimeMillis()-time)+ "," + iter);
}
else if(load < output)
{
iter = 0;
while(load < output)
{
output = output - 10;
iter--;
}
//System.out.println((System.currentTimeMillis()-time)+ "," + iter);
}
System.out.println((System.currentTimeMillis()-time)+ "," + iter + "," + load + "," + temp + "," + myAgent.getCurQueueSize());
}
}
});
}
}
각 속의 행동 반복. 하지만 그 중 아무 것도 차이가없는 것처럼 보였습니다. 더 많은 힙 공간을 추가하려고 시도했지만 메모리 부족 예외가 1 분 정도 지연되었습니다. 옥 엔진이 호출되고 옥의 GUI가 넷빈을 통해 시작되었습니다.
저는 멀티 에이전트 프로그래밍과 옥을 사용하는 것이 새로운 것이므로, 이런 종류의 시스템을 실행하는 데있어보다 우수하고 최적의 방법이있을 수 있으며 그 자체로 문제를 설명 할 수 있습니다. 그러나이 문제에 대한 도움을 주시면 감사하겠습니다.
덕분에, 캘럼
이 문제는 NetBeans 외부에서 실행될 때 존재합니까? netbeans 태그가 추가 된 이유를 잘 모르겠습니다. –