啥也不说了,我就跟Mosek死磕了,从头开始学 MOSEK Optimizer API for C 9.1.13。英文原文:
- Create a project or open an existing project in Visual Studio.
- In the Solution Explorer right-click on the relevant project and select Properties. This will open the Property pages dialog.
- In the selection box Configuration: select All Configurations.
- In the tree-view open Configuration Properties → C/C++ → General.
- In the properties click the Additional Include Directories field and select edit.
- Click on the New Folder button and write the full path to the h header file or browse for the file. For example, for 64-bit Windows use
<HEADERDIR>
. - Click OK.
- Back in the Property Pages dialog select from the tree-view Configuration Properties → Linker → Input.
- In the properties,view click in the Additional Dependencies field and select edit. This will open the Additional Dependencies dialog.
- Add the full path of the MOSEK
lib
. For example, for 64-bit Windows: - <LIBDIR> \ mosek64_9_1.lib
- Click OK.
- Back in the Property Pages dialog click OK.
其实基本就是配置两条,
一个在C/C++选项的General,配置下路径..\Mosek\9.1\tools\platform\win64x86\h; link:..\Mosek\9.1\tools\platform\win64x86\bin\mosek64_9_1.lib
Hello World实验程序。这里的配置要比Fusion容易。
#include "mosek.h"
#include <stdio.h>
/* Error checking not included */
int main() {
MSKrescodee r, trmcode;
MSKenv_t env = NULL;
MSKtask_t task = NULL;
double xx = 0.0;
MSK_makeenv(&env, NULL); // Create environment
MSK_maketask(env, 0, 1, &task); // Create task
MSK_appendvars(task, 1); // 1 variable x
MSK_putcj(task, 0, 1.0); // c_0 = 1.0
MSK_putvarbound(task, 0, MSK_BK_RA, 2.0, 3.0); // 2.0 <= x <= 3.0
MSK_putobjsense(task, MSK_OBJECTIVE_SENSE_MINIMIZE); // Minimize
MSK_optimizetrm(task, &trmcode); // Optimize
MSK_getxx(task, MSK_SOL_ITR, &xx); // Get solution
printf("Solution x = %f\n", xx); // Print solution
MSK_deletetask(&task); // Clean up task
MSK_deleteenv(&env); // Clean up environment
return 0;
}
观察了这个源代码,觉得在方法实现形式上比Fusion上容易。基本上是传统的编程方法。
下面就是来看一下这个具体怎么来玩。
学习笔记2:设计框架 https://blog.youkuaiyun.com/aliexken/article/details/104575835