找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

楼主: aimisiyou

和值固定的不同组合

[复制链接]

已领礼包: 1883个

财富等级: 堆金积玉

 楼主| 发表于 2019-12-16 12:09:56 | 显示全部楼层
aimisiyou 发表于 2019-11-11 07:50
_$ (defun H_L (lst L)
  (setq i -1)
  (setq lst1 (mapcar '(lambda (x y)   

_$ (setq w_tol 179 wlst '(103 65 41 39 35 27 21 17 3 97 89) clst  wlst  M_pop 100 M_re 400 plst nil)
(defun rnd ()
  (* (rem (getvar "cputicks") 1e4) 1e-4)
)
(defun ff (n)
    (setq lst '((0 5 1)(5 10 0)) vlst nil)
    (repeat n
        (setq num (fix (rem (getvar "CPUTICKS") 11)))
        (setq vlst (cons (car (vl-remove nil (mapcar '(lambda (x) (if (<= (car x) num (cadr x)) (last x) nil)) lst))) vlst))
    )
)
(defun dfun (e1 e2)
(apply '+ (mapcar '(lambda (x y) (boole 6 x y)) e1 e2))
)
(defun move (e1 e2)
(setq dis (dfun e1 e2) k (/ (fit e1) 1.0 (fit e2)) p2 0.992)
(mapcar '(lambda (x y) (if (< (setq p (rnd)) (+ (* k 0.4) (/ 1.0 (+ 2.0 dis)))) y (if (< (+ (* k 0.4) (/ 1.0 (+ 2.0 dis))) p p2) x  (boole 7 y (fix (+ 0.5 (rnd))))))) e1 e2)
)
(defun fit (e)
(if (<= (apply '+ (mapcar '* wlst e)) w_tol)
     (setq fitvalue  (apply '+ (mapcar '* clst e)))
     (setq fitvalue  0)
)
)
(repeat M_pop
  (setq plst (cons (ff (length wlst)) plst))
)
(setq pest (cdr (car (vl-sort (mapcar '(lambda (x) (cons (fit x) x)) plst)  '(lambda (e1 e2) (> (car e1) (car e2)))))))
(repeat M_re
(progn
  (setq plst (mapcar '(lambda (x) (move x pest)) plst))
  (setq pest_new (cdr (car (vl-sort (mapcar '(lambda (x) (cons (fit x) x)) plst)  '(lambda (e1 e2) (> (car e1) (car e2)))))))
  (if (> (fit pest_new) (fit pest)) (set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1 1 1 1) (0 0 0 0 1 1 1 1 0 1 0) (0 1 0 0 1 1 1 0 0 0 1) (1 0 1 0 0 0 0 1 1 1 1) (1 1 1 0 0 0 1 1 0 1 1) (1 0 0 1 1 0 1 1 1 1 1) (0 0 1 0 1 0 1 1 1 1 0) (1 1 1 0 0 1 1 1 0 1 0) (1 1 0 1 1 1 0 1 1 1 0) (1 1 1 0 0 1 1 0 1 0 0) (1 1 0 1 1 1 0 1 0 0 0) (1 0 0 1 1 1 0 1 0 1 1) (1 1 1 1 1 1 1 0 0 1 0) (1 0 0 1 1 1 0 0 0 0 1) (1 0 1 1 1 0 1 1 0 1 1))
(0 0 0 1 0 1 1 0 1 0 1)
(0 0 0 1 0 1 1 0 1 0 1)
(179 (39 27 21 3 89))
_$
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-22 09:46 , Processed in 0.355667 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表