基于分解的多目标问题中均匀权重向量集合的生成

原文

在多目标进化算法中,权重向量的生成非常重要。

Das I, Dennis J E. Normal-boundary intersection: A new method for generating the Pareto surface in nonlinear multicriteria optimization problems[J]. SIAM Journal on Optimization, 1998, 8(3): 631-657.

上述这篇文章提出了生成空间中均匀分布的权重向量的方法。该方法对m维空间进行采样,得到个在空间中均匀分布的权重向量,其中,H>0为每个目标方向上的采样个数,其采样步长为δ=1/H。

当m=3,H=4时,生成的均匀分布的权重向量有个,如下所示:

weightVector

 

实现代码如下:

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
    int m; // the number of objectives
    double stepsize;
    double H; // H = 1 / stepsize
    cout << "Please input the number of objectives (m): \n";
    cin >> m;
    cout << "Please input the stepsize (1/H): \n";
    cin >> stepsize;
    H = 1 / stepsize;
    cout << "H = " << H << endl;
    vector<int> sequence;
    for (unsigned int i = 0; i < H; i++) // the number of zero is (H)
    {
        sequence.push_back(0);
    }
    for (unsigned int i = 0; i < (m - 1); i++) // the number of 1 is (H + m - 1 - (m - 1))
    {
        sequence.push_back(1);
    }
    vector< vector<double> > ws;
    do 
    {
        int s = -1;
        vector<double> weight;
        for (unsigned int i = 0; i < (H + m - 1); i++)
        {
            if (sequence[i] == 1)
            {
                double w = i - s;
                w = (w - 1) / H;
                s = i;
                weight.push_back(w);
            }
        }
        double w = H + m - 1 - s;
        w = (w - 1) / H;
        weight.push_back(w);
        ws.push_back(weight);
    } while (next_permutation(sequence.begin(), sequence.end()));
    ofstream outfile("weight.txt");
    for (unsigned int i = 0; i < ws.size(); i++)
    {
        for (unsigned int j = 0; j < ws[i].size(); j++)
        {
            outfile << ws[i][j] << " ";
        }
        outfile << "\n";
    }
    return 0;
}
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值