iFogSim1 icon indicating copy to clipboard operation
iFogSim1 copied to clipboard

Add a scheduling algorithm like (PSO, ABC ) in ifogsim

Open FWHDeveloper opened this issue 6 years ago • 32 comments

Please where can I add a scheduling algorithm in ifogsim

FWHDeveloper avatar Sep 18 '18 07:09 FWHDeveloper

You should extend the ModulePlacement class. The existing scheduling algorithm is given in ModulePlacementEdgewards.java

Irfan508 avatar Apr 26 '19 11:04 Irfan508

Dear Irfan508 Could you please share on which method of ModulePlacementEdgewards.java/ModulePlacement.java class is scheduling algorithm implemented and which scheduling algorithm is implemented in the default?

sujannou avatar Jun 09 '20 18:06 sujannou

@sujannou U may either extend the ModulePlacement class and write the code from scratch or you can choose to modify the _placeModulesInPath(path)_function only By default the AppModules are placed on the fog device with lowest transmission delay

Irfan508 avatar Jun 10 '20 04:06 Irfan508

Thanks Irfan508 for your valuable comments.

sujannou avatar Jun 11 '20 18:06 sujannou

@Irfan508 , which parameter shows any AppModules have the lowest transmission delay? I am still not clear, which scheduling algorithm is used by default? Is it FCFS, SJF, or other. The codes in "placeModulesInPath" method are as follow; private void placeModulesInPath(List<Integer> path) { if(path.size()==0)return; List<String> placedModules = new ArrayList<String>(); Map<AppEdge, Double> appEdgeToRate = new HashMap<AppEdge, Double>();

	/**
	 * Periodic edges have a fixed periodicity of tuples, so setting the tuple rate beforehand
	 */
	for(AppEdge edge : getApplication().getEdges()){
		if(edge.isPeriodic()){
			appEdgeToRate.put(edge, 1/edge.getPeriodicity());
		}
	}
	
	for(Integer deviceId : path){
		FogDevice device = getFogDeviceById(deviceId);
		Map<String, Integer> sensorsAssociated = getAssociatedSensors(device);
		Map<String, Integer> actuatorsAssociated = getAssociatedActuators(device);
		placedModules.addAll(sensorsAssociated.keySet()); // ADDING ALL SENSORS TO PLACED LIST
		placedModules.addAll(actuatorsAssociated.keySet()); // ADDING ALL ACTUATORS TO PLACED LIST
		
		/*
		 * Setting the rates of application edges emanating from sensors
		 */
		for(String sensor : sensorsAssociated.keySet()){
			for(AppEdge edge : getApplication().getEdges()){
				if(edge.getSource().equals(sensor)){
					appEdgeToRate.put(edge, sensorsAssociated.get(sensor)*getRateOfSensor(sensor));
				}
			}
		}
					
		/*
		 * Updating the AppEdge rates for the entire application based on knowledge so far
		 */
		boolean changed = true;
		while(changed){		//Loop runs as long as some new information is added
			changed=false;
			Map<AppEdge, Double> rateMap = new HashMap<AppEdge, Double>(appEdgeToRate);
			for(AppEdge edge : rateMap.keySet()){
				AppModule destModule = getApplication().getModuleByName(edge.getDestination());
				if(destModule == null)continue;
				Map<Pair<String, String>, SelectivityModel> map = destModule.getSelectivityMap();
				for(Pair<String, String> pair : map.keySet()){
					if(pair.getFirst().equals(edge.getTupleType())){
						double outputRate = appEdgeToRate.get(edge)*map.get(pair).getMeanRate(); // getting mean rate from SelectivityModel
						AppEdge outputEdge = getApplication().getEdgeMap().get(pair.getSecond());
						if(!appEdgeToRate.containsKey(outputEdge) || appEdgeToRate.get(outputEdge)!=outputRate){
							// if some new information is available
							changed = true;
						}
						appEdgeToRate.put(outputEdge, outputRate);
					}
				}
			}
		}
		
		/*
		 * Getting the list of modules ready to be placed on current device on path
		 */
		List<String> modulesToPlace = getModulesToPlace(placedModules);
		
		while(modulesToPlace.size() > 0){ // Loop runs until all modules in modulesToPlace are deployed in the path
			String moduleName = modulesToPlace.get(0);
			double totalCpuLoad = 0;
			
			//IF MODULE IS ALREADY PLACED UPSTREAM, THEN UPDATE THE EXISTING MODULE
			int upsteamDeviceId = isPlacedUpstream(moduleName, path);
			if(upsteamDeviceId > 0){
				if(upsteamDeviceId==deviceId){
					placedModules.add(moduleName);
					modulesToPlace = getModulesToPlace(placedModules);
					
					// NOW THE MODULE TO PLACE IS IN THE CURRENT DEVICE. CHECK IF THE NODE CAN SUSTAIN THE MODULE
					for(AppEdge edge : getApplication().getEdges()){		// take all incoming edges
						if(edge.getDestination().equals(moduleName)){
							double rate = appEdgeToRate.get(edge);
							totalCpuLoad += rate*edge.getTupleCpuLength();
						}
					}
					if(totalCpuLoad + getCurrentCpuLoad().get(deviceId) > device.getHost().getTotalMips()){
						Logger.debug("ModulePlacementEdgeward", "Need to shift module "+moduleName+" upstream from device " + device.getName());
						List<String> _placedOperators = shiftModuleNorth(moduleName, totalCpuLoad, deviceId, modulesToPlace);
						for(String placedOperator : _placedOperators){
							if(!placedModules.contains(placedOperator))
								placedModules.add(placedOperator);
						}
					} else{
						placedModules.add(moduleName);
						getCurrentCpuLoad().put(deviceId, getCurrentCpuLoad().get(deviceId)+totalCpuLoad);
						getCurrentModuleInstanceNum().get(deviceId).put(moduleName, getCurrentModuleInstanceNum().get(deviceId).get(moduleName)+1);
						Logger.debug("ModulePlacementEdgeward", "AppModule "+moduleName+" can be created on device "+device.getName());
					}
				}
			}else{
				// FINDING OUT WHETHER PLACEMENT OF OPERATOR ON DEVICE IS POSSIBLE
				for(AppEdge edge : getApplication().getEdges()){		// take all incoming edges
					if(edge.getDestination().equals(moduleName)){
						double rate = appEdgeToRate.get(edge);
						totalCpuLoad += rate*edge.getTupleCpuLength();
					}
				}
					
				if(totalCpuLoad + getCurrentCpuLoad().get(deviceId) > device.getHost().getTotalMips()){
					Logger.debug("ModulePlacementEdgeward", "Placement of operator "+moduleName+ "NOT POSSIBLE on device "+device.getName());
				}
				else{
					Logger.debug("ModulePlacementEdgeward", "Placement of operator "+moduleName+ " on device "+device.getName() + " successful.");
					getCurrentCpuLoad().put(deviceId, totalCpuLoad + getCurrentCpuLoad().get(deviceId));
					System.out.println("Placement of operator "+moduleName+ " on device "+device.getName() + " successful.");

					if(!currentModuleMap.containsKey(deviceId))
						currentModuleMap.put(deviceId, new ArrayList<String>());
					currentModuleMap.get(deviceId).add(moduleName);
					placedModules.add(moduleName);
					modulesToPlace = getModulesToPlace(placedModules);
					getCurrentModuleLoadMap().get(device.getId()).put(moduleName, totalCpuLoad);
					
					int max = 1;
					for(AppEdge edge : getApplication().getEdges()){
						if(edge.getSource().equals(moduleName) && actuatorsAssociated.containsKey(edge.getDestination()))
							max = Math.max(actuatorsAssociated.get(edge.getDestination()), max);
						if(edge.getDestination().equals(moduleName) && sensorsAssociated.containsKey(edge.getSource()))
							max = Math.max(sensorsAssociated.get(edge.getSource()), max);
					}
					getCurrentModuleInstanceNum().get(deviceId).put(moduleName, max);
				}
			}
		
		
			modulesToPlace.remove(moduleName);
		}
		
	}
	
}

