在CPLEX OPL中使用范围内的数组

时间:2018-05-16 02:15:51

标签: constraints linear-programming cplex opl

package main

import (
    "fmt"
    "runtime"
    "path"
    "path/filepath"
)

func main() {
    _, filename, _, ok := runtime.Caller(0)
    if !ok {
        panic("No caller!")
    }
    fmt.Printf("Calling file: %s\n", path.Base(filename))

    // Without extension
    fname := fmt.Sprintf("%s.log", path.Base(filename[0:len(filename)-len(filepath.Ext(filename))]))
    fmt.Printf("Desired log file name: %s\n", fname)

    // you can now use fname to form desired log path
    logPath := path.Join("/var/log", fname)
    fmt.Printf("Desired log path: %s\n", logPath)
}

基本上我想为每个t1 t2 t3使用特定值。我希望我的范围介于t1和t4之间。然后我调用t1我想用1 2 3作为索引。我无法找到解决方法,我是CPLEX OPL的新手。这可能吗?如果是这样我怎么能做到这一点?

1 个答案:

答案 0 :(得分:0)

让我帮助您解决语法问题:

{int} t1 = {1,2,3};
{int} t2 = {4,5,6};
range D=1..10;



tuple tuple4
{
int i;
int j;
}

{tuple4} t4={<i,j> | i in t1,j in t2};

int task[<i,j> in t4][d in D]=i+j+d;

dvar int C[t4];

subject to
{

forall(i4 in t4)C[i4] >= sum (d in D) d * task[i4][d]; 

}

问候