GeminiLight / virne

Virne is a simulator for resource allocation problems in network virtualization, mainly for virtual network embedding (VNE). It also is adaptable to VNE's variants, such as service function chain deployment (SFC Deployment), network slicing, etc.
https://virne.readthedocs.io
Apache License 2.0
99 stars 19 forks source link

如何更改优化目标 #9

Closed Map1eZz closed 1 year ago

Map1eZz commented 1 year ago

最近在学习VNE,想利用pso算法来进行优化,如果我想要更改这个算法的优化目标,需要在代码的哪些部分进行更改? 谢谢大佬!

GeminiLight commented 1 year ago

有关pso算法的实现可以在该目录中找到 Link

具体地,每个个体Particle继承自Individual。通用的优化目标,即fitness,在Individual类中实现:

    def calc_fitness(self, solution):
        # minimize
        if solution['result']:
            return solution['v_net_cost'] / solution['v_net_revenue']
            # return -solution['v_net_cost']
        return INFEASIBLE_FITNESS

您可以通过重载该函数来修改优化目标

Map1eZz commented 1 year ago

解决了,谢谢大佬!