Could you please share with me some codes done/modified in the method "placeModulesInPath(List<Integer> path)" which used any traditional scheduling algorithms like FCFS, SJF, Round Robbin. My email id is [email protected]. Hope the basic and traditional scheduling algorithms will help me to understand better on working of scheduling algorithms in iFogsim.

sujannou avatar Jun 11 '20 18:06 sujannou

I would suggest u go through the base paper of iFogSim again. the default scheduling algorithm is given in the paper. Also during scheduling, leaf-to-root traversal is followed in network topology, with leaf node having the least transmission delay and root having the maximum delay.

Irfan508 avatar Jun 13 '20 04:06 Irfan508

the algorithm implemented in "IrfanEdgewards.java" is given in https://ieeexplore.ieee.org/document/9057799

Irfan508 avatar Jun 16 '20 04:06 Irfan508

@Irfan508

Dear Sir. I have the same issue, can you please send me the code to re-simulate the simulations performed in your above said paper.

[email protected]

Thanks

syedrizwanhassan avatar Sep 16 '20 13:09 syedrizwanhassan

@Irfan508

I am a student who has been given the assignment to implement the PSO algorithm in iFogSim to reduce latency, energy consumption, and cost. I have read some research papers regarding it but I am still confused and don't know how to proceed. Can you give me a little guidance?

