Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scores array has nan values #3

Open
SelinBayramoglu opened this issue May 20, 2022 · 7 comments
Open

scores array has nan values #3

SelinBayramoglu opened this issue May 20, 2022 · 7 comments

Comments

@SelinBayramoglu
Copy link

Hello,

I am trying to replicate the Learning to Branch study. I chose the problem domain as setcover. In 02_generate_dataset.py, when debugging the program, I realized that scores[action_set] has nan values and scores[action_set].argmax() returns the index of an element in scores[action_set] with a nan value. My understanding is that action_set is the set of pseudocandidates (nonfixed variables) and scores[action_set] should not have any nan values. I'd appreciate any help with this. Thank you.

@Yige-Lei
Copy link

Yige-Lei commented Jun 4, 2024

Have you solved this problem? I also encountered the same problem. TT

@Yifan-Lu-47
Copy link

Do you experience low accuracy when running this program? My accuracy is only around 9%. Have you encountered this situation?

@Zjz12138
Copy link

delete ’pseudo_candidates=True‘

@SelinBayramoglu
Copy link
Author

Have you solved this problem? I also encountered the same problem. TT

Hi, I realized that pseudocost scores are not calculated for candidates with an integral value in the LP solution and those candidates receive a nan. For some reason, python picks the first such element as argmax. Therefore, when the solver is performing pseudocost branching, such a candidate will be chosen for branching (if it exists). The data from such nodes is not scored, it is only stored during strong branching in which case nan scores do not arise.

Do you experience low accuracy when running this program? My accuracy is only around 9%. Have you encountered this situation?

In my experience setting pseudo_candidates to True or False might change the accuracy a bit, but not too drastically.

@Zjz12138
Copy link

Translated text:I am a Chinese student and my English is not very good. I am using a translator to respond to you, so please forgive any inaccuracies.

The errors in the action concentration occurred because the pseudo_candidates was set to TRUE. The scores of these erroneous actions were "nan," which led to a series of mistakes.

If you set the pseudo-cost to FALSE and generate a small dataset (for example, 1000 samples), you will find that the accuracy rate increases to 50%.

原文:我是一名中国学生并且我的英语并不好,我在使用翻译器来回答你,请见谅。
由于将伪成本设置为True,导致动作集中出现了错误动作,而错误动作的得分是nan,从而导致了一系列错误。
你可以将伪成本设置为FALSE后生成一个小数据集(例如1000个样本),这时你会发现准确率提升至50%。

Here is the result after set pseudo_candidates to False:
[2025-02-20 16:14:03.360582] EPOCH 2...
[2025-02-20 16:14:36.316428] TRAIN LOSS: 2.868 acc@1: 0.551 acc@3: 0.755 acc@5: 0.837 acc@10: 0.930
[2025-02-20 16:14:36.823017] VALID LOSS: 2.990 acc@1: 0.560 acc@3: 0.720 acc@5: 0.825 acc@10: 0.910
[2025-02-20 16:14:36.826145] best model so far
[2025-02-20 16:14:36.826196] EPOCH 3...
[2025-02-20 16:15:09.895681] TRAIN LOSS: 2.798 acc@1: 0.561 acc@3: 0.767 acc@5: 0.844 acc@10: 0.939
[2025-02-20 16:15:10.420335] VALID LOSS: 2.970 acc@1: 0.570 acc@3: 0.705 acc@5: 0.785 acc@10: 0.915
[2025-02-20 16:15:10.423583] best model so far

@SelinBayramoglu
Copy link
Author

Are you using a different problem family than the ones in the paper? The paper of this study reports high accuracies for the problem families when pseudo_candidates = True. I believe this is intuitive because even when all free integer variables are branching candidates (pseudo_candidates = True), the best ones will mostly likely be fractional, which is equivalent to having pseudo_candidates = False.

@Zjz12138
Copy link

Translation:The problem families I am using are consistent with those in the paper "Exact Combinatorial Optimization with Graph Convolutional Neural Networks," which employs strong branching without using pseudo costs or hybrid rules.

For MILP problems, after the solver obtains a linear solution, it will perform branching selection. At this point, all continuous variables and integer variables with integer values in the linear solution are fixed, so their strong branching scores are nan. The action_set only contains integer variables with non-integer values in the linear solution. However, when using pseudo costs, some integer variables with integer values in the linear solution appear in the action_set. Their score was nan, which resulted in an error.

原文:我使用的问题类别与Exact Combinatorial Optimization with Graph Convolutional Neural Networks这篇论文一致,这篇论文是使用的强分支规则而没有使用伪成本或混合规则。

对于MILP问题,当求解器获得线性解后,将进行分支选择,此时所有连续变量和线性解为整形的整形变量的值被固定,因此它们的强分支分数是nan,action_set中只有线性解为非整形的整形变量。但当使用伪成本时,action_set中有了一些线性解为整形的整形变量,他们的分数为nan,导致了错误。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants