GithubHelp home page GithubHelp logo

xzhang2523 / libmoon Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 0.0 9.88 MB

Libmoon is a flexible and extensible multi-objective optimization platform. Our goal is to make MOO great again. We released libmoon not because developing MOO is easy, but because it is hard.

Home Page: https://pypi.org/project/libmoon/

License: MIT License

Python 77.30% Makefile 0.19% Batchfile 0.24% CSS 9.32% JavaScript 9.84% HTML 3.13%
multiobjective-learning multiobjective-optimization multitask-learning reinforcement-learning baysian-optimisation optimization-algorithms

libmoon's Introduction

Moon: A Standardized/Flexible Framework for MultiObjective OptimizatioN

Moon

'' I raise my cup to invite the moon. With my shadow we become three from one. '' -- Li Bai.

Moon: is a multiobjective optimization framework, from single-objective optimization to multiobjective optimization, towards a better understanding of optimization problems and fair comparasions between MOO algorithms.

Main contributors: Xiaoyuan Zhang (project leader), Ji Cheng, Liao Zhao, Weiduo Liao, Zhe Zhao, Xi Lin, Cheng Gong, Longcan Chen.

Advised by: Prof. Yifan Chen, Prof. Zhichao Lu, Prof. Ke Shang, Prof. Tao Qin.

Corresponding to: Prof. Qingfu Zhang (CityU HK).

The following methods can refer to https://github.com/xzhang2523/awesome-moo-ml-papers. (Welcome to star both!)

(1) A standardlized gradient based framework.

  • Problem class. For more problem details, please also check the Readme_problem.md file. (i) For synthetic problems,
  • Problem Paper Project/Code
    ZDT paper project
    DTLZ [paper] project
    MAF paper [project]
    WFG code Real world problems. Y
    Fi's code Real world problems. Y
    RE paper code

(2) For multitask learning problems,

Problem Paper Project/Code
MO-MNISTs PMTL COSMOS
Fairness Classification COSMOS COSMOS
Federated Learning Federal MTL
Problem Paper Project/Code
Synthetic (DST FTS...) Envelop code
Robotics (MO-MuJoCo...) PGMORL code
  • Gradient-based Solver.

    Method Property #Obj Support Published Complexity
    EPO code Exact solution. Any Y ICML 2020 $O(m^2 n K )$
    COSMOS code Approximated exact solution. Any Y ICDM 2021 $O(m n K )$
    MOO-SVGD code A set of diverse Pareto solution. Any Y NeurIPS 2021 $O(m^2 n K^2 )$
    MGDA code Arbitray Pareto solutions. Location affected highly by initialization. Any Y NeurIPS 2018 $O(m^2 n K )$
    PMTL code Pareto solutions in sectors. 2. 3 is difficult. Y NeurIPS 2019 $O(m^2 n K^2 )$
    PMGDA Pareto solutions satisfying any preference. Any Y Under review $O(m^2 n K )$
    GradienHV WangHao code It is a gradient-based HV method. 2/3 Y CEC 2023 $O(m^2 n K^2 )$
    Aggregation fun. based, e.g. Tche,mTche,LS,PBI,... Pareto solution with aggregations. Any Y

    Here, $m$ is the number of objectives, $K$ is the number of samples, and $n$ is the number of decision variables. For neural network based methods, $n$ is the number of parameters; hence $n$ is very large (>10000), K is also large (e.g., 20-50), while $m$ is small (2.g., 2-4).

    As a result, m^2 is not a big problem. n^2 is a big problem. K^2 is a big problem.

    Time complexity of gradient based methods are as follows, -1 Tier 1. GradAggSolver. -2 Tier 2. MGDASolver, EPOSolver, PMTLSolver. -3 Tier 3. GradHVSolver -4 Tier 4. MOOSVGDSolver

    Current support: GradAggSolver, MGDASolver, EPOSolver, MOOSVGDSolver, GradHVSolver, PMTLSolver.

    Important things to notice: The original code MOO-SVGD does not offer a MTL implement. Our code is the first open source code for MTL MOO-SVGD.

  • PSL solvers

    • EPO-based
    • Agg-based
    • Hypernetwork-based
    • ConditionalNet-based
    • Simple PSL model
    • Generative PSL model
  • MOEA/D Current supported:

  • ML pretrained methods.

How to install libmoon? libmoon is on the standard pypi (https://pypi.org/project/libmoon/).

    pip install libmoon==0.1.11

Example code for a synthetic problem,

from libmoon.solver.gradient import GradAggSolver
from libmoon.util_global.constant import problem_dict
from libmoon.util_global.weight_factor.funs import uniform_pref
import torch
import numpy as np
from matplotlib import pyplot as plt
import argparse
from libmoon.visulization.view_res import vedio_res

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='example')
    parser.add_argument('--n-partition', type=int, default=10)
    parser.add_argument('--agg', type=str, default='tche')  # If solve is agg, then choose a specific agg method.
    parser.add_argument('--solver', type=str, default='agg')
    parser.add_argument('--problem-name', type=str, default='VLMOP2')
    parser.add_argument('--iter', type=int, default=1000)
    parser.add_argument('--step-size', type=float, default=1e-2)
    parser.add_argument('--tol', type=float, default=1e-6)
    args = parser.parse_args()
    
    
    # Init the solver, problem and prefs. 
    solver = GradAggSolver(args.step_size, args.iter, args.tol)
    problem = problem_dict[args.problem_name]
    prefs = uniform_pref(args.n_partition, problem.n_obj, clip_eps=1e-2)
    args.n_prob = len(prefs)

    # Initialize the initial solution 
    if 'lbound' in dir(problem):
        if args.problem_name == 'VLMOP1':
            x0 = torch.rand(args.n_prob, problem.n_var) * 2 / np.sqrt(problem.n_var) - 1 / np.sqrt(problem.n_var)
        else:
            x0 = torch.rand(args.n_prob, problem.n_var)
    else:
        x0 = torch.rand( args.n_prob, problem.n_var )*20 - 10


    # Solve results
    res = solver.solve(problem, x=x0, prefs=prefs, args=args)
    
    # Visualize results
    y_arr = res['y']
    plt.scatter(y_arr[:,0], y_arr[:,1], s=50)
    plt.xlabel('$f_1$', fontsize=20)
    plt.ylabel('$f_2$', fontsize=20)
    plt.show()
    
    # If use vedio
    use_vedio=True
    if use_vedio:
        vedio_res(res, problem, prefs, args)     

Example of MTL



libmoon's People

Contributors

xzhang2523 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.