rupinder516 avatar Oct 18 '20 04:10 rupinder516

@Irfan508

I am a student who has been given the assignment to implement the PSO algorithm in iFogSim to reduce latency, energy consumption, and cost. I have read some research papers regarding it but I am still confused and don't know how to proceed. Can you give me a little guidance?

@rupinder516 I am also working on same type of idea, if you have any leads please connect with me on following mail id.

[email protected]

KrishnanandRai avatar Nov 21 '20 09:11 KrishnanandRai

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

Tauseef-45 avatar Jan 18 '21 12:01 Tauseef-45

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

Sir, can you please share the code for PSO and ACO in github.

Shelly1193 avatar Mar 03 '21 10:03 Shelly1193

@Shelly1193 @Tauseef-45 If you are working on the scheduling code, can you please share the code?

0Vipin0 avatar May 17 '21 19:05 0Vipin0

Could anyone please help in the implementation of tuple scheduling in ifogsim?

pushkal00 avatar May 18 '21 21:05 pushkal00

hey did you received the code ? because the other guy is working, i am also waiting for him to reply

Regards Shelly Garg

On Tue, May 18, 2021 at 1:02 AM Vipin Malik @.***> wrote:

@Shelly1193 https://github.com/Shelly1193 @Tauseef-45 https://github.com/Tauseef-45 If you are working on the scheduling code, can you please share the code?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Cloudslab/iFogSim/issues/7#issuecomment-842577713, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW5MEBVLPC6QOY4PUNQEITTOFVMZANCNFSM4FVVL5OQ .

Shelly1193 avatar Jun 01 '21 06:06 Shelly1193

No, I haven't received any code related to ifogsim yet

pushkal00 avatar Jun 01 '21 11:06 pushkal00

@Irfan508 Can you please share the code of https://ieeexplore.ieee.org/document/9057799 mentioned link. My email id : [email protected]

srinu49 avatar Aug 15 '21 08:08 srinu49

Hello @Irfan508 Can you please share me too the code of https://ieeexplore.ieee.org/document/9057799 mentioned link. My email id : [email protected]

aishajohani avatar Aug 30 '21 01:08 aishajohani

Hello @pushkal00 , have you received any code? If so please share me on this email id: [email protected]

aishajohani avatar Aug 30 '21 01:08 aishajohani

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

Hi @Tauseef-45 , can you please share me the code On this email id: [email protected]

aishajohani avatar Aug 30 '21 01:08 aishajohani

did anyone receive the code? kindly email me too at [email protected]

abeerailyas avatar Apr 27 '22 03:04 abeerailyas

Can you please share the code.

On Wed, Jul 6, 2022, 21:27 fath004 @.***> wrote:

Finally, PSO works with me

— Reply to this email directly, view it on GitHub https://github.com/Cloudslab/iFogSim1/issues/7#issuecomment-1176399342, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW5MEH3K6HCTYMBV7IHE33VSWUHVANCNFSM4FVVL5OQ . You are receiving this because you were mentioned.Message ID: @.***>

Shelly1193 avatar Jul 06 '22 18:07 Shelly1193

Can you please share the working code.

On Wed, Jul 6, 2022, 21:27 fath004 @.***> wrote:

Finally, PSO works with me

— Reply to this email directly, view it on GitHub https://github.com/Cloudslab/iFogSim1/issues/7#issuecomment-1176399342, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW5MEH3K6HCTYMBV7IHE33VSWUHVANCNFSM4FVVL5OQ . You are receiving this because you were mentioned.Message ID: @.***>

Shelly1193 avatar Jul 06 '22 18:07 Shelly1193

Can you please share the working code.

rozaasa avatar Oct 07 '22 13:10 rozaasa

I would suggest u go through the base paper of iFogSim again. the default scheduling algorithm is given in the paper. Also during scheduling, leaf-to-root traversal is followed in network topology, with leaf node having the least transmission delay and root having the maximum delay.

can you please help me

rozaasa avatar Oct 07 '22 13:10 rozaasa

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

can you please help me

rozaasa avatar Oct 07 '22 13:10 rozaasa

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

I have no idea why you wrote done with PSO and ACO without helping others and you ask for help. I did ask for PSO code a long time ago and I deleted my comments. FYI I finished SJF , FCFS, and GCN but really I am done with these useless comments. Everyone asks for help and no one wants to help . Do not expect anyone to help you if you do not wanna help others .

fath004 avatar Oct 17 '22 15:10 fath004

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

I have no idea why you wrote done with PSO and ACO without helping others and you ask for help. I did ask for PSO code a long time ago and I deleted my comments. FYI I finished SJF , FCFS, and GCN but really I am done with these useless comments. Everyone asks for help and no one wants to help . Do not expect anyone to help you if you do not wanna help others .

please can you help me?

rozaasa avatar Oct 21 '22 10:10 rozaasa

Hi can you please share working algorithm code of PSO and ACO?

On Fri, Oct 21, 2022, 16:16 rozaasa @.***> wrote:

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

I have no idea why you wrote done with PSO and ACO without helping others and you ask for help. I did ask for PSO code a long time ago and I deleted my comments. FYI I finished SJF , FCFS, and GCN but really I am done with these useless comments. Everyone asks for help and no one wants to help . Do not expect anyone to help you if you do not wanna help others .

please can you help me?

— Reply to this email directly, view it on GitHub https://github.com/Cloudslab/iFogSim1/issues/7#issuecomment-1286785208, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALW5MEBPW6ZP7OMJD47JY5DWEJYBDANCNFSM4FVVL5OQ . You are receiving this because you were mentioned.Message ID: @.***>

Shelly1193 avatar Oct 21 '22 11:10 Shelly1193

Hi there On Oct 21, 2022 4:17 PM, "Shelly1193" @.***> wrote:

Hi can you please share working algorithm code of PSO and ACO?

On Fri, Oct 21, 2022, 16:16 rozaasa @.***> wrote:

Done with PSO and ACO in iFogsim, but need firs come first serve policy help

I have no idea why you wrote done with PSO and ACO without helping others and you ask for help. I did ask for PSO code a long time ago and I deleted my comments. FYI I finished SJF , FCFS, and GCN but really I am done with these useless comments. Everyone asks for help and no one wants to help . Do not expect anyone to help you if you do not wanna help others .

please can you help me?

— Reply to this email directly, view it on GitHub <https://github.com/Cloudslab/iFogSim1/issues/7#issuecomment-1286785208 , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ALW5MEBPW6ZP7OMJD47JY5DWEJYBDANCNFSM4FVVL5OQ> . You are receiving this because you were mentioned.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/Cloudslab/iFogSim1/issues/7#issuecomment-1286819147, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASQGLTJA7EJP2OZDVLRODLTWEJ3VXANCNFSM4FVVL5OQ . You are receiving this because you were mentioned.Message ID: @.***>

Tauseef-45 avatar Oct 21 '22 16:10 Tauseef-45