Topic
9 replies Latest Post - ‏2013-03-18T17:16:31Z by SystemAdmin
SystemAdmin
SystemAdmin
623 Posts
ACCEPTED ANSWER

Pinned topic request optimization

‏2013-03-13T19:47:40Z |
Hey
I am a new user for Cplex,
I started writing my first code using OPL but the result is no value
the following is my code:
/*********************************************
* OPL 12.5 Model
* Author: mimo
* Creation Date: Mar 5, 2013 at 11:59:33 PM
*********************************************/
using CP;

{string} jobs =...;
{string} links =...;
{string} wavelengths=... ;
{string} paths =...;
int ajobs,paths=... ;
int blinks,paths=... ;
int djobs=... ;
int h =...;
int Xjobs,paths,wavelengths;
int Yjobs,jobs;
int J =... ;
int rjobs=...;
//int val;

//dvar float+ Sjobs;
//dvar float+
dvar int Stjobs ;
//dvar int rjobs;
constraint c1 ;
constraint c2 ;
constraint c3 ;
constraint c4 ;
constraint c5 ;
constraint c6 ;
constraint c7;
constraint c8;
constraint c9;
constraint c10;
constraint c11;
constraint c12;
constraint c13;
constraint c14;

execute {
cp.param.SearchType = "DepthFirst";
}
minimize
sum (j in jobs) (St[j]-r[j]) ;

subject to {

forall (j in jobs)
c1=
{
St[j]>=r[j] ;
}

forall(j in jobs)
c2=
{
forall ( k in jobs:k!=j)
{
c3=
(Yj,k + Yk,j) == 1;
}
}
forall(j in jobs)
c4=
{
sum (p in paths) sum(w in wavelengths) (Xj,p,w*aj,p) ==1;
}
// put constraints for below for's
forall (j in jobs)
c5=
{
forall(p in paths)
{ c6=
forall(w in wavelengths)
{ c7=
0<=Xj,p,w<=1;
}
}
}

forall(j in jobs,k in jobs:k!=j)
c8=
{
forall(k in jobs:k!=j)
{ c9=
0<= Yj,k <=1;
}
}

forall(j in jobs)
c10=
{
St[j]>=0;
r[j]>=0;
}

forall(j in jobs)
c11 =
{
forall(k in jobs:k!=j)
{ c12=
forall(l in links)
{ c13=
forall(w in wavelengths)
{ c14=
((sum ( p in paths)(d[j]*bl,p*Xj,p,w + h*bl,p*Xj,p,w+h*bl,p*Xk,p,w))
+ St[j] - St[k] + h*Yj,k) <=3*h;
}
}
}
}
}
main{
thisOplModel.generate();
cp.startNewSearch();
while(cp.next() )
{
thisOplModel.postProcess();
}
}
please can anybody help me,
thanks
Updated on 2013-03-18T17:16:31Z at 2013-03-18T17:16:31Z by SystemAdmin
  • AlexFleischer
    AlexFleischer
    75 Posts
    ACCEPTED ANSWER

    Re: request optimization

    ‏2013-03-14T07:19:32Z  in response to SystemAdmin
    Hi,

    maybe your model is unfeasible.
    Can you attach your .mod and .dat?

    Regards
    • SystemAdmin
      SystemAdmin
      623 Posts
      ACCEPTED ANSWER

      Re: request optimization

      ‏2013-03-14T15:49:34Z  in response to AlexFleischer
      Hello,

      I have attached you my .dat file and in the following message I will attach you .mod file,
      Thanks a lot for your help,
      • SystemAdmin
        SystemAdmin
        623 Posts
        ACCEPTED ANSWER

        Re: request optimization

        ‏2013-03-14T15:50:10Z  in response to SystemAdmin
        This is my .mod file
        • AlexFleischer
          AlexFleischer
          75 Posts
          ACCEPTED ANSWER

          Re: request optimization

          ‏2013-03-14T16:18:42Z  in response to SystemAdmin
          Hi,

          if you comment your constraints c2 and c4 then you get a solution.

          So there could be an issue with those 2 constraints

          regards
          • SystemAdmin
            SystemAdmin
            623 Posts
            ACCEPTED ANSWER

            Re: request optimization

            ‏2013-03-14T16:27:50Z  in response to AlexFleischer
            Thanks a lot Alex,
            I will try to fix them.

            BR
            • SystemAdmin
              SystemAdmin
              623 Posts
              ACCEPTED ANSWER

              Re: request optimization

              ‏2013-03-14T17:01:40Z  in response to SystemAdmin
              In the constraints c2 and c4, is there any syntax error?

              If I comment c2 and c4 and run the code, I will be warned that:
              "Element c1 might not be used, similarly for the other constraints"
              Does this mean that the constraints are not being used?

              Thanks
              • SystemAdmin
                SystemAdmin
                623 Posts
                ACCEPTED ANSWER

                Re: request optimization

                ‏2013-03-14T18:33:22Z  in response to SystemAdmin
                The constraints are not being used but I can not know why.
                I have changed some constraints to see if the code will assign some values for the X and Y parameters but their values are zeros whatever the constraints are.

                Please can you help me?
                Thanks,
                • ol
                  ol
                  19 Posts
                  ACCEPTED ANSWER

                  Re: request optimization

                  ‏2013-03-18T16:00:20Z  in response to SystemAdmin
                  Hello,

                  I suspect the keyword dvar will help :-)

                  
                  dvar 
                  
                  int X[jobs,paths,wavelengths]; dvar 
                  
                  int Y[jobs,jobs];
                  


                  Regards,
                  ol
                  • SystemAdmin
                    SystemAdmin
                    623 Posts
                    ACCEPTED ANSWER

                    Re: request optimization

                    ‏2013-03-18T17:16:31Z  in response to ol
                    Thanks a lot, I guess it is working :),

                    BR
                    Manar