帮助线性编程 [英] Help linear programming

查看:81
本文介绍了帮助线性编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个我无法解决的问题。它就像一条蛇从顶部移动到金字塔底部,吃到最好的分数。



3

7 4

2 4 6

8 5 9 3



3 + 7 + 4 + 9 = 23





但是我找不到最后的条件,有必要选择数字邻接而不是最大的线。





感谢您的帮助!



我是什么尝试过:



我已写过:



Hello,

I have a problem that I can't solve. It's like a snake moving from the top to the pyramid to the bottom and eat the best score.

3
7 4
2 4 6
8 5 9 3

3+7+4+9=23


But I can't find the last conditions that oblige to choose number adjacents instead of the maximum of the line.


Thanks for helping me !

What I have tried:

I already wrote this :

CODE: SELECT ALL 
int n = ...; 
range rows = 1..n; 
int c[rows][rows] = ...; 
dvar boolean x[rows][rows]; 

maximize 

sum (i in rows, j in rows) c[i][j]*x[i][j] ; 



subject to { 
forall(i in rows) 
sum(j in rows) x[i][j]==1; 
}

推荐答案

Quote:

它就像一只蛇从顶部移动到金字塔底部并吃到最好的分数。

It's like a snake moving from the top to the pyramid to the bottom and eat the best score.



你没有神奇的方法可以知道答案是否最好。

这是一次暴力攻击。

要知道答案是最好的分数,你需要检查所有其他答案。

你必须构建一个算法,检查每个解决方案。



[更新]


You have no magic way to know that an answer is the best or not.
It is a brut force attack.
To know that an answer is best score, you need to check all other answers.
You have to build an algorithm that will check every single solution.

[Update]

引用:

这是动态编程...但我搜索一个约束,以避免总是取得最好的分数,只取相邻的最佳分数。

This is in dynamic programmation... But i search for a constraint to avoid to always take the best score and only take adjacent best scores.



作为程序员,你的工作是创建解决特定问题的算法,你不能依赖别人为你永远做到这一点,所以有一段时间你必须学习如何做。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并做出必要的调整以适应你的实际问题。


As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.


有人可以删除这个帖子吗?
Could someone delete this post ?


这篇关于帮助线性编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