Cloudslab / iFogSim1

The iFogSim Toolkit for Modeling and Simulation of Resource Management Techniques in Internet of Things, Edge and Fog Computing Environments
181 stars 117 forks source link

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

Open FWHDeveloper opened 6 years ago

FWHDeveloper commented 6 years ago

Please where can I add a scheduling algorithm in ifogsim

Irfan508 commented 5 years ago

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

sujannou commented 4 years ago

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?

Irfan508 commented 4 years ago

@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

sujannou commented 4 years ago

Thanks Irfan508 for your valuable comments.

sujannou commented 4 years ago

@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 path) { if(path.size()==0)return; List placedModules = new ArrayList(); 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 path)" which used any traditional scheduling algorithms like FCFS, SJF, Round Robbin. My email id is ersujan@gmail.com. Hope the basic and traditional scheduling algorithms will help me to understand better on working of scheduling algorithms in iFogsim.

Irfan508 commented 4 years ago

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 commented 4 years ago

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

syedrizwanhassan commented 4 years ago

@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.

syedrizwanhassan@yahoo.com

Thanks

rupinder516 commented 4 years ago

@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?

KrishnanandRai commented 3 years ago

@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.

raikrnrai@gmail.com

Tauseef-45 commented 3 years ago

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

Shelly1193 commented 3 years ago

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.

0Vipin0 commented 3 years ago

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

pushkal00 commented 3 years ago

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

Shelly1193 commented 3 years ago

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 .

pushkal00 commented 3 years ago

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

srinu49 commented 3 years ago

@Irfan508 Can you please share the code of https://ieeexplore.ieee.org/document/9057799 mentioned link. My email id : srinivas.mirampalli@gmail.com

aishajohani commented 3 years ago

Hello @Irfan508 Can you please share me too the code of https://ieeexplore.ieee.org/document/9057799 mentioned link. My email id : aisha.johani@gmail.com

aishajohani commented 3 years ago

Hello @pushkal00 , have you received any code? If so please share me on this email id: aisha.johani@gmail.com

aishajohani commented 3 years ago

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: aisha.johani@gmail.com

abeerailyas commented 2 years ago

did anyone receive the code? kindly email me too at abeera_ilyas@hotmail.com

Shelly1193 commented 2 years ago

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 commented 2 years ago

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: @.***>

rozaasa commented 2 years ago

Can you please share the working code.

rozaasa commented 2 years ago

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 commented 2 years ago

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

can you please help me

fath004 commented 2 years ago

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 .

rozaasa commented 2 years ago

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?

Shelly1193 commented 2 years ago

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: @.***>

Tauseef-45 commented 2 years ago

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: @.***>

Yamna2023 commented 1 year ago

Hi everyone, can you send me the code please in this mail : yam.yamna48@gmail.com

Yamna2023 commented 1 year ago

i need PSO and ACO code please send me the code please yam.yamna48@gmail.com