问题描述
出于研究目的,我必须使用不同的参数多次运行相同的优化模型。 (我尝试观察的结果是,当我增加一个参数时,我将得到一个模型。)对我来说,最简单的方法是使用Excel宏,因为这将使我永远永远一个一个地求解每个模型并记录下结果。但是我不知道如何使VBA调用CPLEX Solver,并从excel工作表中读取我的所有参数,并将结果写回那里。
I have to run the same optimization model many times with different parameters for research purposes. (I am trying to observe the results I'll get off a single model when I increase a parameter) The easiest way for me to do is to use Excel Macros as it would take me forever to solve each model one by one and record the results. However I have no idea how I will make VBA call the CPLEX Solver and read all my parameters from my excel sheet and write the results back there.
如果我要放我想在VBA中逐步执行的操作,就像这样:
If I am to put what I want to do in steps in VBA, it'd be something like so:
- 将参数增加x(此参数是由CPLEX读取-但我不知道该代码的VBA代码-)
- 使用x的新值解决模型。
- 写所有结果都返回到Excel工作表(再次使用VBA代码)
- 将所有步骤重复k次。
- Increase the parameter by x (This parameter is being read by CPLEX -but i don't know the VBA code for that-)
- Solve the model using the new value for x.
- Write all results back to the Excel sheet (using VBA codes, once again)
- Repeat all steps by k times.
总而言之,我很高兴知道如何做到
So to sum it all up I'd be really happy to know how I can,
- 集成VBA和CPLEX
- 用于使CPLEX从Excel工作表读取的VBA代码。
- 用于使CPLEX写入我的Excel工作表的VBA代码。
预先感谢。
注意:我尝试阅读所有疑难解答+ CPLEX指南以提供帮助我在这个问题上
Note: I tried reading all of the troubleshooting + CPLEX guides to help me on this issue but it confused me even more.
推荐答案
您看过
?
和
中的.bas示例cplex\examplessrc\excel
?
and at the .bas examples incplex\examples\src\excel?
致谢
这篇关于CPLEX OPL和Excel VBA集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!