Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  some method to save optimization result of variable into a file ??

    Posted 03/15/12 01:44 AM

    Originally posted by: SystemAdmin


    Hi,Everyone. I define the variable using the following code in Asp.net.
    INumVar[][] decide = new INumVar[num][]; //N*M
                for (int i = 0; i < num; i++)
                {
                    string[] name = new string[t];
                    for (int j = 0; j < t; j++)
                    {
                        name[j] = "decide(" + i + ")(" + j + ")";
                    }
                    decide[i] = new INumVar[t];
                    decide[i] = cplex.NumVarArray(t, 0, 1, NumVarType.Bool, name);
                };
    

    my question is that how can i save optimization result of the variable into a file after solved the model. the file is like txt,execell,etc.
    not just use System.Console.WriteLine() to print them out in the window.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: some method to save optimization result of variable into a file ??

    Posted 03/15/12 01:48 AM

    Originally posted by: SystemAdmin


    Maybe Cplex.WriteSolution or Cplex.WriteSolutions are what you are looking for?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: some method to save optimization result of variable into a file ??

    Posted 03/15/12 01:58 AM

    Originally posted by: SystemAdmin


    Can you send me some such examples ?just read the remark of Cplex.WriteSolution,and i can not get it .thanks a lot!!
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: some method to save optimization result of variable into a file ??

    Posted 03/15/12 03:25 AM

    Originally posted by: SystemAdmin


    when i do that like this:
    cplex.WriteSolutions("../../../../include/ilcplex/1.txt");
    

    then it will print out the exception error 1422:Could not open file "../../../../include/ilcplex/1.txt".
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: some method to save optimization result of variable into a file ??

    Posted 03/15/12 03:55 AM

    Originally posted by: SystemAdmin


    Does the path exist? Do you have privileges to write into that destination? Maybe try to write just to "1.txt" and see if that does work.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: some method to save optimization result of variable into a file ??

    Posted 03/15/12 04:17 AM

    Originally posted by: SystemAdmin


    the path of course exists.And i have aready write just to "1.txt" before that,and the file" 1.txt" would never change!
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: some method to save optimization result of variable into a file ??

    Posted 03/15/12 05:39 AM

    Originally posted by: SystemAdmin


    I am quite sure that the problem is not with CPLEX but with the way you specify the file to write to. What is the current working directory when you call WriteSolution()? Can you please double check that the relative path you specify indeed exists when you prepend the current working directory? Maybe something like this
    
    string cwd = Directory.GetCurrentDirectory(); string dir = cwd + 
    "/../../../../include/ilcplex"; string path = dir + 
    "/1.txt"; Console.WriteLine(
    "Current directory is {0}", cwd); Console.WriteLine(
    "Path to file is {0}", dir); Console.WriteLine(
    "File name is {0}", path); 
    
    if ( Directory.Exists(dir) ) 
    { Console.WriteLine(
    "Directory {0} exists", dir); 
    } 
    
    else 
    { Console.WriteLine(
    "Directory {0} does not exist!", dir); 
    } 
    
    if ( File.Exists(path) ) 
    { Console.WriteLine(
    "File {0} exists", path); 
    } 
    
    else 
    { Console.WriteLine(
    "File {0} does not exist", path); 
    }   cplex.WriteSolutions(
    "../../../../include/ilcplex/1.txt");
    

    What is the output of this? Do the directory and file exist?
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: some method to save optimization result of variable into a file ??

    Posted 05/03/17 02:50 AM

    Originally posted by: spyknight2004


    I was trying to use CPLEX in an MVC Web Application.
    Could you pls guide me how can I prepare an MVC WebApllication to use CPLEX libraries?
    is it possible at all?
    how can I add required DLLs? How can I add linkers? ...
    could you please suggest me a step by step process or introduce a useful reference?


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: some method to save optimization result of variable into a file ??

    Posted 05/09/17 09:17 AM

    You should ask this question in a Forum that is dedicated to MVC WebApplications. From that point of view, CPLEX is just a plain DLL that should be linked like any other DLL.


    #CPLEXOptimizers
    #DecisionOptimization